w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cairo-truetype-subset.c File Reference
Include dependency graph for cairo-truetype-subset.c:

Go to the source code of this file.

Classes

struct  subset_glyph
 
struct  table
 
struct  _cairo_truetype_font
 
struct  _cmap_unicode_range
 

Macros

#define _DEFAULT_SOURCE   /* for snprintf(), strdup() */
 
#define check(T, S)   COMPILE_TIME_ASSERT (sizeof (T) == (S))
 
#define SFNT_VERSION   0x00010000
 
#define SFNT_STRING_MAX_LENGTH   65535
 
#define MAX_FONT_NAME_LENGTH   127
 

Typedefs

typedef struct subset_glyph subset_glyph_t
 
typedef struct _cairo_truetype_font cairo_truetype_font_t
 
typedef struct table table_t
 
typedef int compile_time_assertion_at_line___LINE___failed[(sizeof(tt_head_t)==(54))?1:-1]
 
typedef struct _cmap_unicode_range cmap_unicode_range_t
 

Functions

static cairo_status_t cairo_truetype_font_use_glyph (cairo_truetype_font_t *font, unsigned short glyph, unsigned short *out)
 
static cairo_status_t _cairo_truetype_font_set_error (cairo_truetype_font_t *font, cairo_status_t status)
 
static cairo_status_t _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset, cairo_bool_t is_pdf, cairo_truetype_font_t **font_return)
 
static void cairo_truetype_font_destroy (cairo_truetype_font_t *font)
 
static cairo_status_t cairo_truetype_font_allocate_write_buffer (cairo_truetype_font_t *font, size_t length, unsigned char **buffer)
 
static void cairo_truetype_font_write (cairo_truetype_font_t *font, const void *data, size_t length)
 
static void cairo_truetype_font_write_be16 (cairo_truetype_font_t *font, uint16_t value)
 
static void cairo_truetype_font_write_be32 (cairo_truetype_font_t *font, uint32_t value)
 
static cairo_status_t cairo_truetype_font_align_output (cairo_truetype_font_t *font, unsigned long *aligned)
 
static cairo_status_t cairo_truetype_font_check_boundary (cairo_truetype_font_t *font, unsigned long boundary)
 
static cairo_status_t cairo_truetype_font_write_cmap_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_generic_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_remap_composite_glyph (cairo_truetype_font_t *font, unsigned char *buffer, unsigned long size)
 
static cairo_status_t cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_head_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_hhea_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_hmtx_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_loca_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_maxp_table (cairo_truetype_font_t *font, unsigned long tag)
 
static cairo_status_t cairo_truetype_font_write_offset_table (cairo_truetype_font_t *font)
 
static uint32_t cairo_truetype_font_calculate_checksum (cairo_truetype_font_t *font, unsigned long start, unsigned long end)
 
static void cairo_truetype_font_update_entry (cairo_truetype_font_t *font, int index, unsigned long tag, unsigned long start, unsigned long end)
 
static cairo_status_t cairo_truetype_font_generate (cairo_truetype_font_t *font, const char **data, unsigned long *length, const unsigned long **string_offsets, unsigned long *num_strings)
 
static void cairo_truetype_font_add_truetype_table (cairo_truetype_font_t *font, unsigned long tag, cairo_status_t(*write)(cairo_truetype_font_t *font, unsigned long tag), int pos)
 
static void cairo_truetype_font_create_truetype_table_list (cairo_truetype_font_t *font)
 
static cairo_status_t cairo_truetype_subset_init_internal (cairo_truetype_subset_t *truetype_subset, cairo_scaled_font_subset_t *font_subset, cairo_bool_t is_pdf)
 
cairo_status_t _cairo_truetype_subset_init_ps (cairo_truetype_subset_t *truetype_subset, cairo_scaled_font_subset_t *font_subset)
 
