pcf.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* pcf.h
  2. FreeType font driver for pcf fonts
  3. Copyright (C) 2000-2001, 2002 by
  4. Francesco Zappa Nardelli
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. */
  21. #ifndef __PCF_H__
  22. #define __PCF_H__
  23. #include <ft2build.h>
  24. #include FT_INTERNAL_DRIVER_H
  25. #include FT_INTERNAL_STREAM_H
  26. FT_BEGIN_HEADER
  27. typedef struct PCF_TableRec_
  28. {
  29. FT_ULong type;
  30. FT_ULong format;
  31. FT_ULong size;
  32. FT_ULong offset;
  33. } PCF_TableRec, *PCF_Table;
  34. typedef struct PCF_TocRec_
  35. {
  36. FT_ULong version;
  37. FT_ULong count;
  38. PCF_Table tables;
  39. } PCF_TocRec, *PCF_Toc;
  40. typedef struct PCF_ParsePropertyRec_
  41. {
  42. FT_Long name;
  43. FT_Byte isString;
  44. FT_Long value;
  45. } PCF_ParsePropertyRec, *PCF_ParseProperty;
  46. typedef struct PCF_PropertyRec_
  47. {
  48. FT_String* name;
  49. FT_Byte isString;
  50. union
  51. {
  52. FT_String* atom;
  53. FT_Long integer;
  54. FT_ULong cardinal;
  55. } value;
  56. } PCF_PropertyRec, *PCF_Property;
  57. typedef struct PCF_Compressed_MetricRec_
  58. {
  59. FT_Byte leftSideBearing;
  60. FT_Byte rightSideBearing;
  61. FT_Byte characterWidth;
  62. FT_Byte ascent;
  63. FT_Byte descent;
  64. } PCF_Compressed_MetricRec, *PCF_Compressed_Metric;
  65. typedef struct PCF_MetricRec_
  66. {
  67. FT_Short leftSideBearing;
  68. FT_Short rightSideBearing;
  69. FT_Short characterWidth;
  70. FT_Short ascent;
  71. FT_Short descent;
  72. FT_Short attributes;
  73. FT_ULong bits;
  74. } PCF_MetricRec, *PCF_Metric;
  75. typedef struct PCF_AccelRec_
  76. {
  77. FT_Byte noOverlap;
  78. FT_Byte constantMetrics;
  79. FT_Byte terminalFont;
  80. FT_Byte constantWidth;
  81. FT_Byte inkInside;
  82. FT_Byte inkMetrics;
  83. FT_Byte drawDirection;
  84. FT_Long fontAscent;
  85. FT_Long fontDescent;
  86. FT_Long maxOverlap;
  87. PCF_MetricRec minbounds;
  88. PCF_MetricRec maxbounds;
  89. PCF_MetricRec ink_minbounds;
  90. PCF_MetricRec ink_maxbounds;
  91. } PCF_AccelRec, *PCF_Accel;
  92. typedef struct PCD_EncodingRec_
  93. {
  94. FT_Long enc;
  95. FT_Short glyph;
  96. } PCF_EncodingRec, *PCF_Encoding;
  97. typedef struct PCF_FaceRec_
  98. {
  99. FT_FaceRec root;
  100. FT_StreamRec gzip_stream;
  101. FT_Stream gzip_source;
  102. char* charset_encoding;
  103. char* charset_registry;
  104. PCF_TocRec toc;
  105. PCF_AccelRec accel;
  106. int nprops;
  107. PCF_Property properties;
  108. FT_Long nmetrics;
  109. PCF_Metric metrics;
  110. FT_Long nencodings;
  111. PCF_Encoding encodings;
  112. FT_Short defaultChar;
  113. FT_ULong bitmapsFormat;
  114. FT_CharMap charmap_handle;
  115. FT_CharMapRec charmap; /* a single charmap per face */
  116. } PCF_FaceRec, *PCF_Face;
  117. /* macros for pcf font format */
  118. #define LSBFirst 0
  119. #define MSBFirst 1
  120. #define PCF_FILE_VERSION ( ( 'p' << 24 ) | \
  121. ( 'c' << 16 ) | \
  122. ( 'f' << 8 ) | 1 )
  123. #define PCF_FORMAT_MASK 0xFFFFFF00L
  124. #define PCF_DEFAULT_FORMAT 0x00000000L
  125. #define PCF_INKBOUNDS 0x00000200L
  126. #define PCF_ACCEL_W_INKBOUNDS 0x00000100L
  127. #define PCF_COMPRESSED_METRICS 0x00000100L
  128. #define PCF_FORMAT_MATCH( a, b ) \
  129. ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) )
  130. #define PCF_GLYPH_PAD_MASK ( 3 << 0 )
  131. #define PCF_BYTE_MASK ( 1 << 2 )
  132. #define PCF_BIT_MASK ( 1 << 3 )
  133. #define PCF_SCAN_UNIT_MASK ( 3 << 4 )
  134. #define PCF_BYTE_ORDER( f ) \
  135. ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst )
  136. #define PCF_BIT_ORDER( f ) \
  137. ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst )
  138. #define PCF_GLYPH_PAD_INDEX( f ) \
  139. ( (f) & PCF_GLYPH_PAD_MASK )
  140. #define PCF_GLYPH_PAD( f ) \
  141. ( 1 << PCF_GLYPH_PAD_INDEX( f ) )
  142. #define PCF_SCAN_UNIT_INDEX( f ) \
  143. ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 )
  144. #define PCF_SCAN_UNIT( f ) \
  145. ( 1 << PCF_SCAN_UNIT_INDEX( f ) )
  146. #define PCF_FORMAT_BITS( f ) \
  147. ( (f) & ( PCF_GLYPH_PAD_MASK | \
  148. PCF_BYTE_MASK | \
  149. PCF_BIT_MASK | \
  150. PCF_SCAN_UNIT_MASK ) )
  151. #define PCF_SIZE_TO_INDEX( s ) ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 )
  152. #define PCF_INDEX_TO_SIZE( b ) ( 1 << b )
  153. #define PCF_FORMAT( bit, byte, glyph, scan ) \
  154. ( ( PCF_SIZE_TO_INDEX( scan ) << 4 ) | \
  155. ( ( (bit) == MSBFirst ? 1 : 0 ) << 3 ) | \
  156. ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \
  157. ( PCF_SIZE_TO_INDEX( glyph ) << 0 ) )
  158. #define PCF_PROPERTIES ( 1 << 0 )
  159. #define PCF_ACCELERATORS ( 1 << 1 )
  160. #define PCF_METRICS ( 1 << 2 )
  161. #define PCF_BITMAPS ( 1 << 3 )
  162. #define PCF_INK_METRICS ( 1 << 4 )
  163. #define PCF_BDF_ENCODINGS ( 1 << 5 )
  164. #define PCF_SWIDTHS ( 1 << 6 )
  165. #define PCF_GLYPH_NAMES ( 1 << 7 )
  166. #define PCF_BDF_ACCELERATORS ( 1 << 8 )
  167. #define GLYPHPADOPTIONS 4 /* I'm not sure about this */
  168. FT_LOCAL( FT_Error )
  169. pcf_load_font( FT_Stream,
  170. PCF_Face );
  171. FT_END_HEADER
  172. #endif /* __PCF_H__ */
  173. /* END */