ftbdf.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /****************************************************************************
  2. *
  3. * ftbdf.h
  4. *
  5. * FreeType API for accessing BDF-specific strings (specification).
  6. *
  7. * Copyright (C) 2002-2023 by
  8. * David Turner, Robert Wilhelm, and Werner Lemberg.
  9. *
  10. * This file is part of the FreeType project, and may only be used,
  11. * modified, and distributed under the terms of the FreeType project
  12. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  13. * this file you indicate that you have read the license and
  14. * understand and accept it fully.
  15. *
  16. */
  17. #ifndef FTBDF_H_
  18. #define FTBDF_H_
  19. #include <freetype/freetype.h>
  20. #ifdef FREETYPE_H
  21. #error "freetype.h of FreeType 1 has been loaded!"
  22. #error "Please fix the directory search order for header files"
  23. #error "so that freetype.h of FreeType 2 is found first."
  24. #endif
  25. FT_BEGIN_HEADER
  26. /**************************************************************************
  27. *
  28. * @section:
  29. * bdf_fonts
  30. *
  31. * @title:
  32. * BDF and PCF Files
  33. *
  34. * @abstract:
  35. * BDF and PCF specific API.
  36. *
  37. * @description:
  38. * This section contains the declaration of functions specific to BDF and
  39. * PCF fonts.
  40. *
  41. */
  42. /**************************************************************************
  43. *
  44. * @enum:
  45. * BDF_PropertyType
  46. *
  47. * @description:
  48. * A list of BDF property types.
  49. *
  50. * @values:
  51. * BDF_PROPERTY_TYPE_NONE ::
  52. * Value~0 is used to indicate a missing property.
  53. *
  54. * BDF_PROPERTY_TYPE_ATOM ::
  55. * Property is a string atom.
  56. *
  57. * BDF_PROPERTY_TYPE_INTEGER ::
  58. * Property is a 32-bit signed integer.
  59. *
  60. * BDF_PROPERTY_TYPE_CARDINAL ::
  61. * Property is a 32-bit unsigned integer.
  62. */
  63. typedef enum BDF_PropertyType_
  64. {
  65. BDF_PROPERTY_TYPE_NONE = 0,
  66. BDF_PROPERTY_TYPE_ATOM = 1,
  67. BDF_PROPERTY_TYPE_INTEGER = 2,
  68. BDF_PROPERTY_TYPE_CARDINAL = 3
  69. } BDF_PropertyType;
  70. /**************************************************************************
  71. *
  72. * @type:
  73. * BDF_Property
  74. *
  75. * @description:
  76. * A handle to a @BDF_PropertyRec structure to model a given BDF/PCF
  77. * property.
  78. */
  79. typedef struct BDF_PropertyRec_* BDF_Property;
  80. /**************************************************************************
  81. *
  82. * @struct:
  83. * BDF_PropertyRec
  84. *
  85. * @description:
  86. * This structure models a given BDF/PCF property.
  87. *
  88. * @fields:
  89. * type ::
  90. * The property type.
  91. *
  92. * u.atom ::
  93. * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be
  94. * `NULL`, indicating an empty string.
  95. *
  96. * u.integer ::
  97. * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER.
  98. *
  99. * u.cardinal ::
  100. * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL.
  101. */
  102. typedef struct BDF_PropertyRec_
  103. {
  104. BDF_PropertyType type;
  105. union {
  106. const char* atom;
  107. FT_Int32 integer;
  108. FT_UInt32 cardinal;
  109. } u;
  110. } BDF_PropertyRec;
  111. /**************************************************************************
  112. *
  113. * @function:
  114. * FT_Get_BDF_Charset_ID
  115. *
  116. * @description:
  117. * Retrieve a BDF font character set identity, according to the BDF
  118. * specification.
  119. *
  120. * @input:
  121. * face ::
  122. * A handle to the input face.
  123. *
  124. * @output:
  125. * acharset_encoding ::
  126. * Charset encoding, as a C~string, owned by the face.
  127. *
  128. * acharset_registry ::
  129. * Charset registry, as a C~string, owned by the face.
  130. *
  131. * @return:
  132. * FreeType error code. 0~means success.
  133. *
  134. * @note:
  135. * This function only works with BDF faces, returning an error otherwise.
  136. */
  137. FT_EXPORT( FT_Error )
  138. FT_Get_BDF_Charset_ID( FT_Face face,
  139. const char* *acharset_encoding,
  140. const char* *acharset_registry );
  141. /**************************************************************************
  142. *
  143. * @function:
  144. * FT_Get_BDF_Property
  145. *
  146. * @description:
  147. * Retrieve a BDF property from a BDF or PCF font file.
  148. *
  149. * @input:
  150. * face ::
  151. * A handle to the input face.
  152. *
  153. * name ::
  154. * The property name.
  155. *
  156. * @output:
  157. * aproperty ::
  158. * The property.
  159. *
  160. * @return:
  161. * FreeType error code. 0~means success.
  162. *
  163. * @note:
  164. * This function works with BDF _and_ PCF fonts. It returns an error
  165. * otherwise. It also returns an error if the property is not in the
  166. * font.
  167. *
  168. * A 'property' is a either key-value pair within the STARTPROPERTIES
  169. * ... ENDPROPERTIES block of a BDF font or a key-value pair from the
  170. * `info->props` array within a `FontRec` structure of a PCF font.
  171. *
  172. * Integer properties are always stored as 'signed' within PCF fonts;
  173. * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value
  174. * for BDF fonts only.
  175. *
  176. * In case of error, `aproperty->type` is always set to
  177. * @BDF_PROPERTY_TYPE_NONE.
  178. */
  179. FT_EXPORT( FT_Error )
  180. FT_Get_BDF_Property( FT_Face face,
  181. const char* prop_name,
  182. BDF_PropertyRec *aproperty );
  183. /* */
  184. FT_END_HEADER
  185. #endif /* FTBDF_H_ */
  186. /* END */