cairo_status_t _cairo_truetype_subset_init_pdf (cairo_truetype_subset_t *truetype_subset, cairo_scaled_font_subset_t *font_subset)
 
void _cairo_truetype_subset_fini (cairo_truetype_subset_t *subset)
 
static cairo_int_status_t _cairo_truetype_reverse_cmap (cairo_scaled_font_t *scaled_font, unsigned long table_offset, unsigned long index, uint32_t *ucs4)
 
cairo_int_status_t _cairo_truetype_index_to_ucs4 (cairo_scaled_font_t *scaled_font, unsigned long index, uint32_t *ucs4)
 
static cairo_status_t find_name (tt_name_t *name, int name_id, int platform, int encoding, int language, char **str_out)
 
cairo_int_status_t _cairo_truetype_read_font_name (cairo_scaled_font_t *scaled_font, char **ps_name_out, char **font_name_out)
 
cairo_int_status_t _cairo_truetype_get_style (cairo_scaled_font_t *scaled_font, int *weight, cairo_bool_t *bold, cairo_bool_t *italic)
 

Variables

static cmap_unicode_range_t winansi_unicode_ranges []
 

Macro Definition Documentation

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE   /* for snprintf(), strdup() */

Definition at line 43 of file cairo-truetype-subset.c.

◆ check

#define check (   T,
  S 
)    COMPILE_TIME_ASSERT (sizeof (T) == (S))

Definition at line 104 of file cairo-truetype-subset.c.

◆ MAX_FONT_NAME_LENGTH

#define MAX_FONT_NAME_LENGTH   127

Definition at line 1438 of file cairo-truetype-subset.c.

◆ SFNT_STRING_MAX_LENGTH

#define SFNT_STRING_MAX_LENGTH   65535

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

◆ SFNT_VERSION

#define SFNT_VERSION   0x00010000

Definition at line 119 of file cairo-truetype-subset.c.

Typedef Documentation

◆ cairo_truetype_font_t

Definition at line 1 of file cairo-truetype-subset.c.

◆ cmap_unicode_range_t

◆ compile_time_assertion_at_line___LINE___failed

typedef int compile_time_assertion_at_line___LINE___failed[(sizeof(tt_glyph_data_t)==(26))?1:-1]

Definition at line 105 of file cairo-truetype-subset.c.

◆ subset_glyph_t

typedef struct subset_glyph subset_glyph_t

Definition at line 1 of file cairo-truetype-subset.c.

◆ table_t

typedef struct table table_t

Definition at line 1 of file cairo-truetype-subset.c.

Function Documentation

◆ _cairo_truetype_font_create()

◆ _cairo_truetype_font_set_error()

◆ _cairo_truetype_get_style()

cairo_int_status_t _cairo_truetype_get_style ( cairo_scaled_font_t scaled_font,
int weight,
cairo_bool_t bold,
cairo_bool_t italic 
)

_cairo_truetype_get_style: @scaled_font: the cairo_scaled_font_t @weight: returns the font weight from the OS/2 table @bold: returns true if font is bold @italic: returns true if font is italic

If the font is a truetype/opentype font with an OS/2 table, get the weight, bold, and italic data from the OS/2 table. The weight values have the same meaning as the lfWeight field of the Windows LOGFONT structure. Refer to the TrueType Specification for definition of the weight values.

Return value: CAIRO_STATUS_SUCCESS if successful, CAIRO_INT_STATUS_UNSUPPORTED if the font is not TrueType/OpenType or the OS/2 table is not present.

Definition at line 1639 of file cairo-truetype-subset.c.

◆ _cairo_truetype_index_to_ucs4()

cairo_int_status_t _cairo_truetype_index_to_ucs4 ( cairo_scaled_font_t scaled_font,
unsigned long  index,
uint32_t ucs4 
)

_cairo_truetype_index_to_ucs4: @scaled_font: the cairo_scaled_font_t @index: the glyph index @ucs4: return value for the unicode value of the glyph

