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

Remove old/unused draw string code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • None
    • javafx

    Description

      When the complex/richtext text was introduced the code doubled, the old path was keep around for safety and entire new implementation was added.
      Not that last users of old path were updated to use the new implementation we are able to remove the old code.

      There are list of methods and classes that are not complex-aware can be removed:
      PGText
      NGText
      PGTextHelper
      NGTextHelper
      Toolkit#createPGText
      StubToolkit#createPGText
      DummyToolkit#createPGText
      QuantumToolkit#createPGText
      Graphics#(String, FontStrike, float, float);
      Graphics#(String, FontStrike, float, float, Color, int, int);
      TestGraphics#(String, FontStrike, float, float);
      TestGraphics#(String, FontStrike, float, float, Color, int, int);
      BaseShaderGraphics#(String, FontStrike, float, float);
      BaseShaderGraphics#(String, FontStrike, float, float, Color, int, int);
      SWGraphics#(String, FontStrike, float, float);
      SWGraphics#(String, FontStrike, float, float, Color, int, int);
      J2DGraphics#(String, FontStrike, float, float);
      J2DGraphics#(String, FontStrike, float, float, Color, int, int);
      FontStrike#getStringWidth ***see note****
      FontStrike#getStringHeight
      FontStrike#getStringBounds
      FontStrike#getStringVisualBounds
      FontStrike#getOutline(String, BaseTransform);
      FontStrike#getOutline(String, BaseTransform, Path2D);
      T2KFontStrike#getStringWidth
      T2KFontStrike#getStringHeight
      T2KFontStrike#getStringBounds
      T2KFontStrike#getStringVisualBounds
      T2KFontStrike#getOutline(String, BaseTransform);
      T2KFontStrike#getOutline(String, BaseTransform, Path2D);
      CompositeStrike#getStringWidth
      CompositeStrike#getStringHeight
      CompositeStrike#getStringBounds
      CompositeStrike#getStringVisualBounds
      CompositeStrike#getOutline(String, BaseTransform);
      CompositeStrike#getOutline(String, BaseTransform, Path2D);

      The one method is the list above that is in use is strike#getStringWidth():

      TextAreaSkin and TextFieldSkin use FontMetrics#computeStringWidth("W");
      Toolkit.getToolkit().getFontLoader().getFontMetrics(font.get());
      FontMetrics calls in FontLoader:
      Toolkit.getToolkit().getFontLoader().computeStringWidth(string, getFont());
      FontLoader calls in PrismFontUtils
      PrismFontUtils.computeStringWidth(prismFont, string);
      PrismFontUtils calls in FontStrike
      strike.getStringWidth(string);
      which naively accumulates the advances using getCharAdvance


      That can be workaround a number of different ways:
      A) re implement PrismFontUtils.computeStringWidth to use FontStrike#getCharAdvance
      B) replace FontMetrics#computeStringWidth(String) by FontMetrics#getCharAdvance(int);
      C) change TextAreaSkin and TextFieldSkin to use a Text node instead of internals is currently uses


      I like (B), but (A) is the least intrusive.

      Attachments

        Activity

          People

            fheidric Felipe Heidrich (Inactive)
            fheidric Felipe Heidrich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: