-
Enhancement
-
Resolution: Unresolved
-
P4
-
8u5
I often want a font that is in some way derived from another font. To do that now is cumbersome and might be error prone and not future proof.
Something like this has to be done:
setFont(Font.font(getFont().getFamily(), FontWeight.BOLD, getFont().getSize()));
It is for instance easy to forget the posture when creating a derived font, like I did above.. There might also be (this I don't know) other settings that can be set on the font but isn't in the constructor. Further it is future proof since new properties on Font can be transferred to the derived font.
Therefor adding notation like this would be a great improvement to Font, yet it would be very easy to implement.
Font derivedFont = font.withWeight(..);
Font derivedFont = font.withSize(..);
Font derivedFont = font.withFamily(..);
Font derivedFont = font.withPosture(..);
The contract should be that only the provided property is changed and everything else is transferred to the derived font, if possible.
There might also be composite versions, like
Font derivedFont = font.withWeightSize(..);
Something like this has to be done:
setFont(Font.font(getFont().getFamily(), FontWeight.BOLD, getFont().getSize()));
It is for instance easy to forget the posture when creating a derived font, like I did above.. There might also be (this I don't know) other settings that can be set on the font but isn't in the constructor. Further it is future proof since new properties on Font can be transferred to the derived font.
Therefor adding notation like this would be a great improvement to Font, yet it would be very easy to implement.
Font derivedFont = font.withWeight(..);
Font derivedFont = font.withSize(..);
Font derivedFont = font.withFamily(..);
Font derivedFont = font.withPosture(..);
The contract should be that only the provided property is changed and everything else is transferred to the derived font, if possible.
There might also be composite versions, like
Font derivedFont = font.withWeightSize(..);