PDFlib Fonts and Rendering

PDFlib Fonts and Rendering — Functions for shape engines to manipulate FreeType fonts for the PDFlib renderer

Synopsis




struct      PangoPDFLIBLayout;
enum        PangoPDFLIBBaseline;
enum        PangoPDFLIBLineStackingStrategy;
#define     PANGO_RENDER_TYPE_PDFLIB
struct      PangoPDFLIBFontMap;
void        (*PangoPDFLIBSubstituteFunc)    (FcPattern *pattern,
                                             gpointer data);
PangoContext* pango_pdflib_get_context      (double dpi_x,
                                             double dpi_y);
PangoFontMap* pango_pdflib_font_map_for_display
                                            (void);
void        pango_pdflib_shutdown_display   (void);
void        pango_pdflib_render             (PDF *pdf_doc,
                                             const gchar *layout_text,
                                             PangoLayoutRun *run,
                                             PangoFont *font,
                                             PangoGlyphString *glyphs,
                                             gint x,
                                             gint y);
void        pango_pdflib_render_layout_line (PDF *pdf_doc,
                                             const gchar *layout_text,
                                             PangoLayoutLine *line,
                                             gint x,
                                             gint y);
void        pango_pdflib_render_layout_lines
                                            (PDF *pdf_doc,
                                             PangoLayout *layout,
                                             gint line_first,
                                             gint line_last,
                                             gint x,
                                             gint y);
void        pango_pdflib_render_layout      (PDF *pdf_doc,
                                             PangoLayout *layout,
                                             gint x,
                                             gint y);
PangoFontMap* pango_pdflib_font_map_new     (void);
void        pango_pdflib_font_map_set_resolution
                                            (PangoPDFLIBFontMap *fontmap,
                                             double dpi_x,
                                             double dpi_y);
void        pango_pdflib_font_map_set_default_substitute
                                            (PangoPDFLIBFontMap *fontmap,
                                             PangoPDFLIBSubstituteFunc func,
                                             gpointer data,
                                             GDestroyNotify notify);
void        pango_pdflib_font_map_substitute_changed
                                            (PangoPDFLIBFontMap *fontmap);
PangoContext* pango_pdflib_font_map_create_context
                                            (PangoPDFLIBFontMap *fontmap);
enum        PangoPDFLIBDebugFlags;
PangoContext* pango_pdflib_font_map_create_context_with_debug_flags
                                            (PangoPDFLIBFontMap *fontmap,
                                             PangoPDFLIBDebugFlags debug_flags);
void        pango_pdflib_layout_set_line_height
                                            (PangoLayout *layout,
                                             gint line_height);
void        pango_pdflib_layout_set_line_stacking_strategy
                                            (PangoLayout *layout,
                                             PangoPDFLIBLineStackingStrategy line_stacking_strategy);
gint        pango_pdflib_layout_get_item_attrs
                                            (PangoItem *item,
                                             PangoAttrType first_attribute_type,
                                             ...);
PangoGlyph  pango_pdflib_get_unknown_glyph  (PangoFont *font);
int         pango_pdflib_font_get_kerning   (PangoFont *font,
                                             PangoGlyph left,
                                             PangoGlyph right);
FT_Face     pango_pdflib_font_get_face      (PangoFont *font);
PangoCoverage* pango_pdflib_font_get_coverage
                                            (PangoFont *font,
                                             PangoLanguage *language);


Description

Details

struct PangoPDFLIBLayout

struct PangoPDFLIBLayout;

The PangoPDFLIBLayout is a PDFlib-specific subclass of PangoLayout.


enum PangoPDFLIBBaseline

typedef enum {
  PANGO_PDFLIB_BASELINE_INVALID,
  PANGO_PDFLIB_BASELINE_AUTO,
  PANGO_PDFLIB_BASELINE_RESET_SIZE,
  PANGO_PDFLIB_BASELINE_ALPHABETIC,
  PANGO_PDFLIB_BASELINE_IDEOGRAPHIC,
  PANGO_PDFLIB_BASELINE_HANGING,
  PANGO_PDFLIB_BASELINE_MATHEMATICAL,
  PANGO_PDFLIB_BASELINE_CENTRAL,
  PANGO_PDFLIB_BASELINE_MIDDLE,
  PANGO_PDFLIB_BASELINE_TEXT_BEFORE_EDGE,
  PANGO_PDFLIB_BASELINE_TEXT_AFTER_EDGE,
  PANGO_PDFLIB_BASELINE_BEFORE_EDGE,
  PANGO_PDFLIB_BASELINE_AFTER_EDGE,
  PANGO_PDFLIB_BASELINE_LENGTH,
  PANGO_PDFLIB_BASELINE_USE_SCRIPT,
  PANGO_PDFLIB_BASELINE_BASELINE
} PangoPDFLIBBaseline;