If possible (depending on the format of the underlying cairo_scaled_font_t and the font backend in use) assign the unicode character of the glyph to @ucs4.

If mapping glyph indices to unicode is supported but the unicode value of the specified glyph is not available, @ucs4 is set to -1.

Return value: CAIRO_STATUS_SUCCESS if successful, CAIRO_INT_STATUS_UNSUPPORTED if mapping glyph indices to unicode is not supported. Possible errors include CAIRO_STATUS_NO_MEMORY.

Definition at line 1378 of file cairo-truetype-subset.c.

◆ _cairo_truetype_read_font_name()

cairo_int_status_t _cairo_truetype_read_font_name ( cairo_scaled_font_t scaled_font,
char **  ps_name,
char **  font_name 
)

_cairo_truetype_read_font_name: @scaled_font: the cairo_scaled_font_t @ps_name: returns the PostScript name of the font or NULL if the name could not be found. @font_name: returns the font name or NULL if the name could not be found.

If possible (depending on the format of the underlying cairo_scaled_font_t and the font backend in use) read the PostScript and Font names from a TrueType/OpenType font.

The font name is the full name of the font eg "DejaVu Sans Bold". The PostScript name is a shortened name with spaces removed suitable for use as the font name in a PS or PDF file eg "DejaVuSans-Bold".

Return value: CAIRO_STATUS_SUCCESS if successful, CAIRO_INT_STATUS_UNSUPPORTED if the font is not TrueType/OpenType or the name table is not present. Possible errors include CAIRO_STATUS_NO_MEMORY.

Definition at line 1548 of file cairo-truetype-subset.c.

Referenced by _cairo_truetype_font_create().

◆ _cairo_truetype_reverse_cmap()

static cairo_int_status_t _cairo_truetype_reverse_cmap ( cairo_scaled_font_t scaled_font,
unsigned long  table_offset,
unsigned long  index,
uint32_t ucs4 
)
static

◆ _cairo_truetype_subset_fini()

void _cairo_truetype_subset_fini ( cairo_truetype_subset_t truetype_subset)

_cairo_truetype_subset_fini: @truetype_subset: a cairo_truetype_subset_t

Free all resources associated with @truetype_subset. After this call, @truetype_subset should not be used again without a subsequent call to _cairo_truetype_subset_init() again first.

Definition at line 1257 of file cairo-truetype-subset.c.

◆ _cairo_truetype_subset_init_pdf()

cairo_status_t _cairo_truetype_subset_init_pdf ( cairo_truetype_subset_t truetype_subset,
cairo_scaled_font_subset_t font_subset 
)

_cairo_truetype_subset_init_pdf: @truetype_subset: a cairo_truetype_subset_t to initialize @font_subset: the cairo_scaled_font_subset_t to initialize from

If possible (depending on the format of the underlying cairo_scaled_font_t and the font backend in use) generate a truetype file corresponding to @font_subset and initialize @truetype_subset with information about the subset and the truetype data. The generated font will be suitable for embedding in PDF.

Return value: CAIRO_STATUS_SUCCESS if successful, CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a truetype file, or an non-zero value indicating an error. Possible errors include CAIRO_STATUS_NO_MEMORY.

Definition at line 1250 of file cairo-truetype-subset.c.

◆ _cairo_truetype_subset_init_ps()

cairo_status_t _cairo_truetype_subset_init_ps ( cairo_truetype_subset_t truetype_subset,
cairo_scaled_font_subset_t font_subset 
)

_cairo_truetype_subset_init_ps: @truetype_subset: a cairo_truetype_subset_t to initialize @font_subset: the cairo_scaled_font_subset_t to initialize from

If possible (depending on the format of the underlying cairo_scaled_font_t and the font backend in use) generate a truetype file corresponding to @font_subset and initialize @truetype_subset with information about the subset and the truetype data. The generated font will be suitable for embedding in PostScript.

