ftsnames.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /****************************************************************************
  2. *
  3. * ftsnames.h
  4. *
  5. * Simple interface to access SFNT 'name' tables (which are used
  6. * to hold font names, copyright info, notices, etc.) (specification).
  7. *
  8. * This is _not_ used to retrieve glyph names!
  9. *
  10. * Copyright (C) 1996-2023 by
  11. * David Turner, Robert Wilhelm, and Werner Lemberg.
  12. *
  13. * This file is part of the FreeType project, and may only be used,
  14. * modified, and distributed under the terms of the FreeType project
  15. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  16. * this file you indicate that you have read the license and
  17. * understand and accept it fully.
  18. *
  19. */
  20. #ifndef FTSNAMES_H_
  21. #define FTSNAMES_H_
  22. #include <freetype/freetype.h>
  23. #include <freetype/ftparams.h>
  24. #ifdef FREETYPE_H
  25. #error "freetype.h of FreeType 1 has been loaded!"
  26. #error "Please fix the directory search order for header files"
  27. #error "so that freetype.h of FreeType 2 is found first."
  28. #endif
  29. FT_BEGIN_HEADER
  30. /**************************************************************************
  31. *
  32. * @section:
  33. * sfnt_names
  34. *
  35. * @title:
  36. * SFNT Names
  37. *
  38. * @abstract:
  39. * Access the names embedded in TrueType and OpenType files.
  40. *
  41. * @description:
  42. * The TrueType and OpenType specifications allow the inclusion of a
  43. * special names table ('name') in font files. This table contains
  44. * textual (and internationalized) information regarding the font, like
  45. * family name, copyright, version, etc.
  46. *
  47. * The definitions below are used to access them if available.
  48. *
  49. * Note that this has nothing to do with glyph names!
  50. *
  51. */
  52. /**************************************************************************
  53. *
  54. * @struct:
  55. * FT_SfntName
  56. *
  57. * @description:
  58. * A structure used to model an SFNT 'name' table entry.
  59. *
  60. * @fields:
  61. * platform_id ::
  62. * The platform ID for `string`. See @TT_PLATFORM_XXX for possible
  63. * values.
  64. *
  65. * encoding_id ::
  66. * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX,
  67. * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible
  68. * values.
  69. *
  70. * language_id ::
  71. * The language ID for `string`. See @TT_MAC_LANGID_XXX and
  72. * @TT_MS_LANGID_XXX for possible values.
  73. *
  74. * Registered OpenType values for `language_id` are always smaller than
  75. * 0x8000; values equal or larger than 0x8000 usually indicate a
  76. * language tag string (introduced in OpenType version 1.6). Use
  77. * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to
  78. * retrieve the associated language tag.
  79. *
  80. * name_id ::
  81. * An identifier for `string`. See @TT_NAME_ID_XXX for possible
  82. * values.
  83. *
  84. * string ::
  85. * The 'name' string. Note that its format differs depending on the
  86. * (platform,encoding) pair, being either a string of bytes (without a
  87. * terminating `NULL` byte) or containing UTF-16BE entities.
  88. *
  89. * string_len ::
  90. * The length of `string` in bytes.
  91. *
  92. * @note:
  93. * Please refer to the TrueType or OpenType specification for more
  94. * details.
  95. */
  96. typedef struct FT_SfntName_
  97. {
  98. FT_UShort platform_id;
  99. FT_UShort encoding_id;
  100. FT_UShort language_id;
  101. FT_UShort name_id;
  102. FT_Byte* string; /* this string is *not* null-terminated! */
  103. FT_UInt string_len; /* in bytes */
  104. } FT_SfntName;
  105. /**************************************************************************
  106. *
  107. * @function:
  108. * FT_Get_Sfnt_Name_Count
  109. *
  110. * @description:
  111. * Retrieve the number of name strings in the SFNT 'name' table.
  112. *
  113. * @input:
  114. * face ::
  115. * A handle to the source face.
  116. *
  117. * @return:
  118. * The number of strings in the 'name' table.
  119. *
  120. * @note:
  121. * This function always returns an error if the config macro
  122. * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
  123. */
  124. FT_EXPORT( FT_UInt )
  125. FT_Get_Sfnt_Name_Count( FT_Face face );
  126. /**************************************************************************
  127. *
  128. * @function:
  129. * FT_Get_Sfnt_Name
  130. *
  131. * @description:
  132. * Retrieve a string of the SFNT 'name' table for a given index.
  133. *
  134. * @input:
  135. * face ::
  136. * A handle to the source face.
  137. *
  138. * idx ::
  139. * The index of the 'name' string.
  140. *
  141. * @output:
  142. * aname ::
  143. * The indexed @FT_SfntName structure.
  144. *
  145. * @return:
  146. * FreeType error code. 0~means success.
  147. *
  148. * @note:
  149. * The `string` array returned in the `aname` structure is not
  150. * null-terminated. Note that you don't have to deallocate `string` by
  151. * yourself; FreeType takes care of it if you call @FT_Done_Face.
  152. *
  153. * Use @FT_Get_Sfnt_Name_Count to get the total number of available
  154. * 'name' table entries, then do a loop until you get the right platform,
  155. * encoding, and name ID.
  156. *
  157. * 'name' table format~1 entries can use language tags also, see
  158. * @FT_Get_Sfnt_LangTag.
  159. *
  160. * This function always returns an error if the config macro
  161. * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
  162. */
  163. FT_EXPORT( FT_Error )
  164. FT_Get_Sfnt_Name( FT_Face face,
  165. FT_UInt idx,
  166. FT_SfntName *aname );
  167. /**************************************************************************
  168. *
  169. * @struct:
  170. * FT_SfntLangTag
  171. *
  172. * @description:
  173. * A structure to model a language tag entry from an SFNT 'name' table.
  174. *
  175. * @fields:
  176. * string ::
  177. * The language tag string, encoded in UTF-16BE (without trailing
  178. * `NULL` bytes).
  179. *
  180. * string_len ::
  181. * The length of `string` in **bytes**.
  182. *
  183. * @note:
  184. * Please refer to the TrueType or OpenType specification for more
  185. * details.
  186. *
  187. * @since:
  188. * 2.8
  189. */
  190. typedef struct FT_SfntLangTag_
  191. {
  192. FT_Byte* string; /* this string is *not* null-terminated! */
  193. FT_UInt string_len; /* in bytes */
  194. } FT_SfntLangTag;
  195. /**************************************************************************
  196. *
  197. * @function:
  198. * FT_Get_Sfnt_LangTag
  199. *
  200. * @description:
  201. * Retrieve the language tag associated with a language ID of an SFNT
  202. * 'name' table entry.
  203. *
  204. * @input:
  205. * face ::
  206. * A handle to the source face.
  207. *
  208. * langID ::
  209. * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a
  210. * value larger than 0x8000.
  211. *
  212. * @output:
  213. * alangTag ::
  214. * The language tag associated with the 'name' table entry's language
  215. * ID.
  216. *
  217. * @return:
  218. * FreeType error code. 0~means success.
  219. *
  220. * @note:
  221. * The `string` array returned in the `alangTag` structure is not
  222. * null-terminated. Note that you don't have to deallocate `string` by
  223. * yourself; FreeType takes care of it if you call @FT_Done_Face.
  224. *
  225. * Only 'name' table format~1 supports language tags. For format~0
  226. * tables, this function always returns FT_Err_Invalid_Table. For
  227. * invalid format~1 language ID values, FT_Err_Invalid_Argument is
  228. * returned.
  229. *
  230. * This function always returns an error if the config macro
  231. * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
  232. *
  233. * @since:
  234. * 2.8
  235. */
  236. FT_EXPORT( FT_Error )
  237. FT_Get_Sfnt_LangTag( FT_Face face,
  238. FT_UInt langID,
  239. FT_SfntLangTag *alangTag );
  240. /* */
  241. FT_END_HEADER
  242. #endif /* FTSNAMES_H_ */
  243. /* END */