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

                 Key: PIVOT-312
                 URL: https://issues.apache.org/jira/browse/PIVOT-312
             Project: Pivot
          Issue Type: Improvement
          Components: wtk
            Reporter: Greg Brown
             Fix For: 1.4


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.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to