gxfont42.h 5.3 KB

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