On Mon, 11 Mar 2024 13:54:02 GMT, Alexander Scherbatiy <alex...@openjdk.org> 
wrote:

> The fix provides ability to print Black & White pages on macOS.
> 
> Cocoa API has 
> [PMSetColorMode](https://developer.apple.com/documentation/applicationservices/core_printing/1805783-pmsetcolormode)
>  function but it is marked as deprecated and really does nothing.
> 
> There is no replacement; this function was included to facilitate porting 
> legacy applications to macOS, 
> but it serves no useful purpose.
> 
> Dumping `NSPrintInfo` print settings which were set by the native print 
> dialog on macOS shows that the keys and values used for Black & White 
> printing depend on the used printer type.
> For example, the tested 
> `HP Color LaserJet MFP M180n` printer uses `ColorModel` key and`Gray` value, 
> and
> `HP Ink Tank 110 series` uses `HPColorMode` key and `grayscale` value.
> 
> Printing all `NSPrintInfo` presets shows that they do not contain key/value 
> pairs  for Black&White settings.
> This is the code snippet used to print `NSPrintInfo` presets:
> 
>     PMPrinter pr;
>     PMPrintSession printSession = (PMPrintSession)[printInfo PMPrintSession];
>     OSStatus status = PMSessionGetCurrentPrinter(printSession, &pr);
>     CFArrayRef presetsList = nil;
>     status = PMPrinterCopyPresets(pr, &presetsList);
>     CFIndex arrayCount = CFArrayGetCount(presetsList);
> 
>     for (CFIndex index = 0; index < arrayCount; index++) {
>         PMPreset preset = (PMPreset)CFArrayGetValueAtIndex(presetsList, 
> index);
>         CFStringRef presetName = nil;
>         if (PMPresetCopyName(preset, &presetName) == noErr && 
> CFStringGetLength(presetName) > 0) {
>             NSLog(@"  presetName: '%@'", presetName);
>             NSDictionary* dict = nil;
>             if (PMPresetGetAttributes(preset, (CFDictionaryRef*)(&dict)) == 
> noErr) {
>                    // print preset dict
> 
> 
> The idea of the proposed fix is to store printer dependent key/value pairs in 
> the `<jdk-home>/conf/printer.properties` property file.
> 
> The property file has the format:
> 
> print-attribute.print-attribute-value.key=value
> 
> where `print-attribute` is the java print attribute, `print-attribute-value` 
> is the corresponding attribute value, and `key` and `value` is the key/value 
> pair used by a specific printer.
> 
> For example, for `Chromaticity` attribute the property file could look like:
> 
> Chromaticity.MONOCHROME.ColorModel=Gray
> Chromaticity.COLOR.ColorModel=CMYK
> Chromaticity.MONOCHROME.HPColorMode=grayscale
> Chromaticity.COLOR.HPColorMode=color
> 
> where `Chromaticity.MONOCHROME` key prefix corresponds to 
> `Chromaticity.MONOCHOROME` print attribute constant  with  (...

I wonder how this is supposed to be documented ? And who is supposed to 
maintain this file ?
I think this PR should be withdrawn.

src/java.desktop/share/conf/printer.properties line 1:

> 1: Chromaticity.MONOCHROME.BRPrintQuality=Black

Why, oh why  would a file needed for CUPS on macOS be in shared code ?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18195#issuecomment-1992119844
PR Review Comment: https://git.openjdk.org/jdk/pull/18195#discussion_r1521814087

Reply via email to