1*593dc095SDavid du Colombier /* Copyright (C) 2002 Aladdin Enterprises. All rights reserved. 2*593dc095SDavid du Colombier 3*593dc095SDavid du Colombier This software is provided AS-IS with no warranty, either express or 4*593dc095SDavid du Colombier implied. 5*593dc095SDavid du Colombier 6*593dc095SDavid du Colombier This software is distributed under license and may not be copied, 7*593dc095SDavid du Colombier modified or distributed except as expressly authorized under the terms 8*593dc095SDavid du Colombier of the license contained in the file LICENSE in this distribution. 9*593dc095SDavid du Colombier 10*593dc095SDavid du Colombier For more information about licensing, please refer to 11*593dc095SDavid du Colombier http://www.ghostscript.com/licensing/. For information on 12*593dc095SDavid du Colombier commercial licensing, go to http://www.artifex.com/licensing/ or 13*593dc095SDavid du Colombier contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14*593dc095SDavid du Colombier San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15*593dc095SDavid du Colombier */ 16*593dc095SDavid du Colombier 17*593dc095SDavid du Colombier /* $Id: gxfcopy.h,v 1.11 2004/10/15 18:18:32 igor Exp $ */ 18*593dc095SDavid du Colombier /* Font copying for high-level output */ 19*593dc095SDavid du Colombier 20*593dc095SDavid du Colombier #ifndef gxfcopy_INCLUDED 21*593dc095SDavid du Colombier # define gxfcopy_INCLUDED 22*593dc095SDavid du Colombier 23*593dc095SDavid du Colombier #include "gsccode.h" 24*593dc095SDavid du Colombier 25*593dc095SDavid du Colombier #ifndef gs_font_DEFINED 26*593dc095SDavid du Colombier # define gs_font_DEFINED 27*593dc095SDavid du Colombier typedef struct gs_font_s gs_font; 28*593dc095SDavid du Colombier #endif 29*593dc095SDavid du Colombier 30*593dc095SDavid du Colombier #ifndef gs_matrix_DEFINED 31*593dc095SDavid du Colombier # define gs_matrix_DEFINED 32*593dc095SDavid du Colombier typedef struct gs_matrix_s gs_matrix; 33*593dc095SDavid du Colombier #endif 34*593dc095SDavid du Colombier 35*593dc095SDavid du Colombier /* 36*593dc095SDavid du Colombier * Copy a font, aside from its glyphs. Note that PostScript-specific data 37*593dc095SDavid du Colombier * -- that is, data that do not appear in the C structure that is the 38*593dc095SDavid du Colombier * relevant subclass of gs_font -- are NOT copied. In particular, 39*593dc095SDavid du Colombier * Metrics[2], CDevProc, and FontInfo are not copied, except for the 40*593dc095SDavid du Colombier * information returned by font->procs.font_info (see the definition of 41*593dc095SDavid du Colombier * gs_font_info_t in gxfont.h). 42*593dc095SDavid du Colombier * 43*593dc095SDavid du Colombier * Note that in some cases the font must have a definition for the "not 44*593dc095SDavid du Colombier * defined" glyph, as noted below, or a rangecheck error occurs. 45*593dc095SDavid du Colombier * 46*593dc095SDavid du Colombier * The following FontTypes are supported: 47*593dc095SDavid du Colombier * 48*593dc095SDavid du Colombier * Type 1, Type 2 - Encoding and CharStrings are not copied. Subrs and 49*593dc095SDavid du Colombier * GlobalSubrs (for CFFs) are copied; OtherSubrs are not copied. The 50*593dc095SDavid du Colombier * font must have a glyph named .notdef; its definition is copied. 51*593dc095SDavid du Colombier * 52*593dc095SDavid du Colombier * Type 42 (TrueType) - Encoding and CharStrings are not copied. The 53*593dc095SDavid du Colombier * TrueType glyf and loca tables are not copied, nor are the bogus 54*593dc095SDavid du Colombier * Adobe gdir, glyx, and locx "tables". If the font has a definition 55*593dc095SDavid du Colombier * for a glyph named .notdef (in the CharStrings dictionary), the 56*593dc095SDavid du Colombier * definition is copied. 57*593dc095SDavid du Colombier * 58*593dc095SDavid du Colombier * CIDFontType 0 (Type 1/2-based CIDFonts) - the glyph data are not 59*593dc095SDavid du Colombier * copied. The Type 1/2 subfonts *are* copied, as are the Subrs (both 60*593dc095SDavid du Colombier * local and global). 61*593dc095SDavid du Colombier * 62*593dc095SDavid du Colombier * CIDFontType 2 (TrueType-based CIDFonts) - the glyph data and CIDMap 63*593dc095SDavid du Colombier * are not copied. 64*593dc095SDavid du Colombier * 65*593dc095SDavid du Colombier * The resulting font supports querying (font_info, glyph_info, etc.) and 66*593dc095SDavid du Colombier * rendering (glyph_outline, etc.), but it does not support make_font. 67*593dc095SDavid du Colombier */ 68*593dc095SDavid du Colombier int gs_copy_font(gs_font *font, const gs_matrix *orig_matrix, 69*593dc095SDavid du Colombier gs_memory_t *mem, gs_font **pfont_new); 70*593dc095SDavid du Colombier 71*593dc095SDavid du Colombier /* 72*593dc095SDavid du Colombier * Copy a glyph, including any sub-glyphs. The destination font ("copied" 73*593dc095SDavid du Colombier * argument) must be a font created by gs_copy_font. The source font 74*593dc095SDavid du Colombier * ("font" argument) must have the same FontType as the destination, and in 75*593dc095SDavid du Colombier * addition must be "compatible" with it as described under the individual 76*593dc095SDavid du Colombier * FontTypes just below; however, gs_copy_glyph does not check 77*593dc095SDavid du Colombier * compatibility. 78*593dc095SDavid du Colombier * 79*593dc095SDavid du Colombier * If any glyph has already been copied but does not have the same 80*593dc095SDavid du Colombier * definition as the one being copied now, gs_copy_glyph returns an 81*593dc095SDavid du Colombier * invalidaccess error. If the top-level glyph has already been copied 82*593dc095SDavid du Colombier * (with the same definition), gs_copy_glyph returns 1. Otherwise, 83*593dc095SDavid du Colombier * gs_copy_glyph returns 0. 84*593dc095SDavid du Colombier * 85*593dc095SDavid du Colombier * Type 1, Type 2 - the destination and source must have the same 86*593dc095SDavid du Colombier * Subrs. glyph must be a name (not an integer). Copies the 87*593dc095SDavid du Colombier * CharString entry. Note that the Type 1/2 'seac' operator requires 88*593dc095SDavid du Colombier * copying not only the sub-glyphs but their Encoding entries as well. 89*593dc095SDavid du Colombier * 90*593dc095SDavid du Colombier * Type 42 - the destination and source must have compatible tables 91*593dc095SDavid du Colombier * other than glyf and loca. In practice this means that the source 92*593dc095SDavid du Colombier * must be the same font that was passed to gs_copy_font. If glyph is 93*593dc095SDavid du Colombier * an integer, it is interpreted as a GID; if glyph is a name, both 94*593dc095SDavid du Colombier * the CharString entry and the glyph data are copied. 95*593dc095SDavid du Colombier * 96*593dc095SDavid du Colombier * CIDFontType 0 - the destination and source must have the same Subrs, 97*593dc095SDavid du Colombier * and the Type 1/2 subfont(s) referenced by the glyph(s) being copied 98*593dc095SDavid du Colombier * must be compatible. glyph must be a CID. Copies the CharString. 99*593dc095SDavid du Colombier * 100*593dc095SDavid du Colombier * CIDFontType 2 - compatibility is as for Type 42. glyph must be a 101*593dc095SDavid du Colombier * CID (integer), not a GID. Copies the glyph data and the CIDMap 102*593dc095SDavid du Colombier * entry. 103*593dc095SDavid du Colombier * 104*593dc095SDavid du Colombier * Metrics[2] and CDevProc in the source font are ignored. Currently, 105*593dc095SDavid du Colombier * for CIDFontType 2 fonts with MetricsCount != 0, the metrics attached to 106*593dc095SDavid du Colombier * the individual glyph outlines are also ignored (not copied). 107*593dc095SDavid du Colombier */ 108*593dc095SDavid du Colombier int gs_copy_glyph(gs_font *font, gs_glyph glyph, gs_font *copied); 109*593dc095SDavid du Colombier 110*593dc095SDavid du Colombier /* 111*593dc095SDavid du Colombier * Copy a glyph with additional checking options. If options includes 112*593dc095SDavid du Colombier * COPY_GLYPH_NO_OLD, then if the top-level glyph has already been copied, 113*593dc095SDavid du Colombier * return an invalidaccess error rather than 1. If options includes 114*593dc095SDavid du Colombier * COPY_GLYPH_NO_NEW, then if the top-level glyph has *not* already been 115*593dc095SDavid du Colombier * copied, return an undefined error rather than 0. 116*593dc095SDavid du Colombier */ 117*593dc095SDavid du Colombier #define COPY_GLYPH_NO_OLD 1 118*593dc095SDavid du Colombier #define COPY_GLYPH_NO_NEW 2 119*593dc095SDavid du Colombier #define COPY_GLYPH_BY_INDEX 4 120*593dc095SDavid du Colombier int gs_copy_glyph_options(gs_font *font, gs_glyph glyph, gs_font *copied, 121*593dc095SDavid du Colombier int options); 122*593dc095SDavid du Colombier 123*593dc095SDavid du Colombier /* 124*593dc095SDavid du Colombier * Add an encoding entry to a copied font. If the given encoding entry is 125*593dc095SDavid du Colombier * not empty and is not the same as the new value, gs_copied_font_encode 126*593dc095SDavid du Colombier * returns an invalidaccess error. 127*593dc095SDavid du Colombier * 128*593dc095SDavid du Colombier * The action depends on FontType as follows: 129*593dc095SDavid du Colombier * 130*593dc095SDavid du Colombier * Type 1, Type 2 - glyph must be a name, not a CID (integer). Makes 131*593dc095SDavid du Colombier * an entry in the font's Encoding. A glyph by that name must exist 132*593dc095SDavid du Colombier * in the copied font. 133*593dc095SDavid du Colombier * 134*593dc095SDavid du Colombier * Type 42 - same as Type 1. 135*593dc095SDavid du Colombier * 136*593dc095SDavid du Colombier * CIDFontType 0 - gives an error. 137*593dc095SDavid du Colombier * 138*593dc095SDavid du Colombier * CIDFontType 2 - gives an error. 139*593dc095SDavid du Colombier */ 140*593dc095SDavid du Colombier int gs_copied_font_add_encoding(gs_font *copied, gs_char chr, gs_glyph glyph); 141*593dc095SDavid du Colombier 142*593dc095SDavid du Colombier /* 143*593dc095SDavid du Colombier * Copy all the glyphs and, if relevant, Encoding entries from a font. This 144*593dc095SDavid du Colombier * is equivalent to copying the glyphs and Encoding entries individually, 145*593dc095SDavid du Colombier * and returns errors under the same conditions. 146*593dc095SDavid du Colombier */ 147*593dc095SDavid du Colombier int gs_copy_font_complete(gs_font *font, gs_font *copied); 148*593dc095SDavid du Colombier 149*593dc095SDavid du Colombier 150*593dc095SDavid du Colombier /* 151*593dc095SDavid du Colombier * Check whether specified glyphs can be copied from another font. 152*593dc095SDavid du Colombier * It means that (1) fonts have same hinting parameters and 153*593dc095SDavid du Colombier * (2) font subsets for the specified glyph set don't include different 154*593dc095SDavid du Colombier * outlines or metrics. Possible returned values : 155*593dc095SDavid du Colombier * 0 (incompatible), 1 (compatible), < 0 (error) 156*593dc095SDavid du Colombier */ 157*593dc095SDavid du Colombier int gs_copied_can_copy_glyphs(const gs_font *cfont, const gs_font *ofont, 158*593dc095SDavid du Colombier gs_glyph *glyphs, int num_glyphs, int glyphs_step, 159*593dc095SDavid du Colombier bool check_hinting); 160*593dc095SDavid du Colombier 161*593dc095SDavid du Colombier /* Extension glyphs may be added to a font to resolve 162*593dc095SDavid du Colombier glyph name conflicts while conwerting a PDF Widths into Metrics. 163*593dc095SDavid du Colombier This function drops them before writing out an embedded font. */ 164*593dc095SDavid du Colombier int copied_drop_extension_glyphs(gs_font *cfont); 165*593dc095SDavid du Colombier 166*593dc095SDavid du Colombier 167*593dc095SDavid du Colombier #endif /* gxfcopy_INCLUDED */ 168