public abstract class CustomFont extends Typeface implements FontDescriptor, MutableFont
Modifier and Type | Field and Description |
---|---|
protected List<SimpleSingleByteEncoding> |
additionalEncodings |
protected List<CMapSegment> |
cmap
the character map, mapping Unicode ranges to glyph indices.
|
protected Map<Integer,SVGGlyphData> |
svgs |
protected Map<Character,SingleByteFont.UnencodedCharacter> |
unencodedCharacters |
eventListener, NOT_FOUND
Constructor and Description |
---|
CustomFont(InternalResourceResolver resourceResolver) |
Modifier and Type | Method and Description |
---|---|
void |
addUnencodedCharacter(NamedCharacter ch,
int width,
Rectangle bbox)
Adds an unencoded character (one that is not supported by the primary encoding).
|
SimpleSingleByteEncoding |
getAdditionalEncoding(int index)
Returns an additional encoding.
|
int |
getAdditionalEncodingCount()
Returns the number of additional encodings this single-byte font maintains.
|
int |
getAscender()
Returns the ascender value of the font.
|
int |
getAscender(int size)
Returns the ascent of the font described by this
FontMetrics object.
|
int |
getCapHeight()
Returns the capital height of the font.
|
int |
getCapHeight(int size)
Returns the size of a capital letter measured from the font's baseline.
|
CMapSegment[] |
getCMap()
Returns the character map for this font.
|
int |
getDescender()
Returns the descender value of the font.
|
int |
getDescender(int size)
Returns the descent of the font described by this
FontMetrics object.
|
EmbeddingMode |
getEmbeddingMode()
Returns the embedding mode for this font.
|
URI |
getEmbedFileURI()
Returns an URI representing an embeddable font file.
|
String |
getEmbedFontName()
Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
|
String |
getEmbedResourceName()
Returns the lookup name to an embeddable font file available as a
resource.
|
Set<String> |
getFamilyNames()
Returns the font family names.
|
int |
getFirstChar()
Returns the index of the first character defined in this font.
|
int |
getFlags()
Returns the flags for the font.
|
int[] |
getFontBBox()
Returns the font's bounding box.
|
String |
getFontName()
Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
|
String |
getFontSubName()
Returns font's subfamily name.
|
FontType |
getFontType()
Returns the type of the font.
|
URI |
getFontURI()
Returns the URI of the font file from which these metrics were loaded.
|
String |
getFullName()
Returns the font's full name (Example: "Helvetica Bold Oblique").
|
InputStream |
getInputStream()
Returns an
InputStream representing an embeddable font file. |
int |
getItalicAngle()
Returns the italic angle for the font.
|
Map<Integer,Map<Integer,Integer>> |
getKerningInfo()
Returns the kerning map for the font.
|
int |
getLastChar()
Returns the index of the last character defined in this font.
|
int |
getMissingWidth()
Returns the width to be used when no width is available.
|
boolean |
getSimulateStyle() |
int |
getStemV()
Returns the vertical stem width for the font.
|
int |
getStrikeoutPosition(int size)
Returns the distance from the baseline to the center of the strikeout line
(negative value indicates below baseline).
|
int |
getStrikeoutThickness(int size)
Returns the thickness of the strikeout line.
|
String |
getStrippedFontName()
Returns the font family name stripped of whitespace.
|
int |
getUnderlinePosition(int size)
Returns the distance from the baseline to the center of the underline (negative
value indicates below baseline).
|
int |
getUnderlineThickness(int size)
Returns the thickness of the underline.
|
abstract char |
getUnicodeFromGID(int glyphIndex)
Returns the character from it's original glyph index in the font
|
abstract Map<Integer,Integer> |
getUsedGlyphs()
Returns a Map of used Glyphs.
|
int |
getWeight()
Returns the font weight (100, 200...800, 900).
|
int |
getXHeight(int size)
Determines the typical font height of this
FontMetrics object
|
boolean |
hasAdditionalEncodings()
Indicates whether the encoding has additional encodings besides the primary encoding.
|
boolean |
hasKerningInfo()
Indicates if the font has kerning information.
|
boolean |
hasSVG() |
boolean |
isAdvancedEnabled()
Used to determine if advanced typographic features are enabled.
|
boolean |
isKerningEnabled()
Used to determine if kerning is enabled.
|
boolean |
isSymbolicFont()
Indicates whether the font is a symbolic font.
|
protected char |
mapUnencodedChar(char ch)
Adds a character to additional encodings
|
void |
putKerningEntry(Integer key,
Map<Integer,Integer> value)
Adds an entry to the kerning table.
|
void |
replaceKerningMap(Map<Integer,Map<Integer,Integer>> kerningMap)
Replaces the existing kerning map with a new one.
|
void |
setAdvancedEnabled(boolean enabled)
Enables/disabled advanced typographic features.
|
void |
setAscender(int ascender)
Sets the ascent value.
|
void |
setCapHeight(int capHeight)
Sets the capital height value.
|
void |
setCMap(CMapSegment[] cmap)
Sets the character map for this font.
|
void |
setDescender(int descender)
Sets the descent value.
|
void |
setEmbeddingMode(EmbeddingMode embeddingMode)
Sets the embedding mode.
|
void |
setEmbedResourceName(String name)
Sets the resource name of the embeddable font file.
|
void |
setEmbedURI(URI path)
Sets the URI to the embeddable font.
|
void |
setFamilyNames(Set<String> names)
Sets the font's family names (Example: "Helvetica").
|
void |
setFirstChar(int index)
Sets the index of the first character in the character table.
|
void |
setFlags(int flags)
Sets the font's flags
|
void |
setFontBBox(int[] bbox)
Sets the font's bounding box
|
void |
setFontName(String name)
Sets the "PostScript" font name (Example: "Helvetica-BoldOblique").
|
void |
setFontSubFamilyName(String subFamilyName)
Sets the font's subfamily name.
|
void |
setFontType(FontType fontType)
Sets the font type.
|
void |
setFontURI(URI uri)
Sets the URI from which this font is or will be loaded.
|
void |
setFullName(String name)
Sets the font's full name (usually the one that the operating system displays).
|
void |
setItalicAngle(int italicAngle)
Sets the font's italic angle.
|
void |
setKerningEnabled(boolean enabled)
Enables/disabled kerning.
|
void |
setLastChar(int index)
Sets the index of the last character in the character table.
|
void |
setMissingWidth(int width)
Sets the font's default width
|
void |
setSimulateStyle(boolean enabled) |
void |
setStemV(int stemV)
Sets the font's StemV value.
|
void |
setStrikeoutPosition(int strikeoutPosition) |
void |
setStrikeoutThickness(int strikeoutThickness) |
void |
setSVG(Map<Integer,SVGGlyphData> svgs) |
void |
setUnderlinePosition(int underlinePosition) |
void |
setUnderlineThickness(int underlineThickness) |
void |
setWeight(int weight)
Sets the font weight.
|
void |
setXHeight(int xHeight)
Returns the XHeight value of the font.
|
getEncodingName, getMaxAscent, hadMappingOperations, hasChar, hasFeature, isCID, isMultiByte, mapChar, notifyMapOperation, setEventListener, toString, warnMissingGlyph
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isEmbeddable, isSubsetEmbedded
getBoundingBox, getMaxAscent, getWidth, getWidths, hasFeature, isMultiByte
protected List<CMapSegment> cmap
protected Map<Integer,SVGGlyphData> svgs
protected List<SimpleSingleByteEncoding> additionalEncodings
protected Map<Character,SingleByteFont.UnencodedCharacter> unencodedCharacters
public CustomFont(InternalResourceResolver resourceResolver)
resourceResolver
- the URI resource resolver for controlling file accesspublic URI getFontURI()
getFontURI
in interface FontMetrics
public String getFontName()
getFontName
in interface FontMetrics
public String getEmbedFontName()
getEmbedFontName
in interface FontMetrics
public String getFullName()
getFullName
in interface FontMetrics
public Set<String> getFamilyNames()
getFamilyNames
in interface FontMetrics
public String getStrippedFontName()
FontUtil.stripWhiteSpace(String)
public String getFontSubName()
public URI getEmbedFileURI()
public EmbeddingMode getEmbeddingMode()
public InputStream getInputStream() throws IOException
InputStream
representing an embeddable font file.InputStream
for an embeddable font fileIOException
- if embedFileName is not null but Source is not foundpublic String getEmbedResourceName()
public int getAscender()
getAscender
in interface FontDescriptor
public int getDescender()
getDescender
in interface FontDescriptor
public int getCapHeight()
getCapHeight
in interface FontDescriptor
public int getAscender(int size)
getAscender
in interface FontMetrics
size
- font sizepublic int getDescender(int size)
getDescender
in interface FontMetrics
size
- font sizepublic int getCapHeight(int size)
getCapHeight
in interface FontMetrics
size
- font sizepublic int getXHeight(int size)
getXHeight
in interface FontMetrics
size
- font sizepublic int[] getFontBBox()
getFontBBox
in interface FontDescriptor
public int getFlags()
getFlags
in interface FontDescriptor
public boolean isSymbolicFont()
isSymbolicFont
in interface FontDescriptor
public int getWeight()
public int getStemV()
getStemV
in interface FontDescriptor
public int getItalicAngle()
getItalicAngle
in interface FontDescriptor
public int getMissingWidth()
public FontType getFontType()
getFontType
in interface FontMetrics
public int getFirstChar()
public int getLastChar()
public boolean isKerningEnabled()
public final boolean hasKerningInfo()
hasKerningInfo
in interface FontMetrics
public final Map<Integer,Map<Integer,Integer>> getKerningInfo()
getKerningInfo
in interface FontMetrics
public boolean isAdvancedEnabled()
public void setFontURI(URI uri)
setFontURI
in interface MutableFont
uri
- URI from which font is or will be loadedpublic void setFontName(String name)
setFontName
in interface MutableFont
name
- font namepublic void setFullName(String name)
setFullName
in interface MutableFont
name
- font' full namepublic void setFamilyNames(Set<String> names)
setFamilyNames
in interface MutableFont
names
- the font's family names (a Set of Strings)public void setFontSubFamilyName(String subFamilyName)
subFamilyName
- the subfamily name of the fontpublic void setEmbedURI(URI path)
setEmbedURI
in interface MutableFont
path
- URI to the fontpublic void setEmbedResourceName(String name)
setEmbedResourceName
in interface MutableFont
name
- resource namepublic void setEmbeddingMode(EmbeddingMode embeddingMode)
setEmbeddingMode
in interface MutableFont
embeddingMode
- the embedding modepublic void setCapHeight(int capHeight)
setCapHeight
in interface MutableFont
capHeight
- capital heightpublic void setXHeight(int xHeight)
xHeight
- the XHeight valuepublic void setAscender(int ascender)
setAscender
in interface MutableFont
ascender
- ascent heightpublic void setDescender(int descender)
setDescender
in interface MutableFont
descender
- descent valuepublic void setFontBBox(int[] bbox)
setFontBBox
in interface MutableFont
bbox
- bounding boxpublic void setFlags(int flags)
setFlags
in interface MutableFont
flags
- flagspublic void setWeight(int weight)
weight
- the font weightpublic void setStemV(int stemV)
setStemV
in interface MutableFont
stemV
- StemVpublic void setItalicAngle(int italicAngle)
setItalicAngle
in interface MutableFont
italicAngle
- italic anglepublic void setMissingWidth(int width)
setMissingWidth
in interface MutableFont
width
- default widthpublic void setFontType(FontType fontType)
setFontType
in interface MutableFont
fontType
- font typepublic void setFirstChar(int index)
setFirstChar
in interface MutableFont
index
- index of first characterpublic void setLastChar(int index)
setLastChar
in interface MutableFont
index
- index of the last characterpublic void setKerningEnabled(boolean enabled)
setKerningEnabled
in interface MutableFont
enabled
- True if kerning should be enabled if availablepublic void setAdvancedEnabled(boolean enabled)
setAdvancedEnabled
in interface MutableFont
enabled
- true if advanced typographic features should be enabled if availablepublic void setSimulateStyle(boolean enabled)
public boolean getSimulateStyle()
public void putKerningEntry(Integer key, Map<Integer,Integer> value)
putKerningEntry
in interface MutableFont
key
- Kerning keyvalue
- Kerning valuepublic void replaceKerningMap(Map<Integer,Map<Integer,Integer>> kerningMap)
kerningMap
- the kerning map (the integers are
character codes)public void setCMap(CMapSegment[] cmap)
cmap
- the character mappublic CMapSegment[] getCMap()
public int getUnderlinePosition(int size)
FontMetrics
getUnderlinePosition
in interface FontMetrics
size
- font sizepublic void setUnderlinePosition(int underlinePosition)
public int getUnderlineThickness(int size)
FontMetrics
getUnderlineThickness
in interface FontMetrics
size
- font sizepublic void setUnderlineThickness(int underlineThickness)
public int getStrikeoutPosition(int size)
FontMetrics
getStrikeoutPosition
in interface FontMetrics
size
- font sizepublic void setStrikeoutPosition(int strikeoutPosition)
public int getStrikeoutThickness(int size)
FontMetrics
getStrikeoutThickness
in interface FontMetrics
size
- font sizepublic void setStrikeoutThickness(int strikeoutThickness)
public abstract Map<Integer,Integer> getUsedGlyphs()
public abstract char getUnicodeFromGID(int glyphIndex)
glyphIndex
- The original index of the characterpublic boolean hasAdditionalEncodings()
public int getAdditionalEncodingCount()
public SimpleSingleByteEncoding getAdditionalEncoding(int index) throws IndexOutOfBoundsException
index
- the index of the additional encodingIndexOutOfBoundsException
- if the index is out of boundspublic void addUnencodedCharacter(NamedCharacter ch, int width, Rectangle bbox)
ch
- the named characterwidth
- the width of the characterprotected char mapUnencodedChar(char ch)
ch
- character to mappublic boolean hasSVG()
public void setSVG(Map<Integer,SVGGlyphData> svgs)
Copyright © 2025 Apache Software Foundation. All rights reserved.