pangofc-fontmap.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /* Pango
  2. * pangofc-fontmap.h: Base fontmap type for fontconfig-based backends
  3. *
  4. * Copyright (C) 2003 Red Hat Software
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __PANGO_FC_FONT_MAP_H__
  22. #define __PANGO_FC_FONT_MAP_H__
  23. #include <pango/pango.h>
  24. #include <fontconfig/fontconfig.h>
  25. #include <pango/pangofc-decoder.h>
  26. #include <pango/pangofc-font.h>
  27. G_BEGIN_DECLS
  28. #ifdef PANGO_ENABLE_BACKEND
  29. /**
  30. * PangoFcFontsetKey:
  31. *
  32. * An opaque structure containing all the information needed for
  33. * loading a fontset with the PangoFc fontmap.
  34. *
  35. * Since: 1.24
  36. **/
  37. typedef struct _PangoFcFontsetKey PangoFcFontsetKey;
  38. PANGO_AVAILABLE_IN_1_24
  39. PangoLanguage *pango_fc_fontset_key_get_language (const PangoFcFontsetKey *key);
  40. PANGO_AVAILABLE_IN_1_24
  41. const PangoFontDescription *pango_fc_fontset_key_get_description (const PangoFcFontsetKey *key);
  42. PANGO_AVAILABLE_IN_1_24
  43. const PangoMatrix *pango_fc_fontset_key_get_matrix (const PangoFcFontsetKey *key);
  44. PANGO_AVAILABLE_IN_1_24
  45. double pango_fc_fontset_key_get_absolute_size (const PangoFcFontsetKey *key);
  46. PANGO_AVAILABLE_IN_1_24
  47. double pango_fc_fontset_key_get_resolution (const PangoFcFontsetKey *key);
  48. PANGO_AVAILABLE_IN_1_24
  49. gpointer pango_fc_fontset_key_get_context_key (const PangoFcFontsetKey *key);
  50. /**
  51. * PangoFcFontKey:
  52. *
  53. * An opaque structure containing all the information needed for
  54. * loading a font with the PangoFc fontmap.
  55. *
  56. * Since: 1.24
  57. **/
  58. typedef struct _PangoFcFontKey PangoFcFontKey;
  59. PANGO_AVAILABLE_IN_1_24
  60. const FcPattern *pango_fc_font_key_get_pattern (const PangoFcFontKey *key);
  61. PANGO_AVAILABLE_IN_1_24
  62. const PangoMatrix *pango_fc_font_key_get_matrix (const PangoFcFontKey *key);
  63. PANGO_AVAILABLE_IN_1_24
  64. gpointer pango_fc_font_key_get_context_key (const PangoFcFontKey *key);
  65. PANGO_AVAILABLE_IN_1_40
  66. const char *pango_fc_font_key_get_variations (const PangoFcFontKey *key);
  67. #endif
  68. /*
  69. * PangoFcFontMap
  70. */
  71. #define PANGO_TYPE_FC_FONT_MAP (pango_fc_font_map_get_type ())
  72. #define PANGO_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMap))
  73. #define PANGO_IS_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FC_FONT_MAP))
  74. typedef struct _PangoFcFontMap PangoFcFontMap;
  75. typedef struct _PangoFcFontMapClass PangoFcFontMapClass;
  76. typedef struct _PangoFcFontMapPrivate PangoFcFontMapPrivate;
  77. #ifdef PANGO_ENABLE_BACKEND
  78. #define PANGO_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
  79. #define PANGO_IS_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FC_FONT_MAP))
  80. #define PANGO_FC_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
  81. /**
  82. * PangoFcFontMap:
  83. *
  84. * #PangoFcFontMap is a base class for font map implementations
  85. * using the Fontconfig and FreeType libraries. To create a new
  86. * backend using Fontconfig and FreeType, you derive from this class
  87. * and implement a new_font() virtual function that creates an
  88. * instance deriving from #PangoFcFont.
  89. **/
  90. struct _PangoFcFontMap
  91. {
  92. PangoFontMap parent_instance;
  93. PangoFcFontMapPrivate *priv;
  94. };
  95. /**
  96. * PangoFcFontMapClass:
  97. * @default_substitute: (nullable): Substitutes in default
  98. * values for unspecified fields in a #FcPattern. This will
  99. * be called prior to creating a font for the pattern. May be
  100. * %NULL. Deprecated in favor of @font_key_substitute().
  101. * @new_font: Creates a new #PangoFcFont for the specified
  102. * pattern of the appropriate type for this font map. The
  103. * @pattern argument must be passed to the "pattern" property
  104. * of #PangoFcFont when you call g_object_new(). Deprecated
  105. * in favor of @create_font().
  106. * @get_resolution: Gets the resolution (the scale factor
  107. * between logical and absolute font sizes) that the backend
  108. * will use for a particular fontmap and context. @context
  109. * may be null.
  110. * @context_key_get: Gets an opaque key holding backend
  111. * specific options for the context that will affect
  112. * fonts created by @create_font(). The result must point to
  113. * persistant storage owned by the fontmap. This key
  114. * is used to index hash tables used to look up fontsets
  115. * and fonts.
  116. * @context_key_copy: Copies a context key. Pango uses this
  117. * to make a persistant copy of the value returned from
  118. * @context_key_get.
  119. * @context_key_free: Frees a context key copied with
  120. * @context_key_copy.
  121. * @context_key_hash: Gets a hash value for a context key
  122. * @context_key_equal: Compares two context keys for equality.
  123. * @fontset_key_substitute: (nullable): Substitutes in
  124. * default values for unspecified fields in a
  125. * #FcPattern. This will be called prior to creating a font
  126. * for the pattern. May be %NULL. (Since: 1.24)
  127. * @create_font: (nullable): Creates a new #PangoFcFont for
  128. * the specified pattern of the appropriate type for this
  129. * font map using information from the font key that is
  130. * passed in. The @pattern member of @font_key can be
  131. * retrieved using pango_fc_font_key_get_pattern() and must
  132. * be passed to the "pattern" property of #PangoFcFont when
  133. * you call g_object_new(). If %NULL, new_font() is used.
  134. * (Since: 1.24)
  135. *
  136. * Class structure for #PangoFcFontMap.
  137. **/
  138. struct _PangoFcFontMapClass
  139. {
  140. /*< private >*/
  141. PangoFontMapClass parent_class;
  142. /*< public >*/
  143. /* Deprecated in favor of fontset_key_substitute */
  144. void (*default_substitute) (PangoFcFontMap *fontmap,
  145. FcPattern *pattern);
  146. /* Deprecated in favor of create_font */
  147. PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
  148. FcPattern *pattern);
  149. double (*get_resolution) (PangoFcFontMap *fcfontmap,
  150. PangoContext *context);
  151. gconstpointer (*context_key_get) (PangoFcFontMap *fcfontmap,
  152. PangoContext *context);
  153. gpointer (*context_key_copy) (PangoFcFontMap *fcfontmap,
  154. gconstpointer key);
  155. void (*context_key_free) (PangoFcFontMap *fcfontmap,
  156. gpointer key);
  157. guint32 (*context_key_hash) (PangoFcFontMap *fcfontmap,
  158. gconstpointer key);
  159. gboolean (*context_key_equal) (PangoFcFontMap *fcfontmap,
  160. gconstpointer key_a,
  161. gconstpointer key_b);
  162. void (*fontset_key_substitute)(PangoFcFontMap *fontmap,
  163. PangoFcFontsetKey *fontsetkey,
  164. FcPattern *pattern);
  165. PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
  166. PangoFcFontKey *fontkey);
  167. /*< private >*/
  168. /* Padding for future expansion */
  169. void (*_pango_reserved1) (void);
  170. void (*_pango_reserved2) (void);
  171. void (*_pango_reserved3) (void);
  172. void (*_pango_reserved4) (void);
  173. };
  174. #ifndef PANGO_DISABLE_DEPRECATED
  175. PANGO_DEPRECATED_IN_1_22_FOR(pango_font_map_create_context)
  176. PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
  177. #endif
  178. PANGO_AVAILABLE_IN_1_4
  179. void pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap);
  180. #endif
  181. PANGO_AVAILABLE_IN_ALL
  182. GType pango_fc_font_map_get_type (void) G_GNUC_CONST;
  183. PANGO_AVAILABLE_IN_1_4
  184. void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap);
  185. PANGO_AVAILABLE_IN_1_38
  186. void
  187. pango_fc_font_map_config_changed (PangoFcFontMap *fcfontmap);
  188. PANGO_AVAILABLE_IN_1_38
  189. void
  190. pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap,
  191. FcConfig *fcconfig);
  192. PANGO_AVAILABLE_IN_1_38
  193. FcConfig *
  194. pango_fc_font_map_get_config (PangoFcFontMap *fcfontmap);
  195. /**
  196. * PangoFcDecoderFindFunc:
  197. * @pattern: a fully resolved #FcPattern specifying the font on the system
  198. * @user_data: user data passed to pango_fc_font_map_add_decoder_find_func()
  199. *
  200. * Callback function passed to pango_fc_font_map_add_decoder_find_func().
  201. *
  202. * Return value: a new reference to a custom decoder for this pattern,
  203. * or %NULL if the default decoder handling should be used.
  204. **/
  205. typedef PangoFcDecoder * (*PangoFcDecoderFindFunc) (FcPattern *pattern,
  206. gpointer user_data);
  207. PANGO_AVAILABLE_IN_1_6
  208. void pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap,
  209. PangoFcDecoderFindFunc findfunc,
  210. gpointer user_data,
  211. GDestroyNotify dnotify);
  212. PANGO_AVAILABLE_IN_1_26
  213. PangoFcDecoder *pango_fc_font_map_find_decoder (PangoFcFontMap *fcfontmap,
  214. FcPattern *pattern);
  215. PANGO_AVAILABLE_IN_1_4
  216. PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern,
  217. gboolean include_size);
  218. /**
  219. * PANGO_FC_GRAVITY:
  220. *
  221. * String representing a fontconfig property name that Pango sets on any
  222. * fontconfig pattern it passes to fontconfig if a #PangoGravity other
  223. * than %PANGO_GRAVITY_SOUTH is desired.
  224. *
  225. * The property will have a #PangoGravity value as a string, like "east".
  226. * This can be used to write fontconfig configuration rules to choose
  227. * different fonts for horizontal and vertical writing directions.
  228. *
  229. * Since: 1.20
  230. */
  231. #define PANGO_FC_GRAVITY "pangogravity"
  232. /**
  233. * PANGO_FC_VERSION:
  234. *
  235. * String representing a fontconfig property name that Pango sets on any
  236. * fontconfig pattern it passes to fontconfig.
  237. *
  238. * The property will have an integer value equal to what
  239. * pango_version() returns.
  240. * This can be used to write fontconfig configuration rules that only affect
  241. * certain pango versions (or only pango-using applications, or only
  242. * non-pango-using applications).
  243. *
  244. * Since: 1.20
  245. */
  246. #define PANGO_FC_VERSION "pangoversion"
  247. /**
  248. * PANGO_FC_PRGNAME:
  249. *
  250. * String representing a fontconfig property name that Pango sets on any
  251. * fontconfig pattern it passes to fontconfig.
  252. *
  253. * The property will have a string equal to what
  254. * g_get_prgname() returns.
  255. * This can be used to write fontconfig configuration rules that only affect
  256. * certain applications.
  257. *
  258. * This is equivalent to FC_PRGNAME in versions of fontconfig that have that.
  259. *
  260. * Since: 1.24
  261. */
  262. #define PANGO_FC_PRGNAME "prgname"
  263. /**
  264. * PANGO_FC_FONT_FEATURES:
  265. *
  266. * String representing a fontconfig property name that Pango reads from font
  267. * patterns to populate list of OpenType features to be enabled for the font
  268. * by default.
  269. *
  270. * The property will have a number of string elements, each of which is the
  271. * OpenType feature tag of one feature to enable.
  272. *
  273. * This is equivalent to FC_FONT_FEATURES in versions of fontconfig that have that.
  274. *
  275. * Since: 1.34
  276. */
  277. #define PANGO_FC_FONT_FEATURES "fontfeatures"
  278. /**
  279. * PANGO_FC_FONT_VARIATIONS:
  280. *
  281. * String representing a fontconfig property name that Pango reads from font
  282. * patterns to populate list of OpenType font variations to be used for a font.
  283. *
  284. * The property will have a string elements, each of which a comma-separated
  285. * list of OpenType axis setting of the form AXIS=VALUE.
  286. */
  287. #define PANGO_FC_FONT_VARIATIONS "fontvariations"
  288. G_END_DECLS
  289. #endif /* __PANGO_FC_FONT_MAP_H__ */