jPod PDF library

de.intarsys.pdf.font
Class PDFontTools

java.lang.Object
  extended by de.intarsys.pdf.font.PDFontTools

public class PDFontTools
extends Object

Tool class for handling PDF fonts.

For more sophisticated help, see IFontOutlet.


Constructor Summary
PDFontTools()
           
 
Method Summary
static PDFont createBuiltinFont(String name)
          Create a well known Type1 font.
static PDFont getFont(PDDocument document, PDResources resources, COSName name)
          The font name, looked up in resources.
static PDFont getFont(PDResources resources, COSName name)
          The font name, looked up in resources.
static List getFonts(PDDocument doc)
          Determine the fonts contained as objects within the document.
static float getGlyphHeight(PDFont font)
          The font height in user space coordinates.
static float getGlyphHeightScaled(PDFont font, float size)
          The scaled font height in user space coordinates.
static int getGlyphWidthEncoded(PDFont font, byte[] codepoints, int offset, int length)
          The sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.
static float getGlyphWidthEncodedScaled(PDFont font, float size, byte[] codepoints, int offset, int length)
          The scaled sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.
static PDFont getType0Font(PDFont font)
          "Scale up" font to a multibyte font.
static List getUsedFonts(PDDocument doc, boolean considerTR)
          Tries to determine which fonts are really used within the document The following criteria are used to determine usage of a font.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFontTools

public PDFontTools()
Method Detail

createBuiltinFont

public static PDFont createBuiltinFont(String name)
Create a well known Type1 font.

Parameters:
name - The font name.
Returns:
The font we found or a new instance created on the fly.

getFont

public static PDFont getFont(PDDocument document,
                             PDResources resources,
                             COSName name)
The font name, looked up in resources.

When no matching resource is found, a builtin font is created on the fly.

Parameters:
document -
resources -
name -
Returns:
The font name, looked up in resources.

getFont

public static PDFont getFont(PDResources resources,
                             COSName name)
The font name, looked up in resources.

Parameters:
resources -
name -
Returns:
The font name, looked up in resources.

getFonts

public static List getFonts(PDDocument doc)
Determine the fonts contained as objects within the document.

Parameters:
doc - The PDDocument to parse
Returns:
Collection of all PDFont objects in the document.

getGlyphHeight

public static float getGlyphHeight(PDFont font)
The font height in user space coordinates.

Parameters:
font - The font to be used.
Returns:
The scaled font height in user space coordinates.

getGlyphHeightScaled

public static float getGlyphHeightScaled(PDFont font,
                                         float size)
The scaled font height in user space coordinates.

Parameters:
font - The font to be used.
size - The font size
Returns:
The scaled font height in user space coordinates.

getGlyphWidthEncoded

public static int getGlyphWidthEncoded(PDFont font,
                                       byte[] codepoints,
                                       int offset,
                                       int length)
The sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.

Parameters:
font -
codepoints -
offset -
length -
Returns:
The sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.

getGlyphWidthEncodedScaled

public static float getGlyphWidthEncodedScaled(PDFont font,
                                               float size,
                                               byte[] codepoints,
                                               int offset,
                                               int length)
The scaled sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.

Parameters:
font -
size -
codepoints -
offset -
length -
Returns:
The scaled sum of the length of all glyphs referenced by length bytes from codepoints starting at offset.

getType0Font

public static PDFont getType0Font(PDFont font)
"Scale up" font to a multibyte font.

Parameters:
font -
Returns:

getUsedFonts

public static List getUsedFonts(PDDocument doc,
                                boolean considerTR)
Tries to determine which fonts are really used within the document The following criteria are used to determine usage of a font.

Parameters:
doc - The PDDocument to parse
considerTR - If true, considers font references with Text rendering mode 3 as unused
Returns:
Set of all used fonts

jPod PDF library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.