Outline stroke on text has artifacts

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11, D3D

      A DESCRIPTION OF THE PROBLEM :
      Rendering text with an outline stroke produces unexpected stroke artifacts.

      In the example code, the following issues can be observed:

      - At the top end of the digit 4, a sharp tip appears. If you look zoom in (with a screenshot tool for example), it looks as if two stroke renderings overlap. I have observed the same for the letter 'M', but that was in another application.
      - The lowercase 'o' loses the inner stroke as the stroke width increases.
      - The dots on 'i' and 'j' are not properly outlined, showing gaps inside.
      - The glyphs themselves sometimes appear slightly unclear or blurry, which may be related to subpixel rendering.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See demo code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Clean looking text, no space with increasing stroke with, no tips/spikes
      ACTUAL -
      Artifacts described above

      ---------- BEGIN SOURCE ----------
      public class TextOutsideStrokeDemo extends Application {

      private static final String DEMO_TEXT = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9";
      private static final Font SYSTEM_FONT = Font.font("System", 12);

      @Override
      public void start(Stage stage) {

      final VBox root = new VBox(20);
      root.setPadding(new Insets(50));

      for (double strokeWidth = 1; strokeWidth <= 5; strokeWidth += 0.5) {
      final var text = new Text(DEMO_TEXT);
      text.setFont(SYSTEM_FONT);
      text.setFill(Color.BLACK);
      text.setStroke(Color.MAGENTA);
      text.setStrokeWidth(strokeWidth);
      text.setStrokeType(StrokeType.OUTSIDE);

      root.getChildren().add(text);
      }

      final Scene scene = new Scene(root);
      stage.setScene(scene);
      stage.show();
      }

      public static void main(String[] args) {
      launch(args);
      }
      }
      ---------- END SOURCE ----------

        1. screenshot.png
          screenshot.png
          139 kB
        2. 4.png
          4.png
          0.7 kB
        3. o.png
          o.png
          0.9 kB
        4. i_j.png
          i_j.png
          0.7 kB
        5. Test.java
          1 kB
        6. outline_stroke-linux.png
          outline_stroke-linux.png
          120 kB
        7. outline_issue-macos.png
          outline_issue-macos.png
          518 kB

            Assignee:
            Kevin Rushforth
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: