API review "RT-30861: Add simple Font factory method for a default font of a different size"

Felipe Heidrich felipe.heidrich at oracle.com
Mon Jun 3 11:07:04 PDT 2013

Moving API discussion to the mailing:

Font#font(float)		- creates new font using default font family name and given font size
Font#font(String)		- creates new font using given font family and default font size

Phil Wrote
> I keep having to type this:
>    text.setFont(Font.font(Font.getDefault().getFamily(), 81));
>I would prefer just:
>    text.setFont(Font.font(81));
>which would use the default font.

I think that last line was meant to be "default font family".
All the font(..) factory methods are family based and we should
keep it that way.
So the new API Font.font(-81) as specified and implemented here
is using the default family but its not necessarily getting the same
style as the default font. Nor would it inherit any other (theoretical)
attributes of the default font. In practice it'll all work out
the same until the day that some platform has a bold default font
or has something else different about the default font that can't
be communicated solely through family.
So some day we also need to add Font.deriveFont(..).

Felipe wrote:
Right, the problem you pointed out would be better solved using the derive pattern:


That said, the two new methods don't exclude the option of adding derive in the future.
They are consistent with the javadoc, other factory methods, and probably good enough to make Richard happy for now.

Anyway, I will let him be the judge for that. 

Personally I would go with the 2 new methods for now and worried about derive in the future (at which time we can consider the implication of different style options such as stretch and advance typographic features).


More information about the openjfx-dev mailing list