Uploaded image for project: 'Pivot'
  1. Pivot
  2. PIVOT-312

Add new font setters to text-based skin classes that allow a caller to customize the theme font



    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: wtk
    • Labels:


      Callers often want to modify only the weight, size, or style of the theme font when constructing a UI. Currently, the Label skin supports this via the "fontBold", "fontItalic", and "fontSize" styles, but similar styles are not available for other text-based components (e.g. buttons), and it would be cumbersome to add them.

      A more comprehensive solution would add support for a new JSON-based font encoding that callers could use as follows:

      <Label text="Foo" styles="{font:{bold:true}}"/>

      Instead of calling Font.decode(), the string-based font setter in LabelSkin would call a new method, org.apache.pivot.wtk.GraphicsUtilities.decodeFont(String):Font. If the string begins with a curly brace, this method would derive the font value from the theme font, applying the given properties. Otherwise, it would delegate to Font.decode().

      Callers should be able to fully specify a font using this notation (i.e. support a "name" property in addition to "size", "bold", and "italic"). So, decodeFont() should work as follows:

      • Get the current theme font.
      • Extract name, size, bold, and italic properties from it.
      • Override these values with values specified in the JSON string.
      • Create a new Font instance and return it.

      The existing "fontBold", "fontItalic", and "fontSize" styles in LabelSkin should be removed as part of this change.




            • Assignee:
              gbrown Gregory K. Brown
              gbrown Gregory K. Brown
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: