gdevpdtd.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: gdevpdtd.h,v 1.5 2005/04/05 15:44:44 igor Exp $ */
  14. /* FontDescriptor structure and API for pdfwrite */
  15. #ifndef gdevpdtd_INCLUDED
  16. # define gdevpdtd_INCLUDED
  17. #include "gdevpdtx.h"
  18. #include "gdevpdtb.h"
  19. /* ================ Types and structures ================ */
  20. /*
  21. * FontDescriptors are handled as pseudo-resources. Multiple Font resources
  22. * may share a descriptor. We don't need to use reference counting to keep
  23. * track of this, since all descriptors persist until the device is closed.
  24. * The CharSet entry in the FontDescriptor for a Type 1 subset font lists
  25. * the glyphs that are included in the subset, so the FontDescriptor cannot
  26. * be written until the font has been written, but we could use an indirect
  27. * object for the CharSet and write the FontDescriptor itself early.
  28. * However, we don't think that is worthwhile, since FontDescriptors are
  29. * small objects compared to the fonts themselves, and it's simpler to keep
  30. * all the FontDescriptors until the end.
  31. *
  32. * Note that FontDescriptors and BaseFonts correspond 1-to-1. While the PDF
  33. * specification allows multiple FontDescriptors for a single BaseFont, this
  34. * has no value: all the information in the FontDescriptor is derived from
  35. * the BaseFont, so all the FontDescriptors for the same BaseFont must be
  36. * the same.
  37. */
  38. /*
  39. * Font names in PDF files have caused an enormous amount of trouble, so we
  40. * document specifically how they are handled in each structure.
  41. *
  42. * The PDF Reference says that the FontName in a font descriptor must be
  43. * the same as the BaseFont in the font or CIDFont resource(s) that
  44. * reference(s) it.
  45. *
  46. * We never create a font descriptor without also creating a font resource
  47. * that references it, so we set the FontName at the same time as the
  48. * BaseFont of the font resource. For more information, see gdevpdtf.h.
  49. */
  50. #ifndef pdf_font_descriptor_DEFINED
  51. # define pdf_font_descriptor_DEFINED
  52. typedef struct pdf_font_descriptor_s pdf_font_descriptor_t;
  53. #endif
  54. /* ================ Procedures ================ */
  55. /*
  56. * Allocate a FontDescriptor, initializing the FontType and rid from the
  57. * gs_font.
  58. */
  59. int pdf_font_descriptor_alloc(gx_device_pdf *pdev,
  60. pdf_font_descriptor_t **ppfd,
  61. gs_font_base *font, bool embed);
  62. /*
  63. * Get the object ID of a FontDescriptor.
  64. */
  65. long pdf_font_descriptor_id(const pdf_font_descriptor_t *pfd);
  66. /*
  67. * Get the FontType of a FontDescriptor.
  68. */
  69. font_type pdf_font_descriptor_FontType(const pdf_font_descriptor_t *pfd);
  70. /*
  71. * Get the embedding status of a FontDescriptor.
  72. */
  73. bool pdf_font_descriptor_embedding(const pdf_font_descriptor_t *pfd);
  74. /*
  75. * Check for subset font.
  76. */
  77. bool pdf_font_descriptor_is_subset(const pdf_font_descriptor_t *pfd);
  78. /*
  79. * Return a reference to the FontName of a FontDescriptor, similar to
  80. * pdf_base_font_name.
  81. */
  82. gs_string *pdf_font_descriptor_name(pdf_font_descriptor_t *pfd);
  83. /*
  84. * Return the (copied, subset or complete) font associated with a FontDescriptor.
  85. * This procedure probably shouldn't exist....
  86. */
  87. gs_font_base *pdf_font_descriptor_font(const pdf_font_descriptor_t *pfd, bool complete);
  88. /*
  89. * Drop the copied complete font associated with a FontDescriptor.
  90. */
  91. void pdf_font_descriptor_drop_complete_font(const pdf_font_descriptor_t *pfd);
  92. /*
  93. * Return a reference to the name of a FontDescriptor's base font, per
  94. * pdf_base_font_name.
  95. */
  96. gs_string *pdf_font_descriptor_base_name(const pdf_font_descriptor_t *pfd);
  97. /*
  98. * Copy a glyph from a font to the stable copy. Return 0 if this is a
  99. * new glyph, 1 if it was already copied.
  100. */
  101. int pdf_font_used_glyph(pdf_font_descriptor_t *pfd, gs_glyph glyph,
  102. gs_font_base *font);
  103. /*
  104. * Compute the FontDescriptor metrics for a font.
  105. */
  106. int pdf_compute_font_descriptor(pdf_font_descriptor_t *pfd);
  107. /*
  108. * Finish a FontDescriptor by computing the metric values, and then
  109. * writing the associated embedded font if any.
  110. */
  111. int pdf_finish_FontDescriptor(gx_device_pdf *pdev,
  112. pdf_font_descriptor_t *pfd);
  113. int pdf_finish_font_descriptors(gx_device_pdf *pdev,
  114. int (*finish_proc)(gx_device_pdf *,
  115. pdf_font_descriptor_t *));
  116. /*
  117. * Write a FontDescriptor.
  118. */
  119. int pdf_write_FontDescriptor(gx_device_pdf *pdev,
  120. pdf_font_descriptor_t *pfd);
  121. /*
  122. * Release a FontDescriptor components.
  123. */
  124. int pdf_release_FontDescriptor_components(gx_device_pdf *pdev, pdf_font_descriptor_t *pfd);
  125. #endif /* gdevpdtd_INCLUDED */