Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
cairo-font-subset-private.h File Reference
#include "cairoint.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  cairo_font_subset


typedef struct cairo_font_subset_backend
typedef struct cairo_font_subset


cairo_private int _cairo_font_subset_use_glyph (cairo_font_subset_t *font, int glyph)
cairo_private cairo_status_t _cairo_font_subset_generate (cairo_font_subset_t *font, const char **data, unsigned long *length)
cairo_private void _cairo_font_subset_destroy (cairo_font_subset_t *font)
cairo_private cairo_font_subset_t * _cairo_font_subset_create (cairo_unscaled_font_t *unscaled_font)

Class Documentation

struct cairo_font_subset

Definition at line 43 of file cairo-font-subset-private.h.

Collaboration diagram for cairo_font_subset:
Class Members
long ascent
cairo_font_subset_backend_t * backend
char * base_font
long descent
unsigned int font_id
int num_glyphs
cairo_unscaled_font_t * unscaled_font
int * widths
long x_max
long x_min
long y_max
long y_min

Typedef Documentation

typedef struct cairo_font_subset

Definition at line 42 of file cairo-font-subset-private.h.

typedef struct cairo_font_subset_backend

Definition at line 41 of file cairo-font-subset-private.h.

Function Documentation

cairo_private cairo_font_subset_t* _cairo_font_subset_create ( cairo_unscaled_font_t unscaled_font)

Definition at line 139 of file cairo-font-subset.c.

    cairo_ft_unscaled_font_t *ft_unscaled_font;
    FT_Face face;
    cairo_pdf_ft_font_t *font;
    unsigned long size;
    int i, j;

    /* XXX: Need to fix this to work with a general cairo_unscaled_font_t. */
    if (! _cairo_unscaled_font_is_ft (unscaled_font))
       return NULL;

    ft_unscaled_font = (cairo_ft_unscaled_font_t *) unscaled_font;

    face = _cairo_ft_unscaled_font_lock_face (ft_unscaled_font);

    /* We currently only support freetype truetype fonts. */
    size = 0;
    if (!FT_IS_SFNT (face) ||
       FT_Load_Sfnt_Table (face, TTAG_glyf, 0, NULL, &size) != 0)
       return NULL;

    font = malloc (sizeof (cairo_pdf_ft_font_t));
    if (font == NULL)
       return NULL;

    font->base.unscaled_font = _cairo_unscaled_font_reference (unscaled_font);
    font->base.backend = &cairo_pdf_ft_font_backend;

    _cairo_array_init (&font->output, sizeof (char));
    if (_cairo_array_grow_by (&font->output, 4096) != CAIRO_STATUS_SUCCESS)
       goto fail1;

    font->glyphs = calloc (face->num_glyphs + 1, sizeof (ft_subset_glyph_t));
    if (font->glyphs == NULL)
       goto fail2;

    font->parent_to_subset = calloc (face->num_glyphs, sizeof (int));
    if (font->parent_to_subset == NULL)
       goto fail3;

    font->base.num_glyphs = 1;
    font->base.x_min = face->bbox.xMin;
    font->base.y_min = face->bbox.yMin;
    font->base.x_max = face->bbox.xMax;
    font->base.y_max = face->bbox.yMax;
    font->base.ascent = face->ascender;
    font->base.descent = face->descender;
    font->base.base_font = strdup (face->family_name);
    if (font->base.base_font == NULL)
       goto fail4;

    for (i = 0, j = 0; font->base.base_font[j]; j++) {
       if (font->base.base_font[j] == ' ')
       font->base.base_font[i++] = font->base.base_font[j];
    font->base.base_font[i] = '\0';

    font->base.widths = calloc (face->num_glyphs, sizeof (int));
    if (font->base.widths == NULL)
       goto fail5;

    _cairo_ft_unscaled_font_unlock_face (ft_unscaled_font);

    font->status = CAIRO_STATUS_SUCCESS;

    return &font->base;

    free (font->base.base_font);
    free (font->parent_to_subset);
    free (font->glyphs);
    _cairo_array_fini (&font->output);
    free (font);
    return NULL;

Here is the call graph for this function:

Here is the caller graph for this function:

cairo_private void _cairo_font_subset_destroy ( cairo_font_subset_t *  font)

Definition at line 133 of file cairo-font-subset.c.

    font->backend->destroy (font);

Here is the caller graph for this function:

cairo_private cairo_status_t _cairo_font_subset_generate ( cairo_font_subset_t *  font,
const char **  data,
unsigned long length 

Definition at line 126 of file cairo-font-subset.c.

    return font->backend->generate (font, data, length);

Here is the caller graph for this function:

cairo_private int _cairo_font_subset_use_glyph ( cairo_font_subset_t *  font,
int  glyph 

Definition at line 120 of file cairo-font-subset.c.

    return font->backend->use_glyph (font, glyph);

Here is the caller graph for this function: