public abstract class PDFFont extends Object
The PDFFont is the abstract superclass for all Fonts in a PDF document. It defines properties which are common to all fonts, regardless of writing direction.
Modifier and Type | Method and Description |
---|---|
abstract float |
getAscender()
Get the Ascender for the font (the maximum height above the baseline the
font extends), as a proportion of the point size.
|
String[] |
getAvailableFeatures()
Return the list of available features for this font.
|
String |
getBaseName()
Return the Base Font Name for this font.
|
float |
getBottom(String s)
Get the bottom-most Y co-ordinate if this String was rendered in 1
point high text at position (0,0)
|
int |
getCharWidth(char c)
Return the width of the specified character in millipoints if
the font size was 1 point.
|
int |
getCharWidth(int codepoint)
Return the width of the specified character in millipoints if
the font size was 1 point.
|
abstract float |
getDefaultLeading()
Get the default leading for this font - the preferred distance between
two successive baselines of text.
|
abstract float |
getDescender()
Get the Descender for the font (the maximum height below the baseline the
font extends), as a proportion of the point size.
|
boolean |
getFeature(String feature)
Returns whether the specified feature is currently set for this font.
|
int |
getKerning(char c1,
char c2)
Get the horizontal character-to-character (or "pair-wise") kerning in this font
for the specified characters, in millipoints.
|
int |
getKerning(int codepoint1,
int codepoint2)
Get the horizontal character-to-character (or "pair-wise") kerning in this font
for the specified characters, in millipoints.
|
float |
getLeft(String s)
Get the left-most X co-ordinate if this String was rendered in 1
point high text at position (0,0)
|
float |
getRight(String s)
Get the right-most X co-ordinate if this String was rendered in 1
point high text at position (0,0).
|
abstract float |
getStrikeoutPosition()
Get the strikeout position, as a proportion of the font size.
|
abstract float |
getStrikeoutThickness()
Get the strikeout thickness, as a proportion of the font size.
|
abstract float |
getSubscriptPosition()
Get the recommended position of a sub-script version of this font, as
a proportion of the sub-scripted font size.
|
abstract float |
getSubscriptSize()
Get the recommended size of a super/sub script version of this font, as
a proportion of the normal font size.
|
abstract float |
getSuperscriptPosition()
Get the recommended position of a super-script version of this font, as
a proportion of the sub-scripted font size.
|
float |
getTop(String s)
Get the top-most Y co-ordinate if this String was rendered in 1
point high text at position (0,0)
|
abstract float |
getUnderlinePosition()
Get the underline position, as a proportion of the font size.
|
abstract float |
getUnderlineThickness()
Get the underline thickness, as a proportion of the font size.
|
abstract float |
getXHeight()
Get the X-Height of the font - normally the height of a lower-case 'x' character
|
abstract boolean |
isBold()
Return true if the font is bold
|
boolean |
isDefined(char c)
Return true if the specified Unicode character is defined in the font.
|
boolean |
isDefined(int codepoint)
Return true if the specified Unicode character is defined in the font.
|
boolean |
isHorizontal()
Return true if the specified font is written Left-to-Right or
Right-to-Left.
|
abstract boolean |
isItalic()
Return true if the font is italic
|
abstract boolean |
isMonospace()
Return true if every character has the same width (like Courier),
false if every character is potentially a different width (like
Times-Roman)
|
abstract boolean |
isSerif()
Return true if the font is serif
|
int |
ligaturize(char[] buf,
int off,
int len,
Locale locale)
Deprecated.
use
setFeature("latinligatures", true) instead |
String |
ligaturize(String s,
Locale locale)
Return the specified string with ligatures substituted where appropriate.
|
boolean |
requote(char[] buf,
int off,
int len,
Locale locale)
Deprecated.
use
setFeature("requote", true) instead |
String |
requote(String s,
Locale l)
Deprecated.
use
setFeature("requote", true) instead |
void |
setFeature(String feature,
boolean on)
Set or clear an optional feature on a font.
|
String |
toString() |
PDFFont |
versionBold()
Return a bold version of the current font, if available.
|
PDFFont |
versionItalic()
Return an italic version of the current font, if available.
|
PDFFont |
versionNonBold()
Return a non-bold version of the current font, if available.
|
PDFFont |
versionNonItalic()
Return a non-italic version of the current font, if available.
|
PDFFont |
versionRegular()
Return a non-bold, non-italic version of the current font, if available.
|
public final float getLeft(String s)
public final float getTop(String s)
public final float getBottom(String s)
public float getRight(String s)
PDFStyle.getTextLength(java.lang.String)
method can be used to perform the same calculation based on the
values set in the style.public abstract boolean isItalic()
public abstract boolean isBold()
public abstract boolean isSerif()
public final boolean isDefined(char c)
public boolean isDefined(int codepoint)
isDefined(char)
but takes an int
,
to cater for the new Unicode 4.0 codepoints added in Java 1.5.codepoint
- a Unicode codepoint between U+0000 and U+10FFFDpublic final int getCharWidth(char c)
public int getCharWidth(int codepoint)
getCharWidth(char)
method but takes an int
to cater
for the new Unicode 4.0 codepoints added in Java 1.5.codepoint
- a Unicode codepoint between U+0000 and U+10FFFDpublic String getBaseName()
public final int getKerning(char c1, char c2)
c1
in order to correctly position
character c2
. For many fonts and combinations of characters, this returns zero.PDFStyle.setTrackKerning(float)
public int getKerning(int codepoint1, int codepoint2)
getKerning(char,char)
but takes ints, to handle the new Unicode 4.0
characters defined in Java 1.5codepoint1
- a Unicode codepoint between U+0000 and U+10FFFDcodepoint2
- a Unicode codepoint between U+0000 and U+10FFFDpublic boolean isHorizontal()
public abstract boolean isMonospace()
public abstract float getAscender()
public abstract float getDescender()
public abstract float getDefaultLeading()
Get the default leading for this font - the preferred distance between two successive baselines of text. Values are a ratio of the font size, and are typically between 1 and 1.3
Note that the values of the different spacing-between-lines methods have
changed - in versions 1.0.4 and earlier this routine normally returned 1
and the spacing was set by the PDFStyle.setTextLineSpacing(float)
method.
Since 1.1, the values for these two methods are effectively reversed. See
the relevant method comments in the PDFStyle
class for more
information.
public abstract float getUnderlineThickness()
public abstract float getUnderlinePosition()
getDescender()
method, the returned value is almost
always negative, indicating below the baseline.public abstract float getStrikeoutThickness()
public abstract float getStrikeoutPosition()
public abstract float getSubscriptSize()
Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size. Typical value is around 0.6.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
public abstract float getSuperscriptPosition()
Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size. Value is always positive.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
public abstract float getSubscriptPosition()
Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size. Value is almost always zero or negative.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
public abstract float getXHeight()
public void setFeature(String feature, boolean on)
Set or clear an optional feature on a font. For most fonts
the only possible features are "latinligatures", which controls
the use of ligatures for "fi", "fl" and so on, "kerning"
to turn on or off the standard inter-character kerning for fonts
(both these default to on) and "requote", which will substitute
typographically-correct quotes for plain ones in the same way
as the deprecated requote(char[], int, int, java.util.Locale)
method (this defaults to off).
OpenType fonts have more
to choose from.
Since 2.14.1 you can set these features on the PDFStyle
referencing this font by calling the PDFStyle.setFontFeature(java.lang.String, boolean)
method.
This is preferable to calling this method, as it allows different
features to be used on the font within the same LayoutBox
. This
method can still be used to set a font-wide default value for each feature.
feature
- the feature nameon
- whether to set or clear the featurerequote(char[], int, int, java.util.Locale)
,
getAvailableFeatures()
,
PDFStyle.setFontFeature(java.lang.String, boolean)
public String[] getAvailableFeatures()
PDFStyle.setFontFeature(java.lang.String, boolean)
PDFStyle.setFontFeature(java.lang.String, boolean)
public boolean getFeature(String feature)
PDFStyle.getFontFeature(java.lang.String)
.feature
- the feature namePDFStyle.getFontFeature(java.lang.String)
@Deprecated public int ligaturize(char[] buf, int off, int len, Locale locale)
setFeature("latinligatures", true)
insteadbuf
- the buffer to modifyoff
- the offset into the buffer for the start of the datalen
- the length of the data in the bufferlocale
- controls which language the buffer is in. Currently not used.@Deprecated public boolean requote(char[] buf, int off, int len, Locale locale)
setFeature("requote", true)
insteadbuf
- the buffer to modifyoff
- the offset into the buffer to the start of the datalen
- the length of the data in the bufferlocale
- determines which style of quote is substituted. Recognized languages are English, Dutch, Italian, Spanish, Portuguese, Catalan, Turkish, Czech, German, Slovak, Danish, Swedish, Norwegian, Finnish, Polish and Hungarian@Deprecated public String requote(String s, Locale l)
setFeature("requote", true)
insteadrequote(char[],int,int,Locale)
but returns the end result as a (possibly) new String. Obviously not as efficient, but
more convenientpublic String ligaturize(String s, Locale locale)
Return the specified string with ligatures substituted where appropriate. As
for the ligaturize(char[],int,int,Locale)
method, but returns an
entirely new String. Obviously not as efficient as the other method, but more
convenient.
s
- the string to ligaturizelocale
- controls which language the buffer is in. Currently not used.public PDFFont versionItalic()
public PDFFont versionBold()
public PDFFont versionNonBold()
public PDFFont versionNonItalic()
public PDFFont versionRegular()
public String toString()
Copyright © 2001-2017 Big Faceless Organization