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.CodepointIDVisitor
General purpose (unicode) `codepoint` symbol andFont.Glyph
ID visitor without enforcingFont.Glyph
caching.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
General purposeFont.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 Static 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.void
forAllCodepoints(Font.CodepointIDVisitor visitor)
Visit all (unicode) `codepoint` symbol andFont.Glyph
ID tuple of this font.void
forAllGlyphs(Font.GlyphVisitor2 visitor)
Visit allFont.Glyph
s of this font.String
fullString()
Returns all font details as string.float
getAdvanceWidth(int glyphID)
Returns advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidth()
.int
getAdvanceWidthFU(int glyphID)
Returns advance-width of given glyphID in font-units, sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidthFU()
.StringBuilder
getAllNames(StringBuilder string, String separator)
static Font
getBestCoverage(Font a, Font b, CharSequence s)
ReturnsFont
with best coverage for given text while favoringa
.int
getDefinedCount(CharSequence text)
Returns the number of definedFont.Glyph
s (coverage), i.e.String
getFullFamilyName()
Shall return the family and subfamily name, separated a dash.Font.Glyph
getGlyph(char codepoint)
Returns theFont.Glyph
mapped to given (unicode) `codepoint` symbol.Font.Glyph
getGlyph(int glyph_id)
Returns theFont.Glyph
using given ID.Font.Glyph
getGlyph(String name)
Returns theFont.Glyph
mapped to given `name`.com.jogamp.math.geom.AABBox
getGlyphBounds(CharSequence string)
Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.com.jogamp.math.geom.AABBox
getGlyphBounds(CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.com.jogamp.math.geom.AABBox
getGlyphBoundsFU(CharSequence string)
Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.com.jogamp.math.geom.AABBox
getGlyphBoundsFU(CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.char
getGlyphCodepoint(String name)
Returns theFont.Glyph
(unicode) `codepoint` symbol mapped to givenFont.Glyph
`name`.int
getGlyphCount()
Returns number ofFont.Glyph
IDs available, i.e.int
getGlyphID(char codepoint)
Returns theFont.Glyph
ID mapped to given UTF16 (unicode) `codepoint` symbol.com.jogamp.math.geom.AABBox
getGlyphShapeBounds(com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShape
into account.com.jogamp.math.geom.AABBox
getGlyphShapeBounds(com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sizedOutlineShape
into account.float
getLineHeight()
Returns line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.int
getLineHeightFU()
Returns line height, baseline-to-baseline in font-units, composed from `hhea' table entries.com.jogamp.math.geom.AABBox
getMetricBounds(CharSequence string)
Returns metric-bounds in font em-size.com.jogamp.math.geom.AABBox
getMetricBoundsFU(CharSequence string)
Returns metric-bounds in font-units.Font.Metrics
getMetrics()
String
getName(int nameIndex)
static String
getUTF16String(char codepoint)
Returns UTF-16 representation of the specified (unicode) `codepoint` symbol likeCharacter.toChars(int)
orCharacter.toString()
.String
getUTF16String(String name)
Returns UTF-16 representation of the specifiedFont.Glyph
`name` usinggetGlyphCodepoint(String)
andgetUTF16String(char)
.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
.com.jogamp.math.geom.AABBox
processString(Font.GlyphVisitor visitor, com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string)
Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.com.jogamp.math.geom.AABBox
processString(Font.GlyphVisitor visitor, com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string, com.jogamp.math.geom.plane.AffineTransform temp1, com.jogamp.math.geom.plane.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
-
getUTF16String
static String getUTF16String(char codepoint)
Returns UTF-16 representation of the specified (unicode) `codepoint` symbol likeCharacter.toChars(int)
orCharacter.toString()
.The returned string can be inserted in any text.
- Parameters:
codepoint
- the (unicode) `codepoint` symbol- Returns:
- the Java
String
conforming result
-
getBestCoverage
static Font getBestCoverage(Font a, Font b, CharSequence s)
ReturnsFont
with best coverage for given text while favoringa
. SeegetDefinedCount(CharSequence)
.return a.getDefinedCount(text) >= b.getDefinedCount(text) ? a : b;
-
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)
Returns advance-width of given glyphID in font-units, sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidthFU()
.- Parameters:
glyphID
-
-
getAdvanceWidth
float getAdvanceWidth(int glyphID)
Returns advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidth()
.- Parameters:
glyphID
-
-
getMetrics
Font.Metrics getMetrics()
-
getGlyphCount
int getGlyphCount()
Returns number ofFont.Glyph
IDs available, i.e. retrievable viagetGlyph(int)
[0..count).
-
getDefinedCount
int getDefinedCount(CharSequence text)
Returns the number of definedFont.Glyph
s (coverage), i.e. notFont.Glyph.isUndefined()
, of given text.
-
getGlyphCodepoint
char getGlyphCodepoint(String name)
Returns theFont.Glyph
(unicode) `codepoint` symbol mapped to givenFont.Glyph
`name`.
-
getUTF16String
String getUTF16String(String name)
Returns UTF-16 representation of the specifiedFont.Glyph
`name` usinggetGlyphCodepoint(String)
andgetUTF16String(char)
.The returned string can be inserted in any text.
- Parameters:
codepoint
- the (unicode) `codepoint` symbol- Returns:
- the Java
String
conforming result
-
getGlyphID
int getGlyphID(char codepoint)
Returns theFont.Glyph
ID mapped to given UTF16 (unicode) `codepoint` symbol.
-
getGlyph
Font.Glyph getGlyph(String name)
Returns theFont.Glyph
mapped to given `name`.
-
getGlyph
Font.Glyph getGlyph(char codepoint)
Returns theFont.Glyph
mapped to given (unicode) `codepoint` symbol.
-
getGlyph
Font.Glyph getGlyph(int glyph_id)
Returns theFont.Glyph
using given ID.
-
forAllCodepoints
void forAllCodepoints(Font.CodepointIDVisitor visitor)
Visit all (unicode) `codepoint` symbol andFont.Glyph
ID tuple of this font.- Parameters:
visitor
- handling each (unicode) `codepoint` symbol andFont.Glyph
ID tuple.
-
forAllGlyphs
void forAllGlyphs(Font.GlyphVisitor2 visitor)
Visit allFont.Glyph
s of this font.Warning: All
Font.Glyph
s will be cached.- Parameters:
visitor
- handling eachFont.Glyph
-
getLineHeightFU
int getLineHeightFU()
Returns 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()
Returns 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
com.jogamp.math.geom.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
com.jogamp.math.geom.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
com.jogamp.math.geom.AABBox getGlyphBounds(CharSequence string)
Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.
-
getGlyphBounds
com.jogamp.math.geom.AABBox getGlyphBounds(CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.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
com.jogamp.math.geom.AABBox getGlyphBoundsFU(CharSequence string)
Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.
-
getGlyphBoundsFU
com.jogamp.math.geom.AABBox getGlyphBoundsFU(CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.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
com.jogamp.math.geom.AABBox getGlyphShapeBounds(com.jogamp.math.geom.plane.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
com.jogamp.math.geom.AABBox getGlyphShapeBounds(com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string, com.jogamp.math.geom.plane.AffineTransform tmp1, com.jogamp.math.geom.plane.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
com.jogamp.math.geom.AABBox processString(Font.GlyphVisitor visitor, com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string)
Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)
to reuseAffineTransform
instances.
-
processString
com.jogamp.math.geom.AABBox processString(Font.GlyphVisitor visitor, com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string, com.jogamp.math.geom.plane.AffineTransform temp1, com.jogamp.math.geom.plane.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()
Returns all font details as string.
-
-