On Tue, 10 Dec 2024 10:05:18 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> **Description:**
>> The PR updates sun.print.CUPSPrinter's behavior in terms of reading media 
>> imageable area values according to the PostScript Printer Description File 
>> Format Specification.
>> The actual implementation reads X and Y coordinates of the upper right 
>> corner of the imageable area as width and height of the imageable area. 
>> https://bugs.openjdk.org/browse/JDK-8344119
>> 
>> **Updates:** 
>> Added subtraction of the X and Y coordinates of the lower left corner to fix 
>> the width and height values of the imageable area.
>> 
>> **Tests:**
>> Tested with `test/jdk/javax/print/DialogMargins.java` using Brother 
>> DCP-T720DW, the test draws a black line along the borders of the imageable 
>> area.
>> The test was run with the minimum possible margins.
>> _Before the fix_: the right and bottom lines are not printed (the right and 
>> bottom lines are outside the printable area).
>> _After the fix_: all lines are printed.
>
> I can see the spec 
> https://web.mit.edu/PostScript/Adobe/Documents/5003.PPD_Spec_v4.3.pdf
> indeed say that that 
> 
>> "The bounding box value of *ImageableArea is given as four real numbers, 
>> repre-
>> senting the x and y coordinates of the lower left and upper right corners of 
>> the
>> region, respectively, in the PostScript language default user space 
>> coordinate
>> system."
>> 
> 
> but I believe it will be better if we do the correction in 
> CUPSfuncs.c#getPageSizes() which reads the "PageSize" and store the value so 
> that it stores the correct value in native..
> 
> Also, it will be better to add a manual test similar to what is mentioned in 
> the description above..

@prsadhuk, thanks for your review. Let me explain my decision before I move the 
changes to the native code.
CUPS uses ppd_size_t structure to store a page size, and I suggested that we 
should return values from the native code as much closer to the CUPS's 
ppd_size_t structure. The structure contains 6 float values: width, length, 
left, bottom, right, and top; thus we should return from the native function 
the same 6 float values. 


typedef struct ppd_size_s               // Page Sizes @deprecated@
{
  int           marked;                 // Page size selected?
  char          name[PPD_MAX_NAME];     // Media size option
  float         width;                  // Width of media in points
  float         length;                 // Length of media in points
  float         left;                   // Left printable margin in points
  float         bottom;                 // Bottom printable margin in points
  float         right;                  // Right printable margin in points
  float         top;                    // Top printable margin in points
} ppd_size_t;

https://github.com/OpenPrinting/cups/blob/c76b026e54a3f95d56d20c36d42c8bb4d4e23029/cups/ppd.h#L195

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

PR Comment: https://git.openjdk.org/jdk/pull/22110#issuecomment-2538903474

Reply via email to