Interface Font
-
public interface Font
Interface 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 interface
Font.Glyph
Glyph 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 interface
Font.GlyphVisitor
General purposeFont.Glyph
visitor.static interface
Font.GlyphVisitor2
ConstrainedFont.Glyph
visitor w/oAffineTransform
.static interface
Font.Metrics
Metrics 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 int
NAME_COPYRIGHT
font name indices for name tablestatic int
NAME_DESIGNER
static int
NAME_FAMILY
static int
NAME_FULLNAME
static int
NAME_MANUFACTURER
static int
NAME_SUBFAMILY
static int
NAME_UNIQUNAME
static int
NAME_VERSION
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
equals(Object o)
Returns true if other instance is of same type andNAME_UNIQUNAME
is equal.String
fullString()
Return all font details as string.float
getAdvanceWidth(int glyphID)
Return advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table.int
getAdvanceWidthFU(int glyphID)
Return advance-width of given glyphID in font-units, sourced from `hmtx` table.StringBuilder
getAllNames(StringBuilder string, String separator)
String
getFullFamilyName()
Shall return the family and subfamily name, separated a dash.Font.Glyph
getGlyph(int glyph_id)
Return theFont.Glyph
using given ID, seegetGlyphCount()
.AABBox
getGlyphBounds(CharSequence string)
Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.AABBox
getGlyphBounds(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.AABBox
getGlyphBoundsFU(CharSequence string)
Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.AABBox
getGlyphBoundsFU(CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.int
getGlyphCount()
Return number ofFont.Glyph
IDs available, i.e.int
getGlyphID(char symbol)
Return theFont.Glyph
ID mapped to given `symbol`, usually UTF16 unicode.AABBox
getGlyphShapeBounds(AffineTransform transform, CharSequence string)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShape
into account.AABBox
getGlyphShapeBounds(AffineTransform transform, CharSequence string, AffineTransform tmp1, AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShape
into account.float
getLineHeight()
Return line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.int
getLineHeightFU()
Return line height, baseline-to-baseline in font-units, composed from `hhea' table entries.AABBox
getMetricBounds(CharSequence string)
Returns metric-bounds in font em-size.AABBox
getMetricBoundsFU(CharSequence string)
Returns metric-bounds in font-units.Font.Metrics
getMetrics()
String
getName(int nameIndex)
int
getNumGlyphs()
int
hashCode()
Returns the hash code based onNAME_UNIQUNAME
.boolean
isPrintableChar(char c)
void
processString(Font.GlyphVisitor2 visitor, CharSequence string)
Visit eachFont.Glyph
and perhaps itsOutlineShape
of the string with the constrainedFont.GlyphVisitor2
.AABBox
processString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string)
Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.AABBox
processString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string, AffineTransform temp1, AffineTransform temp2)
Visit eachFont.Glyph
and perhaps itsOutlineShape
of the string with theFont.GlyphVisitor
while passing the progressedAffineTransform
.String
toString()
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_FAMILY
andNAME_SUBFAMILY
Example: "
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_UNIQUNAME
is 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.Glyph
ID mapped to given `symbol`, usually UTF16 unicode. Returned ID can be used to retrieve theFont.Glyph
viagetGlyph(int)
.
-
getGlyphCount
int getGlyphCount()
Return number ofFont.Glyph
IDs available, i.e. retrievable viagetGlyph(int)
[0..count).
-
getGlyph
Font.Glyph getGlyph(int glyph_id)
Return theFont.Glyph
using 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 reuseAffineTransform
instances.
-
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
- tempAffineTransform
to be reusedtmp2
- tempAffineTransform
to 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 reuseAffineTransform
instances.
-
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
- tempAffineTransform
to be reusedtmp2
- tempAffineTransform
to 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-sizedOutlineShape
into account.Glyph shape bounds is based on each glyph's
OutlineShape
and `hhea' composed line height.This method is only exposed to validate the produced
OutlineShape
againstgetGlyphBounds(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-sizedOutlineShape
into account.Glyph shape bounds is based on each glyph's
OutlineShape
and `hhea' composed line height.This method is only exposed to validate the produced
OutlineShape
againstgetGlyphBounds(CharSequence)
.- Parameters:
transform
- optional given transformstring
- string texttmp1
- tempAffineTransform
to be reusedtmp2
- tempAffineTransform
to 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 reuseAffineTransform
instances.
-
processString
AABBox processString(Font.GlyphVisitor visitor, AffineTransform transform, CharSequence string, AffineTransform temp1, AffineTransform temp2)
Visit eachFont.Glyph
and perhaps itsOutlineShape
of the string with theFont.GlyphVisitor
while 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.Glyph
and perhaps itsOutlineShape
in font em-size [0..1] and the givenAffineTransform
transform
- optional given transform for size and positionfont
- the targetFont
string
- 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]
OutlineShape
into account. - See Also:
processString(GlyphVisitor, AffineTransform, CharSequence)
-
processString
void processString(Font.GlyphVisitor2 visitor, CharSequence string)
Visit eachFont.Glyph
and perhaps itsOutlineShape
of the string with the constrainedFont.GlyphVisitor2
.The processed shapes are in font em-size [0..1].
- Parameters:
visitor
- handling eachFont.Glyph
and perhaps itsOutlineShape
in font em-size [0..1]string
- string text
-
toString
String toString()
ReturnsgetFullFamilyName()
-
fullString
String fullString()
Return all font details as string.
-
-