The PangoPDFLIBBaseline represents the baseline for aligning glyphs.

PANGO_PDFLIB_BASELINE_INVALIDInvalid
PANGO_PDFLIB_BASELINE_AUTOThe baseline is determined by Pango
PANGO_PDFLIB_BASELINE_RESET_SIZE
PANGO_PDFLIB_BASELINE_ALPHABETICThe baseline used by most alphabetic and syllabic scripts
PANGO_PDFLIB_BASELINE_IDEOGRAPHICThe baseline used by ideographic scripts
PANGO_PDFLIB_BASELINE_HANGINGThe baseline used by certain Indic scripts
PANGO_PDFLIB_BASELINE_MATHEMATICALThe baseline used by mathematical symbols
PANGO_PDFLIB_BASELINE_CENTRALThe computed baseline at the center of the em box
PANGO_PDFLIB_BASELINE_MIDDLE The baseline offset from the alphabetic baseline in the shift-direction by 1/2 the font x-height
PANGO_PDFLIB_BASELINE_TEXT_BEFORE_EDGEThe baseline at the before-edge of the em box
PANGO_PDFLIB_BASELINE_TEXT_AFTER_EDGEThe baseline at the after-edge of the em box
PANGO_PDFLIB_BASELINE_BEFORE_EDGEComputed baseline for line areas
PANGO_PDFLIB_BASELINE_AFTER_EDGEComputed baseline for line areas
PANGO_PDFLIB_BASELINE_LENGTHBaseline is specified as a length
PANGO_PDFLIB_BASELINE_USE_SCRIPTThe script determines the baseline
PANGO_PDFLIB_BASELINE_BASELINE

enum PangoPDFLIBLineStackingStrategy

typedef enum {
  PANGO_PDFLIB_LINE_STACKING_STRATEGY_INVALID,
  PANGO_PDFLIB_LINE_STACKING_STRATEGY_LINE_HEIGHT,
  PANGO_PDFLIB_LINE_STACKING_STRATEGY_FONT_HEIGHT,
  PANGO_PDFLIB_LINE_STACKING_STRATEGY_MAX_HEIGHT
} PangoPDFLIBLineStackingStrategy;

The PangoPDFLIBLineStackingStrategy determines how lines are stacked within a layout.

See Section 7.15.6 of the XSL 1.0 Recommendation.

PANGO_PDFLIB_LINE_STACKING_STRATEGY_INVALIDInvalid value
PANGO_PDFLIB_LINE_STACKING_STRATEGY_LINE_HEIGHTUses the per-inline-height rectangle
PANGO_PDFLIB_LINE_STACKING_STRATEGY_FONT_HEIGHTUses the nominal-requested-line-rectangle
PANGO_PDFLIB_LINE_STACKING_STRATEGY_MAX_HEIGHTUses the maximal-line-rectangle

PANGO_RENDER_TYPE_PDFLIB

#define PANGO_RENDER_TYPE_PDFLIB "PangoRenderPDFLIB"

A string constant identifying the PDFlib renderer. The associated quark (see g_quark_from_string()) is used to identify the renderer in pango_find_map().


struct PangoPDFLIBFontMap

struct PangoPDFLIBFontMap;

The PangoPDFLIBFontMap is the PangoFontMap implementation for FreeType fonts and the PDFlib renderer.


PangoPDFLIBSubstituteFunc ()

void        (*PangoPDFLIBSubstituteFunc)    (FcPattern *pattern,
                                             gpointer data);

Function type for doing final config tweaking on prepared FcPatterns.

pattern :the FcPattern to tweak.
data :user data.

pango_pdflib_get_context ()

PangoContext* pango_pdflib_get_context      (double dpi_x,
                                             double dpi_y);

Retrieves a PangoContext for the default PangoPDFLIB fontmap (see pango_pdflib_fontmap_get_for_display()) and sets the resolution for the default fontmap to dpi_x by dpi_y.

Use of this function is discouraged, see pango_pdflib_font_map_create_context() instead.

