Interface Font
-
public interface FontInterface wrapper for font implementation.TrueType Font Specification:
- http://www.freetype.org/freetype2/documentation.html
- https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html
- http://www.microsoft.com/typography/SpecificationsOverview.mspx
- http://www.microsoft.com/typography/otspec/
TrueType Font Table Introduction:
- http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08
Misc.:
- Treatis on Font
Rasterization https://freddie.witherden.org/pages/font-rasterisation/ - Glyph Hell
http://walon.org/pub/ttf/ttf_glyphs.htm
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceFont.GlyphGlyph for font http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6glyf.html http://www.microsoft.com/typography/otspec/glyf.htmstatic interfaceFont.GlyphVisitorGeneral purposeFont.Glyphvisitor.static interfaceFont.GlyphVisitor2ConstrainedFont.Glyphvisitor w/oAffineTransform.static interfaceFont.MetricsMetrics for font Depending on the font's direction, horizontal or vertical, the following tables shall be used: Vertical https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6vhea.html Horizontal https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hhea.html
-
Field Summary
Fields Modifier and Type Field Description static intNAME_COPYRIGHTfont name indices for name tablestatic intNAME_DESIGNERstatic intNAME_FAMILYstatic intNAME_FULLNAMEstatic intNAME_MANUFACTURERstatic intNAME_SUBFAMILYstatic intNAME_UNIQUNAMEstatic intNAME_VERSION
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanequals(Object o)Returns true if other instance is of same type andNAME_UNIQUNAMEis equal.StringfullString()Return all font details as string.floatgetAdvanceWidth(int glyphID)Return advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table.intgetAdvanceWidthFU(int glyphID)Return advance-width of given glyphID in font-units, sourced from `hmtx` table.StringBuildergetAllNames(StringBuilder string, String separator)StringgetFullFamilyName()Shall return the family and subfamily name, separated a dash.Font.GlyphgetGlyph(int glyph_id)Return theFont.Glyphusing given ID, seegetGlyphCount().AABBoxgetGlyphBounds(CharSequence string)Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.AABBoxgetGlyphBounds(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.AABBoxgetGlyphBoundsFU(CharSequence string)Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.AABBoxgetGlyphBoundsFU(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.intgetGlyphCount()Return number ofFont.GlyphIDs available, i.e.intgetGlyphID(char symbol)Return theFont.GlyphID mapped to given `symbol`, usually UTF16 unicode.AABBoxgetGlyphShapeBounds(AffineTransform transform, CharSequence string)Returns accurate bounding box by taking each glyph's font em-sizedOutlineShapeinto account.AABBoxgetGlyphShapeBounds(AffineTransform transform, CharSequence string, AffineTransform tmp1, AffineTransform tmp2)Returns accurate bounding box by taking each glyph's font em-sizedOutlineShapeinto account.floatgetLineHeight()Return line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.intgetLineHeightFU()Return line height, baseline-to-baseline in font-units, composed from `hhea' table entries.AABBoxgetMetricBounds(CharSequence string)Returns metric-bounds in font em-size.AABBoxgetMetricBoundsFU(CharSequence string)Returns metric-bounds in font-units.Font.MetricsgetMetrics()StringgetName(int nameIndex)intgetNumGlyphs()inthashCode()Returns the hash code based onNAME_UNIQUNAME.booleanisPrintableChar(char c)voidprocessString(Font.GlyphVisitor2 visitor, CharSequence string)Visit eachFont.Glyphand perhaps itsOutlineShapeof the string with the constrainedFont.GlyphVisitor2.AABBoxprocessString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string)Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.AABBoxprocessString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string, AffineTransform temp1, AffineTransform temp2)Visit eachFont.Glyphand perhaps itsOutlineShapeof the string with theFont.GlyphVisitorwhile passing the progressedAffineTransform.StringtoString()ReturnsgetFullFamilyName()
-
-
-
Field Detail
-
NAME_COPYRIGHT
static final int NAME_COPYRIGHT
font name indices for name table- See Also:
- Constant Field Values
-
NAME_FAMILY
static final int NAME_FAMILY
- See Also:
- Constant Field Values
-
NAME_SUBFAMILY
static final int NAME_SUBFAMILY
- See Also:
- Constant Field Values
-
NAME_UNIQUNAME
static final int NAME_UNIQUNAME
- See Also:
- Constant Field Values
-
NAME_FULLNAME
static final int NAME_FULLNAME
- See Also:
- Constant Field Values
-
NAME_VERSION
static final int NAME_VERSION
- See Also:
- Constant Field Values
-
NAME_MANUFACTURER
static final int NAME_MANUFACTURER
- See Also:
- Constant Field Values
-
NAME_DESIGNER
static final int NAME_DESIGNER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName(int nameIndex)
-
getFullFamilyName
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.#getName(StringBuilder, int)w/NAME_FAMILYandNAME_SUBFAMILYExample: "
Ubuntu-Regular"
-
getAllNames
StringBuilder getAllNames(StringBuilder string, String separator)
-
hashCode
int hashCode()
Returns the hash code based onNAME_UNIQUNAME.
-
equals
boolean equals(Object o)
Returns true if other instance is of same type andNAME_UNIQUNAMEis equal.
-
getAdvanceWidthFU
int getAdvanceWidthFU(int glyphID)
Return advance-width of given glyphID in font-units, sourced from `hmtx` table.- Parameters:
glyphID-
-
getAdvanceWidth
float getAdvanceWidth(int glyphID)
Return advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table.- Parameters:
glyphID-
-
getMetrics
Font.Metrics getMetrics()
-
getGlyphID
int getGlyphID(char symbol)
Return theFont.GlyphID mapped to given `symbol`, usually UTF16 unicode. Returned ID can be used to retrieve theFont.GlyphviagetGlyph(int).
-
getGlyphCount
int getGlyphCount()
Return number ofFont.GlyphIDs available, i.e. retrievable viagetGlyph(int)[0..count).
-
getGlyph
Font.Glyph getGlyph(int glyph_id)
Return theFont.Glyphusing given ID, seegetGlyphCount().
-
getNumGlyphs
int getNumGlyphs()
-
getLineHeightFU
int getLineHeightFU()
Return line height, baseline-to-baseline in font-units, composed from `hhea' table entries.return ascent - descent + linegap;
or// lineGap positive value // descent negative value // ascent positive value return ascent - descent + linegap;
-
getLineHeight
float getLineHeight()
Return line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.return ascent - descent + linegap;
or// lineGap positive value // descent negative value // ascent positive value return ascent - descent + linegap;
-
getMetricBoundsFU
AABBox getMetricBoundsFU(CharSequence string)
Returns metric-bounds in font-units.Metric bounds is based on the `hmtx` table's advance of each glyph and `hhea' composed line height.
For accurate layout consider using
getGlyphBoundsFU(CharSequence).
-
getMetricBounds
AABBox getMetricBounds(CharSequence string)
Returns metric-bounds in font em-size.Metric bounds is based on the `hmtx` table's advance of each glyph and `hhea' composed line height.
For accurate layout consider using
getGlyphBounds(CharSequence).- See Also:
getMetricBoundsFU(CharSequence),getGlyphBounds(CharSequence),#getGlyphShapeBounds(CharSequence)
-
getGlyphBounds
AABBox getGlyphBounds(CharSequence string)
Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.
-
getGlyphBounds
AABBox getGlyphBounds(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
- Parameters:
string- string texttmp1- tempAffineTransformto be reusedtmp2- tempAffineTransformto be reused- Returns:
- the bounding box of the given string in font em-size [0..1]
- See Also:
getGlyphBoundsFU(CharSequence),#getGlyphShapeBounds(CharSequence),getMetricBounds(CharSequence)
-
getGlyphBoundsFU
AABBox getGlyphBoundsFU(CharSequence string)
Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.
-
getGlyphBoundsFU
AABBox getGlyphBoundsFU(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
- Parameters:
string- string texttmp1- tempAffineTransformto be reusedtmp2- tempAffineTransformto be reused- Returns:
- the bounding box of the given string in font-units [0..1]
- See Also:
getGlyphBounds(CharSequence)
-
getGlyphShapeBounds
AABBox getGlyphShapeBounds(AffineTransform transform, CharSequence string)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShapeinto account.Glyph shape bounds is based on each glyph's
OutlineShapeand `hhea' composed line height.This method is only exposed to validate the produced
OutlineShapeagainstgetGlyphBounds(CharSequence).- Parameters:
transform- optional given transformstring- string text- Returns:
- the bounding box of the given string in font-units [0..1]
- See Also:
#getGlyphShapeBounds(CharSequence),getGlyphBounds(CharSequence),getMetricBounds(CharSequence)
-
getGlyphShapeBounds
AABBox getGlyphShapeBounds(AffineTransform transform, CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShapeinto account.Glyph shape bounds is based on each glyph's
OutlineShapeand `hhea' composed line height.This method is only exposed to validate the produced
OutlineShapeagainstgetGlyphBounds(CharSequence).- Parameters:
transform- optional given transformstring- string texttmp1- tempAffineTransformto be reusedtmp2- tempAffineTransformto be reused- Returns:
- the bounding box of the given string in font-units [0..1]
- See Also:
#getGlyphShapeBounds(CharSequence),getGlyphBounds(CharSequence),getMetricBounds(CharSequence)
-
isPrintableChar
boolean isPrintableChar(char c)
-
processString
AABBox processString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string)
Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.
-
processString
AABBox processString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string, AffineTransform temp1, AffineTransform temp2)
Visit eachFont.Glyphand perhaps itsOutlineShapeof the string with theFont.GlyphVisitorwhile passing the progressedAffineTransform.The processed shapes are in font em-size [0..1], but can be adjusted with the given transform, progressed and passed to the visitor.
- Parameters:
visitor- handling eachFont.Glyphand perhaps itsOutlineShapein font em-size [0..1] and the givenAffineTransformtransform- optional given transform for size and positionfont- the targetFontstring- string texttemp1- temporary AffineTransform storage, mandatorytemp2- temporary AffineTransform storage, mandatory- Returns:
- the bounding box of the given string by taking each glyph's font em-sized [0..1]
OutlineShapeinto account. - See Also:
processString(GlyphVisitor, AffineTransform, CharSequence)
-
processString
void processString(Font.GlyphVisitor2 visitor, CharSequence string)
Visit eachFont.Glyphand perhaps itsOutlineShapeof the string with the constrainedFont.GlyphVisitor2.The processed shapes are in font em-size [0..1].
- Parameters:
visitor- handling eachFont.Glyphand perhaps itsOutlineShapein font em-size [0..1]string- string text
-
toString
String toString()
ReturnsgetFullFamilyName()
-
fullString
String fullString()
Return all font details as string.
-
-