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.CodepointIDVisitorGeneral purpose (unicode) `codepoint` symbol andFont.GlyphID visitor without enforcingFont.Glyphcaching.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.GlyphVisitor2General purposeFont.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 Static 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.voidforAllCodepoints(Font.CodepointIDVisitor visitor)Visit all (unicode) `codepoint` symbol andFont.GlyphID tuple of this font.voidforAllGlyphs(Font.GlyphVisitor2 visitor)Visit allFont.Glyphs of this font.StringfullString()Returns all font details as string.floatgetAdvanceWidth(int glyphID)Returns advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidth().intgetAdvanceWidthFU(int glyphID)Returns advance-width of given glyphID in font-units, sourced from `hmtx` table - same asFont.Glyph.getAdvanceWidthFU().StringBuildergetAllNames(StringBuilder string, String separator)static FontgetBestCoverage(Font a, Font b, CharSequence s)ReturnsFontwith best coverage for given text while favoringa.intgetDefinedCount(CharSequence text)Returns the number of definedFont.Glyphs (coverage), i.e.StringgetFullFamilyName()Shall return the family and subfamily name, separated a dash.Font.GlyphgetGlyph(char codepoint)Returns theFont.Glyphmapped to given (unicode) `codepoint` symbol.Font.GlyphgetGlyph(int glyph_id)Returns theFont.Glyphusing given ID.Font.GlyphgetGlyph(String name)Returns theFont.Glyphmapped to given `name`.com.jogamp.math.geom.AABBoxgetGlyphBounds(CharSequence string)Try usinggetGlyphBounds(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.com.jogamp.math.geom.AABBoxgetGlyphBounds(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.AABBoxgetGlyphBoundsFU(CharSequence string)Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.com.jogamp.math.geom.AABBoxgetGlyphBoundsFU(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.chargetGlyphCodepoint(String name)Returns theFont.Glyph(unicode) `codepoint` symbol mapped to givenFont.Glyph`name`.intgetGlyphCount()Returns number ofFont.GlyphIDs available, i.e.intgetGlyphID(char codepoint)Returns theFont.GlyphID mapped to given UTF16 (unicode) `codepoint` symbol.com.jogamp.math.geom.AABBoxgetGlyphShapeBounds(com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string)Returns accurate bounding box by taking each glyph's font em-sizedOutlineShapeinto account.com.jogamp.math.geom.AABBoxgetGlyphShapeBounds(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-sizedOutlineShapeinto account.floatgetLineHeight()Returns line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.intgetLineHeightFU()Returns line height, baseline-to-baseline in font-units, composed from `hhea' table entries.com.jogamp.math.geom.AABBoxgetMetricBounds(CharSequence string)Returns metric-bounds in font em-size.com.jogamp.math.geom.AABBoxgetMetricBoundsFU(CharSequence string)Returns metric-bounds in font-units.Font.MetricsgetMetrics()StringgetName(int nameIndex)static StringgetUTF16String(char codepoint)Returns UTF-16 representation of the specified (unicode) `codepoint` symbol likeCharacter.toChars(int)orCharacter.toString().StringgetUTF16String(String name)Returns UTF-16 representation of the specifiedFont.Glyph`name` usinggetGlyphCodepoint(String)andgetUTF16String(char).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.com.jogamp.math.geom.AABBoxprocessString(Font.GlyphVisitor visitor, com.jogamp.math.geom.plane.AffineTransform transform, CharSequence string)Try usingprocessString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.com.jogamp.math.geom.AABBoxprocessString(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.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
-
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
Stringconforming result
-
getBestCoverage
static Font getBestCoverage(Font a, Font b, CharSequence s)
ReturnsFontwith 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_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)
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.GlyphIDs available, i.e. retrievable viagetGlyph(int)[0..count).
-
getDefinedCount
int getDefinedCount(CharSequence text)
Returns the number of definedFont.Glyphs (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
Stringconforming result
-
getGlyphID
int getGlyphID(char codepoint)
Returns theFont.GlyphID mapped to given UTF16 (unicode) `codepoint` symbol.
-
getGlyph
Font.Glyph getGlyph(String name)
Returns theFont.Glyphmapped to given `name`.
-
getGlyph
Font.Glyph getGlyph(char codepoint)
Returns theFont.Glyphmapped to given (unicode) `codepoint` symbol.
-
getGlyph
Font.Glyph getGlyph(int glyph_id)
Returns theFont.Glyphusing given ID.
-
forAllCodepoints
void forAllCodepoints(Font.CodepointIDVisitor visitor)
Visit all (unicode) `codepoint` symbol andFont.GlyphID tuple of this font.- Parameters:
visitor- handling each (unicode) `codepoint` symbol andFont.GlyphID tuple.
-
forAllGlyphs
void forAllGlyphs(Font.GlyphVisitor2 visitor)
Visit allFont.Glyphs of this font.Warning: All
Font.Glyphs 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 reuseAffineTransforminstances.
-
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- 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
com.jogamp.math.geom.AABBox getGlyphBoundsFU(CharSequence string)
Try usinggetGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)to reuseAffineTransforminstances.
-
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- tempAffineTransformto be reusedtmp2- tempAffineTransformto 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-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
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-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
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 reuseAffineTransforminstances.
-
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.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()
Returns all font details as string.
-
-