intarsys PDF library API

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 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 getGlyphWidth(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 getGlyphWidthScaled(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 float getGlyphWidthScaled(PDFont font, float size, int codepoint)
          The scaled width of the glyphs referenced by codepoint .
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

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.

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

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.

getGlyphHeight

public static float getGlyphHeight(PDFont font)
The 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.

getGlyphWidth

public static int getGlyphWidth(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.

getGlyphWidthScaled

public static float getGlyphWidthScaled(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.

getGlyphWidthScaled

public static float getGlyphWidthScaled(PDFont font,
                                        float size,
                                        int codepoint)
The scaled width of the glyphs referenced by codepoint .

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

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.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.