[OpenJDK 2D-Dev] [9] Review request for 8158370 Text drawn with floating pointing scale can be shifted to one pixel

Alexandr Scherbatiy alexandr.scherbatiy at oracle.com
Thu Jun 23 20:04:42 UTC 2016


Hello,

Could you review the fix:
   bug: https://bugs.openjdk.java.net/browse/JDK-8158370
   webrev: http://cr.openjdk.java.net/~alexsch/8158370/webrev.00

   Char advance in user space is calculated with float precision. That 
leads that summed up char advances in user space can have small rounding 
error.

   To draw a substring of a text as selected it needs to draw the 
selected text from the string location plus the preceding text width.
   The selected text location is close to an integer value for an 
integer scale:
     (textX + sum(charAdvanceInDevSpave/scale) + transformTranslate) * 
scale //  both textX and transformTranslate have integer value

   The situation is different for floating point scales. Now (textX + 
transformTranslate) * scale can be a floating point value like N.5 where 
N is some integer value. The sum(charAdvanceInDevSpave/scale) * scale is 
close to an integer.
   Sum of these values can be M.499.. which is rounded to M or M.500.. 
which is rounded to M+1.

   Because of this a selected text can be shifted to one pixel left from 
the required position.

   The proposed fix rounds the text coordinates to the closest half 
integer value if it is necessary in dev space.

  Thanks,
  Alexandr.




More information about the 2d-dev mailing list