Return value: CAIRO_STATUS_SUCCESS if successful, CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a truetype file, or an non-zero value indicating an error. Possible errors include CAIRO_STATUS_NO_MEMORY.

Definition at line 1243 of file cairo-truetype-subset.c.

◆ cairo_truetype_font_add_truetype_table()

static void cairo_truetype_font_add_truetype_table ( cairo_truetype_font_t font,
unsigned long  tag,
cairo_status_t(*)(cairo_truetype_font_t *font, unsigned long tag write,
int  pos 
)
static

Definition at line 1043 of file cairo-truetype-subset.c.

References pos, tag, and write.

Referenced by cairo_truetype_font_create_truetype_table_list().

◆ cairo_truetype_font_align_output()

◆ cairo_truetype_font_allocate_write_buffer()

◆ cairo_truetype_font_calculate_checksum()

static uint32_t cairo_truetype_font_calculate_checksum ( cairo_truetype_font_t font,
unsigned long  start,
unsigned long  end 
)
static

◆ cairo_truetype_font_check_boundary()

static cairo_status_t cairo_truetype_font_check_boundary ( cairo_truetype_font_t font,
unsigned long  boundary 
)
static

◆ cairo_truetype_font_create_truetype_table_list()

◆ cairo_truetype_font_destroy()

static void cairo_truetype_font_destroy ( cairo_truetype_font_t font)
static

Definition at line 296 of file cairo-truetype-subset.c.

References _cairo_array_fini(), and free.

Referenced by cairo_truetype_subset_init_internal().

◆ cairo_truetype_font_generate()

◆ cairo_truetype_font_remap_composite_glyph()

◆ cairo_truetype_font_update_entry()

static void cairo_truetype_font_update_entry ( cairo_truetype_font_t font,
int  index,
unsigned long  tag,
unsigned long  start,
unsigned long  end 
)
static

◆ cairo_truetype_font_use_glyph()

static cairo_status_t cairo_truetype_font_use_glyph ( cairo_truetype_font_t font,
unsigned short  glyph,
unsigned short *  out 
)
static

◆ cairo_truetype_font_write()

static void cairo_truetype_font_write ( cairo_truetype_font_t font,
const void data,
size_t  length 
)
static

◆ cairo_truetype_font_write_be16()

◆ cairo_truetype_font_write_be32()

◆ cairo_truetype_font_write_cmap_table()

◆ cairo_truetype_font_write_generic_table()

static cairo_status_t cairo_truetype_font_write_generic_table ( cairo_truetype_font_t font,
unsigned long  tag 
)
static

◆ cairo_truetype_font_write_glyf_table()

◆ cairo_truetype_font_write_head_table()

◆ cairo_truetype_font_write_hhea_table()

◆ cairo_truetype_font_write_hmtx_table()

◆ cairo_truetype_font_write_loca_table()

◆ cairo_truetype_font_write_maxp_table()

◆ cairo_truetype_font_write_offset_table()

◆ cairo_truetype_subset_init_internal()

◆ find_name()

Variable Documentation

◆ winansi_unicode_ranges

cmap_unicode_range_t winansi_unicode_ranges[]
static
Initial value:
= {
{ 0x0020, 0x007f },
{ 0x00a0, 0x00ff },
{ 0x0152, 0x0153 },
{ 0x0160, 0x0161 },
{ 0x0178, 0x0178 },
{ 0x017d, 0x017e },
{ 0x0192, 0x0192 },
{ 0x02c6, 0x02c6 },
{ 0x02dc, 0x02dc },
{ 0x2013, 0x2026 },
{ 0x2030, 0x2030 },
{ 0x2039, 0x203a },
{ 0x20ac, 0x20ac },
{ 0x2122, 0x2122 },
}

Definition at line 419 of file cairo-truetype-subset.c.

Referenced by cairo_truetype_font_write_cmap_table().