1
0

gxfcopy.h 6.6 KB

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