dpi_x : the horizontal dpi of the target device
dpi_y : the vertical dpi of the target device
Returns : the new PangoContext

pango_pdflib_font_map_for_display ()

PangoFontMap* pango_pdflib_font_map_for_display
                                            (void);

Returns a PangoPDFLIBFontMap. This font map is cached and should not be freed. If the font map is no longer needed, it can be released with pango_pdflib_shutdown_display().

Returns : a PangoPDFLIBFontMap.

pango_pdflib_shutdown_display ()

void        pango_pdflib_shutdown_display   (void);

Free the global fontmap. (See pango_pdflib_font_map_for_display())


pango_pdflib_render ()

void        pango_pdflib_render             (PDF *pdf_doc,
                                             const gchar *layout_text,
                                             PangoLayoutRun *run,
                                             PangoFont *font,
                                             PangoGlyphString *glyphs,
                                             gint x,
                                             gint y);

Renders a PangoGlyphString onto a PDFlib PDF document.

pdf_doc : the PDFlib document onto which to draw layout_text.
layout_text : the text of the layout.
run : the PangoLayoutRun to render.
font : the font in which to draw the string.
glyphs : the glyph string to draw.
x : the x position of the start of the string (in PangoGlyphUnit).
y : the y position of the baseline (in PangoGlyphUnit).

pango_pdflib_render_layout_line ()

void        pango_pdflib_render_layout_line (PDF *pdf_doc,
                                             const gchar *layout_text,
                                             PangoLayoutLine *line,
                                             gint x,
                                             gint y);

Render a PangoLayoutLine onto a FreeType2 bitmap

pdf_doc : the PDFlib document onto which to draw layout_text.
layout_text : the text of the layout.
line : a PangoLayoutLine
x : the x position of start of string (in PangoGlyphUnit)
y : the y position of baseline (in PangoGlyphUnit)

pango_pdflib_render_layout_lines ()

void        pango_pdflib_render_layout_lines
                                            (PDF *pdf_doc,
                                             PangoLayout *layout,
                                             gint line_first,
                                             gint line_last,
                                             gint x,
                                             gint y);

Render some lines from PangoLayout onto a PDFlib PDF document.

pdf_doc : the PDFlib document onto which to draw layout_text.
layout : a PangoLayout
line_first : the first line to render.
line_last : the last line to render.
x : the X position of the left of the layout (in PangoGlyphUnit)
y : the Y position of the top of the layout (in PangoGlyphUnit)

pango_pdflib_render_layout ()

void        pango_pdflib_render_layout      (PDF *pdf_doc,
                                             PangoLayout *layout,
                                             gint x,
                                             gint y);

Render a PangoLayout onto a PDFlib PDF document.

pdf_doc : the PDFlib document onto which to draw layout_text.
layout : a PangoLayout
x : the X position of the left of the layout (in PangoGlyphUnit)
y : the Y position of the top of the layout (in PangoGlyphUnit)

pango_pdflib_font_map_new ()

PangoFontMap* pango_pdflib_font_map_new     (void);

Create a new PangoPDFLIBFontMap object; a fontmap is used to cache information about available fonts, and holds certain global parameters such as the resolution and the default substitute function (see pango_font_map_set_default_substitute()).

Returns : the newly created fontmap object. Unref with g_object_unref when you are finished with it.

pango_pdflib_font_map_set_resolution ()

void        pango_pdflib_font_map_set_resolution
                                            (PangoPDFLIBFontMap *fontmap,
                                             double dpi_x,
                                             double dpi_y);

Sets the horizontal and vertical resolutions for the fontmap.

fontmap : a PangoPDFLIBFontmap
dpi_x : dots per inch in the X direction
dpi_y : dots per inch in the Y direction

pango_pdflib_font_map_set_default_substitute ()

void        pango_pdflib_font_map_set_default_substitute
                                            (PangoPDFLIBFontMap *fontmap,
                                             PangoPDFLIBSubstituteFunc func,
                                             gpointer data,
                                             GDestroyNotify notify);

Sets a function that will be called to do final configuration substitution on a FcPattern before it is used to load the font. This function can be used to do things like set hinting and antiasing options.

Since: 1.2

fontmap : a PangoPDFLIBFontMap
func : function to call to to do final config tweaking on FcPattern objects.
data : data to pass to func
notify : function to call when data is no longer used.

pango_pdflib_font_map_substitute_changed ()

void        pango_pdflib_font_map_substitute_changed
                                            (PangoPDFLIBFontMap *fontmap);

