Typeface Class
The Typeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specify how text appears when drawn (and measured).Typeface objects are immutable, and so they can be shared between threads.
Methods
fromName
(
Typeface
fromName
style
Creates new instance of Typeface class to the font that most closely matches the requested familyName and style.
Parameters:
-
fromName
StringThe name of the font family. Pass null as the familyName to return the default font for the requested style.
-
style
SymbolThe style of the typeface.
- #normal
- #bold
- #italic
- #bold+italic
Returns:
Typeface: A new reference to the typeface that most closely matches the requested familyName and style (never returns null).
Example:
// create paint object for text
var paint = new Paint();
paint.textSize = 40;
// set diferent font
paint.typeface = Typeface.fromName("FreeMono", #bold+italic);