ifont.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: ifont.h,v 1.6 2000/12/03 23:35:30 lpd Exp $ */
  16. /* Interpreter internal font representation */
  17. #ifndef ifont_INCLUDED
  18. # define ifont_INCLUDED
  19. #include "gsccode.h" /* for gs_glyph, NUM_KNOWN_ENCODINGS */
  20. #include "gsstype.h" /* for extern_st */
  21. /* The external definition of fonts is given in the PostScript manual, */
  22. /* pp. 91-93. */
  23. /* The structure given below is 'client data' from the viewpoint */
  24. /* of the library. font-type objects (t_struct/st_font, "t_fontID") */
  25. /* point directly to a gs_font. */
  26. typedef struct font_data_s {
  27. ref dict; /* font dictionary object */
  28. ref BuildChar;
  29. ref BuildGlyph;
  30. ref Encoding;
  31. ref CharStrings;
  32. union _fs {
  33. struct _f1 {
  34. ref OtherSubrs; /* from Private dictionary */
  35. ref Subrs; /* from Private dictionary */
  36. ref GlobalSubrs; /* from Private dictionary, */
  37. /* for Type 2 charstrings */
  38. } type1;
  39. struct _f42 {
  40. ref sfnts;
  41. ref CIDMap; /* for CIDFontType 2 fonts */
  42. ref GlyphDirectory;
  43. } type42;
  44. struct _fc0 {
  45. ref GlyphDirectory;
  46. ref GlyphData; /* (if preloaded) string or array of strings */
  47. ref DataSource; /* (if not preloaded) reusable stream */
  48. } cid0;
  49. } u;
  50. } font_data;
  51. /*
  52. * Even though the interpreter's part of the font data actually
  53. * consists of refs, allocating it as refs tends to create sandbars;
  54. * since it is always allocated and freed as a unit, we can treat it
  55. * as an ordinary structure.
  56. */
  57. /* st_font_data is exported for zdefault_make_font in zfont.c. */
  58. extern_st(st_font_data);
  59. #define public_st_font_data() /* in zbfont.c */\
  60. gs_public_st_ref_struct(st_font_data, font_data, "font_data")
  61. #define pfont_data(pfont) ((font_data *)((pfont)->client_data))
  62. #define pfont_dict(pfont) (&pfont_data(pfont)->dict)
  63. /* Registered encodings, for the benefit of platform fonts, `seac', */
  64. /* and compiled font initialization. */
  65. /* This is a t_array ref that points to the encodings. */
  66. #define registered_Encodings_countof NUM_KNOWN_ENCODINGS
  67. extern ref registered_Encodings;
  68. #define registered_Encoding(i) (registered_Encodings.value.refs[i])
  69. #define StandardEncoding registered_Encoding(0)
  70. /* ================Internal procedures shared across files ================ */
  71. /* ---------------- Exported by zchar.c ---------------- */
  72. /*
  73. * Get the FontBBox from a font dictionary, if any; if none, or if invalid,
  74. * return 4 zeros.
  75. */
  76. int font_bbox_param(P2(const ref * pfdict, double bbox[4]));
  77. /* ---------------- Exported by zfont.c ---------------- */
  78. #ifndef gs_font_DEFINED
  79. # define gs_font_DEFINED
  80. typedef struct gs_font_s gs_font;
  81. #endif
  82. /*
  83. * Check a parameter that should be a valid font dictionary, and return
  84. * the gs_font stored in its FID entry.
  85. */
  86. int font_param(P2(const ref * pfdict, gs_font ** ppfont));
  87. /*
  88. * Mark a glyph as a PostScript name (if it isn't a CID) for the garbage
  89. * collector. Return true if a mark was just added. This procedure is
  90. * intended to be used as the mark_glyph procedure in the character cache.
  91. */
  92. bool zfont_mark_glyph_name(P2(gs_glyph glyph, void *ignore_data));
  93. /*
  94. * Return information about a font, including information from the FontInfo
  95. * dictionary. This procedure is intended to be used as the font_info
  96. * procedure in all PostScript fonts.
  97. */
  98. font_proc_font_info(zfont_info);
  99. #endif /* ifont_INCLUDED */