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, warnMissingGlyphclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisEmbeddable, isSubsetEmbeddedgetBoundingBox, getMaxAscent, getWidth, getWidths, hasFeature, isMultiByteprotected 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 FontMetricspublic String getFontName()
getFontName in interface FontMetricspublic String getEmbedFontName()
getEmbedFontName in interface FontMetricspublic String getFullName()
getFullName in interface FontMetricspublic Set<String> getFamilyNames()
getFamilyNames in interface FontMetricspublic 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 FontDescriptorpublic int getDescender()
getDescender in interface FontDescriptorpublic int getCapHeight()
getCapHeight in interface FontDescriptorpublic int getAscender(int size)
getAscender in interface FontMetricssize - font sizepublic int getDescender(int size)
getDescender in interface FontMetricssize - font sizepublic int getCapHeight(int size)
getCapHeight in interface FontMetricssize - font sizepublic int getXHeight(int size)
getXHeight in interface FontMetricssize - font sizepublic int[] getFontBBox()
getFontBBox in interface FontDescriptorpublic int getFlags()
getFlags in interface FontDescriptorpublic boolean isSymbolicFont()
isSymbolicFont in interface FontDescriptorpublic int getWeight()
public int getStemV()
getStemV in interface FontDescriptorpublic int getItalicAngle()
getItalicAngle in interface FontDescriptorpublic int getMissingWidth()
public FontType getFontType()
getFontType in interface FontMetricspublic int getFirstChar()
public int getLastChar()
public boolean isKerningEnabled()
public final boolean hasKerningInfo()
hasKerningInfo in interface FontMetricspublic final Map<Integer,Map<Integer,Integer>> getKerningInfo()
getKerningInfo in interface FontMetricspublic boolean isAdvancedEnabled()
public void setFontURI(URI uri)
setFontURI in interface MutableFonturi - URI from which font is or will be loadedpublic void setFontName(String name)
setFontName in interface MutableFontname - font namepublic void setFullName(String name)
setFullName in interface MutableFontname - font' full namepublic void setFamilyNames(Set<String> names)
setFamilyNames in interface MutableFontnames - 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 MutableFontpath - URI to the fontpublic void setEmbedResourceName(String name)
setEmbedResourceName in interface MutableFontname - resource namepublic void setEmbeddingMode(EmbeddingMode embeddingMode)
setEmbeddingMode in interface MutableFontembeddingMode - the embedding modepublic void setCapHeight(int capHeight)
setCapHeight in interface MutableFontcapHeight - capital heightpublic void setXHeight(int xHeight)
xHeight - the XHeight valuepublic void setAscender(int ascender)
setAscender in interface MutableFontascender - ascent heightpublic void setDescender(int descender)
setDescender in interface MutableFontdescender - descent valuepublic void setFontBBox(int[] bbox)
setFontBBox in interface MutableFontbbox - bounding boxpublic void setFlags(int flags)
setFlags in interface MutableFontflags - flagspublic void setWeight(int weight)
weight - the font weightpublic void setStemV(int stemV)
setStemV in interface MutableFontstemV - StemVpublic void setItalicAngle(int italicAngle)
setItalicAngle in interface MutableFontitalicAngle - italic anglepublic void setMissingWidth(int width)
setMissingWidth in interface MutableFontwidth - default widthpublic void setFontType(FontType fontType)
setFontType in interface MutableFontfontType - font typepublic void setFirstChar(int index)
setFirstChar in interface MutableFontindex - index of first characterpublic void setLastChar(int index)
setLastChar in interface MutableFontindex - index of the last characterpublic void setKerningEnabled(boolean enabled)
setKerningEnabled in interface MutableFontenabled - True if kerning should be enabled if availablepublic void setAdvancedEnabled(boolean enabled)
setAdvancedEnabled in interface MutableFontenabled - 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 MutableFontkey - 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)
FontMetricsgetUnderlinePosition in interface FontMetricssize - font sizepublic void setUnderlinePosition(int underlinePosition)
public int getUnderlineThickness(int size)
FontMetricsgetUnderlineThickness in interface FontMetricssize - font sizepublic void setUnderlineThickness(int underlineThickness)
public int getStrikeoutPosition(int size)
FontMetricsgetStrikeoutPosition in interface FontMetricssize - font sizepublic void setStrikeoutPosition(int strikeoutPosition)
public int getStrikeoutThickness(int size)
FontMetricsgetStrikeoutThickness in interface FontMetricssize - 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.