Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277333

Glyph outline broken at small sizes

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Fails in:
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)
      OpenJDK 64-Bit Server VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)
      OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)


      Works in:
      OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      The outline of a GlyphVector created from the SERIF font with a size of 1 is incorrect when the font is a compound glyph - ie. U+00CA (E with a circumflex). The circumflex is positioned way off its mark, so much so the text is illegible. Increase the font size and it's correct. I suspect something, somewhere is being rounded to an int when it should be a float.

      Happens in multiple fonts on Linux, eg "Times New Roman" or "DejaVu Serif" - both from the Ubuntu apt packages. macOS is fine.

      This was working with 11.0.3+7 but not with 11.0.3+12 up to 17.0.1.

      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached, look at the image.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Change the scale in the attached to a higher value (eg 10) and run it again, the result is correct.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.geom.*;
      import java.awt.image.*;
      import javax.imageio.*;
      import java.awt.font.*;
      import java.io.File;

      public class Test {
          public static void main(String[] args) throws Exception {
              
              int scale = 1;
              Font font = new Font("serif", Font.PLAIN, scale);
              FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true);
              GlyphVector gv = font.createGlyphVector(frc, "\u00ca");
              Shape shape = gv.getOutline();
              
              shape = AffineTransform.getScaleInstance(400f/scale,400f/scale).createTransformedShape(shape);
              Rectangle r = shape.getBounds();
              BufferedImage img = new BufferedImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g = img.createGraphics();
              g.transform(AffineTransform.getTranslateInstance(-r.x, -r.y));
              g.setColor(Color.white);
              g.fill(r);
              g.setColor(Color.black);
              g.fill(shape);
              g.dispose();
              ImageIO.write(img, "png", new File("out.png"));
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            pnarayanaswa Praveen Narayanaswamy
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: