public class EmbeddedFontStyle
extends java.lang.Object
FontInfo object.
Examples:
Shows how to extract an embedded font from a document, and save it to the local file system.
Document doc = new Document(getMyDir() + "Embedded font.docx");
FontInfo embeddedFont = doc.getFontInfos().get("Alte DIN 1451 Mittelschrift");
byte[] embeddedFontBytes = embeddedFont.getEmbeddedFont(EmbeddedFontFormat.OPEN_TYPE, EmbeddedFontStyle.REGULAR);
FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Alte DIN 1451 Mittelschrift.ttf"), embeddedFontBytes);
// Embedded font formats may be different in other formats such as .doc.
// We need to know the correct format before we can extract the font.
doc = new Document(getMyDir() + "Embedded font.doc");
Assert.assertNull(doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFont(EmbeddedFontFormat.OPEN_TYPE, EmbeddedFontStyle.REGULAR));
Assert.assertNotNull(doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFont(EmbeddedFontFormat.EMBEDDED_OPEN_TYPE, EmbeddedFontStyle.REGULAR));
// Also, we can convert embedded OpenType format, which comes from .doc documents, to OpenType.
embeddedFontBytes = doc.getFontInfos().get("Alte DIN 1451 Mittelschrift").getEmbeddedFontAsOpenType(EmbeddedFontStyle.REGULAR);
FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Alte DIN 1451 Mittelschrift.otf"), embeddedFontBytes);
| Modifier and Type | Field and Description |
|---|---|
static int |
BOLD
Specifies the Bold embedded font.
|
static int |
BOLD_ITALIC
Specifies the Bold-Italic embedded font.
|
static int |
ITALIC
Specifies the Italic embedded font.
|
static int |
length |
static int |
REGULAR
Specifies the Regular embedded font.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String embeddedFontStyleName) |
static int |
fromNames(java.util.Set embeddedFontStyleNames) |
static java.lang.String |
getName(int embeddedFontStyle) |
static java.util.Set |
getNames(int embeddedFontStyle) |
static int[] |
getValues() |
static java.lang.String |
toString(int embeddedFontStyle) |
static java.lang.String |
toStringSet(int attr) |
public static int REGULAR
public static int BOLD
public static int ITALIC
public static int BOLD_ITALIC
public static int length
public static java.lang.String getName(int embeddedFontStyle)
public static java.util.Set getNames(int embeddedFontStyle)
public static java.lang.String toString(int embeddedFontStyle)
public static java.lang.String toStringSet(int attr)
public static int fromName(java.lang.String embeddedFontStyleName)
public static int fromNames(java.util.Set embeddedFontStyleNames)
public static int[] getValues()