Call this function any time the results of the default substitution function set with pango_pdflib_font_map_set_default_substitute() change. That is, if your subsitution function will return different results for the same input pattern, you must call this function.

fontmap : a PangoPDFLIBFontmap

pango_pdflib_font_map_create_context ()

PangoContext* pango_pdflib_font_map_create_context
                                            (PangoPDFLIBFontMap *fontmap);

Create a PangoContext for the given fontmap.

fontmap : a PangoPDFLIBFontmap
Returns : the newly created context; free with g_object_unref().

enum PangoPDFLIBDebugFlags

typedef enum
{
  PANGO_PDFLIB_DEBUG_NONE	= 0,
  PANGO_PDFLIB_DEBUG_DEBUG	= 1,
  PANGO_PDFLIB_DEBUG_MASK	= 0x01
} PangoPDFLIBDebugFlags;

The PangoPDFLIBDebugFlags determine the debugging mode of the PangoContext

PANGO_PDFLIB_DEBUG_NONENo debugging is enabled
PANGO_PDFLIB_DEBUG_DEBUGDebugging is enabled
PANGO_PDFLIB_DEBUG_MASK

pango_pdflib_font_map_create_context_with_debug_flags ()

PangoContext* pango_pdflib_font_map_create_context_with_debug_flags
                                            (PangoPDFLIBFontMap *fontmap,
                                             PangoPDFLIBDebugFlags debug_flags);

Create a PangoContext for the given fontmap.

Debug flags are currently ignored.

fontmap : a PangoPDFLIBFontmap
debug_flags : PangoPDFLIBDebugFlags
Returns : the newly created context; free with g_object_unref().

pango_pdflib_layout_set_line_height ()

void        pango_pdflib_layout_set_line_height
                                            (PangoLayout *layout,
                                             gint line_height);

Sets the line-height of the layout.

layout : The PangoPDFLIBLayout.
line_height : The line-height for the layout.

pango_pdflib_layout_set_line_stacking_strategy ()

void        pango_pdflib_layout_set_line_stacking_strategy
                                            (PangoLayout *layout,
                                             PangoPDFLIBLineStackingStrategy line_stacking_strategy);

Sets the line-stacking-strategy of the layout.

layout : The PangoPDFLIBLayout.
line_stacking_strategy : The line-stacking-strategy for the layout.

pango_pdflib_layout_get_item_attrs ()

gint        pango_pdflib_layout_get_item_attrs
                                            (PangoItem *item,
                                             PangoAttrType first_attribute_type,
                                             ...);

Gets specified attribute types, if present, from the extra attributes of item.

For each specified attribute type, if item has an attribute of that type, sets the PangoAttribute pointed to by the following argument to the attribute.

If item does not have an attribute of the specified type, sets the PangoAttribute pointed to by the following argument to NULL.

item : PangoItem which may have extra attributes.
first_attribute_type : PangoAttrType of a predefined or registered attribute type.
... : Remainder of list of PangoAttrType and **PangoAttribute pairs, terminated by PANGO_ATTR_INVALID.
Returns : The number of matches found.

pango_pdflib_get_unknown_glyph ()

PangoGlyph  pango_pdflib_get_unknown_glyph  (PangoFont *font);

Return the index of a glyph suitable for drawing unknown characters.

font : a PangoFont
Returns : a glyph index into font

pango_pdflib_font_get_kerning ()

int         pango_pdflib_font_get_kerning   (PangoFont *font,
                                             PangoGlyph left,
                                             PangoGlyph right);

Retrieves kerning information for a combination of two glyphs.

font : a PangoFont
left : the left PangoGlyph
right : the right PangoGlyph
Returns : The amount of kerning (in Pango units) to apply for the given combination of glyphs.

pango_pdflib_font_get_face ()

FT_Face     pango_pdflib_font_get_face      (PangoFont *font);

Returns the native FreeType2 FT_Face structure used for this PangoFont. This may be useful if you want to use FreeType2 functions directly.

font : a PangoFont
Returns : a pointer to a FT_Face structure, with the size set correctly

pango_pdflib_font_get_coverage ()

PangoCoverage* pango_pdflib_font_get_coverage
                                            (PangoFont *font,
                                             PangoLanguage *language);

Should not be called directly, use pango_font_get_coverage() instead.

font : a PangoPDFLIBFont.
language : a language tag.
Returns : a PangoCoverage.