public class FontInfo
extends java.lang.Object
implements java.lang.Cloneable
To learn more, visit the Working with Fonts documentation article.
Remarks:
You do not create instances of this class directly. Use the DocumentBase.getFontInfos() property to access the collection of fonts defined in a document.
Examples:
Shows how to print the details of what fonts are present in a document.
Document doc = new Document(getMyDir() + "Embedded font.docx");
FontInfoCollection allFonts = doc.getFontInfos();
// Print all the used and unused fonts in the document.
for (int i = 0; i < allFonts.getCount(); i++) {
System.out.println("Font index #{i}");
System.out.println("\tName: {allFonts[i].Name}");
}
FontInfoCollection,
DocumentBase.getFontInfos()| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAltName()
Gets the alternate name for the font.
|
int |
getCharset()
Gets the character set for the font.
|
byte[] |
getEmbeddedFont(int format,
int style) |
byte[] |
getEmbeddedFontAsOpenType(int style) |
FontEmbeddingLicensingRights |
getEmbeddingLicensingRights()
Gets the embedded font licensing rights.
|
int |
getFamily()
Gets the font family this font belongs to.
|
java.lang.String |
getName()
Gets the name of the font.
|
byte[] |
getPanose()
Gets the PANOSE typeface classification number.
|
int |
getPitch()
The pitch indicates if the font is fixed pitch, proportionally spaced, or relies on a default setting.
|
boolean |
isTrueType()
Indicates that this font is a TrueType or OpenType font as opposed to a raster or vector font.
|
void |
isTrueType(boolean value)
Indicates that this font is a TrueType or OpenType font as opposed to a raster or vector font.
|
protected java.lang.Object |
memberwiseClone() |
void |
setAltName(java.lang.String value)
Sets the alternate name for the font.
|
void |
setCharset(int value)
Sets the character set for the font.
|
void |
setFamily(int value)
Sets the font family this font belongs to.
|
void |
setPanose(byte[] value)
Sets the PANOSE typeface classification number.
|
void |
setPitch(int value)
The pitch indicates if the font is fixed pitch, proportionally spaced, or relies on a default setting.
|
public byte[] getEmbeddedFont(int format,
int style)
public byte[] getEmbeddedFontAsOpenType(int style)
public int getPitch()
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
int value. The returned value is one of FontPitch constants.public void setPitch(int value)
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
value - The corresponding int value. The value must be one of FontPitch constants.public boolean isTrueType()
true.
Examples:
Shows how to print the details of what fonts are present in a document.
Document doc = new Document(getMyDir() + "Embedded font.docx");
FontInfoCollection allFonts = doc.getFontInfos();
// Print all the used and unused fonts in the document.
for (int i = 0; i < allFonts.getCount(); i++) {
System.out.println("Font index #{i}");
System.out.println("\tName: {allFonts[i].Name}");
}
boolean value.public void isTrueType(boolean value)
true.
Examples:
Shows how to print the details of what fonts are present in a document.
Document doc = new Document(getMyDir() + "Embedded font.docx");
FontInfoCollection allFonts = doc.getFontInfos();
// Print all the used and unused fonts in the document.
for (int i = 0; i < allFonts.getCount(); i++) {
System.out.println("Font index #{i}");
System.out.println("\tName: {allFonts[i].Name}");
}
value - The corresponding boolean value.public int getFamily()
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
FontFamily constants.public void setFamily(int value)
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
value - The font family this font belongs to. The value must be one of FontFamily constants.public int getCharset()
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
public void setCharset(int value)
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
value - The character set for the font.public byte[] getPanose()
Remarks:
PANOSE is a compact 10-byte description of a fonts critical visual characteristics, such as contrast, weight, and serif style. The digits represent Family Kind, Serif Style, Weight, Proportion, Contrast, Stroke Variation, Arm Style, Letterform, Midline, and X-Height.
Can be null.
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
public void setPanose(byte[] value)
Remarks:
PANOSE is a compact 10-byte description of a fonts critical visual characteristics, such as contrast, weight, and serif style. The digits represent Family Kind, Serif Style, Weight, Proportion, Contrast, Stroke Variation, Arm Style, Letterform, Midline, and X-Height.
Can be null.
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
value - The PANOSE typeface classification number.public java.lang.String getName()
Remarks:
Cannot be null. Can be an empty string.
Examples:
Shows how to print the details of what fonts are present in a document.
Document doc = new Document(getMyDir() + "Embedded font.docx");
FontInfoCollection allFonts = doc.getFontInfos();
// Print all the used and unused fonts in the document.
for (int i = 0; i < allFonts.getCount(); i++) {
System.out.println("Font index #{i}");
System.out.println("\tName: {allFonts[i].Name}");
}
public java.lang.String getAltName()
Remarks:
Cannot be null. Can be an empty string.
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
public void setAltName(java.lang.String value)
Remarks:
Cannot be null. Can be an empty string.
Examples:
Shows how to access and print details of each font in a document.
Document doc = new Document(getMyDir() + "Document.docx");
Iterator<FontInfo> fontCollectionEnumerator = doc.getFontInfos().iterator();
while (fontCollectionEnumerator.hasNext()) {
FontInfo fontInfo = fontCollectionEnumerator.next();
if (fontInfo != null) {
System.out.println("Font name: " + fontInfo.getName());
// Alt names are usually blank.
System.out.println("Alt name: " + fontInfo.getAltName());
System.out.println("\t- Family: " + fontInfo.getFamily());
System.out.println("\t- " + (fontInfo.isTrueType() ? "Is TrueType" : "Is not TrueType"));
System.out.println("\t- Pitch: " + fontInfo.getPitch());
System.out.println("\t- Charset: " + fontInfo.getCharset());
System.out.println("\t- Panose:");
System.out.println("\t\tFamily Kind: " + (fontInfo.getPanose()[0] & 0xFF));
System.out.println("\t\tSerif Style: " + (fontInfo.getPanose()[1] & 0xFF));
System.out.println("\t\tWeight: " + (fontInfo.getPanose()[2] & 0xFF));
System.out.println("\t\tProportion: " + (fontInfo.getPanose()[3] & 0xFF));
System.out.println("\t\tContrast: " + (fontInfo.getPanose()[4] & 0xFF));
System.out.println("\t\tStroke Variation: " + (fontInfo.getPanose()[5] & 0xFF));
System.out.println("\t\tArm Style: " + (fontInfo.getPanose()[6] & 0xFF));
System.out.println("\t\tLetterform: " + (fontInfo.getPanose()[7] & 0xFF));
System.out.println("\t\tMidline: " + (fontInfo.getPanose()[8] & 0xFF));
System.out.println("\t\tX-Height: " + (fontInfo.getPanose()[9] & 0xFF));
}
}
value - The alternate name for the font.public FontEmbeddingLicensingRights getEmbeddingLicensingRights()
Remarks:
The value may be null if font is not embedded.
Examples:
Shows how to get license rights information for embedded fonts (FontInfo).
Document doc = new Document(getMyDir() + "Embedded font rights.docx");
// Get the list of document fonts.
FontInfoCollection fontInfos = doc.getFontInfos();
for (FontInfo fontInfo : fontInfos)
{
if (fontInfo.getEmbeddingLicensingRights() != null)
{
System.out.println(fontInfo.getEmbeddingLicensingRights().getEmbeddingUsagePermissions());
System.out.println(fontInfo.getEmbeddingLicensingRights().getBitmapEmbeddingOnly());
System.out.println(fontInfo.getEmbeddingLicensingRights().getNoSubsetting());
}
}
protected java.lang.Object memberwiseClone()