1 /* Copyright (C) 1996, 2000, 2001 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: gxfont42.h,v 1.21 2005/02/27 05:56:59 ray Exp $ */ 18 /* Type 42 font data definition */ 19 20 #ifndef gxfont42_INCLUDED 21 # define gxfont42_INCLUDED 22 23 #ifndef gs_glyph_cache_DEFINED 24 # define gs_glyph_cache_DEFINED 25 typedef struct gs_glyph_cache_s gs_glyph_cache; 26 #endif 27 28 #ifndef cached_fm_pair_DEFINED 29 # define cached_fm_pair_DEFINED 30 typedef struct cached_fm_pair_s cached_fm_pair; 31 #endif 32 33 /* This is the type-specific information for a Type 42 (TrueType) font. */ 34 #ifndef gs_type42_data_DEFINED 35 #define gs_type42_data_DEFINED 36 typedef struct gs_type42_data_s gs_type42_data; 37 #endif 38 #ifndef gs_font_type42_DEFINED 39 # define gs_font_type42_DEFINED 40 typedef struct gs_font_type42_s gs_font_type42; 41 #endif 42 typedef struct gs_type42_mtx_s { 43 uint numMetrics; /* num*Metrics from [hv]hea */ 44 ulong offset; /* offset to [hv]mtx table */ 45 uint length; /* length of [hv]mtx table */ 46 } gs_type42_mtx_t; 47 struct gs_type42_data_s { 48 /* The following are set by the client. */ 49 int (*string_proc) (gs_font_type42 *, ulong, uint, const byte **); 50 void *proc_data; /* data for procedures */ 51 /* 52 * The following are initialized by ...font_init, but may be reset by 53 * the client. 54 */ 55 uint (*get_glyph_index)(gs_font_type42 *pfont, gs_glyph glyph); 56 int (*get_outline)(gs_font_type42 *pfont, uint glyph_index, 57 gs_glyph_data_t *pgd); 58 int (*get_metrics)(gs_font_type42 *pfont, uint glyph_index, int wmode, 59 float sbw[4]); 60 /* The following are cached values. */ 61 ulong cmap; /* offset to cmap table (not used by */ 62 /* renderer, only here for clients) */ 63 ulong glyf; /* offset to glyf table */ 64 uint unitsPerEm; /* from head */ 65 uint indexToLocFormat; /* from head */ 66 gs_type42_mtx_t metrics[2]; /* hhea/hmtx, vhea/vmtx (indexed by WMode) */ 67 ulong loca; /* offset to loca table */ 68 /* 69 * TrueType fonts specify the number of glyphs in two different ways: 70 * the size of the loca table, and an explicit value in maxp. Currently 71 * the value of numGlyphs in this structure is computed from the size of 72 * loca. This is wrong: incrementally downloaded TrueType (or 73 * CIDFontType 2) fonts will have no loca table, but will have a 74 * reasonable glyph count in maxp. Unfortunately, a significant amount 75 * of code now depends on the incorrect definition of numGlyphs. 76 * Therefore, rather than run the risk of introducing bugs by changing 77 * the definition and/or by changing the name of the data member, we add 78 * another member trueNumGlyphs to hold the value from maxp. 79 */ 80 uint numGlyphs; /* from size of loca */ 81 uint trueNumGlyphs; /* from maxp */ 82 uint *len_glyphs; /* built from the loca table */ 83 gs_glyph_cache *gdcache; 84 bool warning_patented; 85 bool warning_bad_instruction; 86 }; 87 #define gs_font_type42_common\ 88 gs_font_base_common;\ 89 gs_type42_data data 90 struct gs_font_type42_s { 91 gs_font_type42_common; 92 }; 93 94 extern_st(st_gs_font_type42); 95 #define public_st_gs_font_type42() /* in gstype42.c */\ 96 gs_public_st_suffix_add3_final(st_gs_font_type42, gs_font_type42,\ 97 "gs_font_type42", font_type42_enum_ptrs, font_type42_reloc_ptrs,\ 98 gs_font_finalize, st_gs_font_base, data.proc_data, data.len_glyphs, \ 99 data.gdcache) 100 101 /* 102 * Because a Type 42 font contains so many cached values, 103 * we provide a procedure to initialize them from the font data. 104 * Note that this initializes the type42_data procedures other than 105 * string_proc, and the font procedures as well. 106 */ 107 int gs_type42_font_init(gs_font_type42 *); 108 109 /* Append the outline of a TrueType character to a path. */ 110 int gs_type42_append(uint glyph_index, gs_imager_state * pis, 111 gx_path * ppath, const gs_log2_scale_point * pscale, 112 bool charpath_flag, int paint_type, cached_fm_pair *pair); 113 114 /* Get the metrics of a TrueType character. */ 115 int gs_type42_get_metrics(gs_font_type42 * pfont, uint glyph_index, 116 float psbw[4]); 117 int gs_type42_wmode_metrics(gs_font_type42 * pfont, uint glyph_index, 118 int wmode, float psbw[4]); 119 /* Export the default get_metrics procedure. */ 120 int gs_type42_default_get_metrics(gs_font_type42 *pfont, uint glyph_index, 121 int wmode, float sbw[4]); 122 123 int gs_type42_get_outline_from_TT_file(gs_font_type42 * pfont, stream *s, uint glyph_index, 124 gs_glyph_data_t *pgd); 125 126 /* Export the font procedures so they can be called from the interpreter. */ 127 font_proc_enumerate_glyph(gs_type42_enumerate_glyph); 128 font_proc_glyph_info(gs_type42_glyph_info); 129 font_proc_glyph_outline(gs_type42_glyph_outline); 130 131 /* Get glyph info by glyph index. */ 132 int gs_type42_glyph_info_by_gid(gs_font *font, gs_glyph glyph, const gs_matrix *pmat, 133 int members, gs_glyph_info_t *info, uint glyph_index); 134 135 #endif /* gxfont42_INCLUDED */ 136