pangofc-fontmap.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. PangoLanguage *pango_fc_fontset_key_get_language (const PangoFcFontsetKey *key);
  39. const PangoFontDescription *pango_fc_fontset_key_get_description (const PangoFcFontsetKey *key);
  40. const PangoMatrix *pango_fc_fontset_key_get_matrix (const PangoFcFontsetKey *key);
  41. double pango_fc_fontset_key_get_absolute_size (const PangoFcFontsetKey *key);
  42. double pango_fc_fontset_key_get_resolution (const PangoFcFontsetKey *key);
  43. gpointer pango_fc_fontset_key_get_context_key (const PangoFcFontsetKey *key);
  44. /**
  45. * PangoFcFontKey:
  46. *
  47. * An opaque structure containing all the information needed for
  48. * loading a font with the PangoFc fontmap.
  49. *
  50. * Since: 1.24
  51. **/
  52. typedef struct _PangoFcFontKey PangoFcFontKey;
  53. const FcPattern *pango_fc_font_key_get_pattern (const PangoFcFontKey *key);
  54. const PangoMatrix *pango_fc_font_key_get_matrix (const PangoFcFontKey *key);
  55. gpointer pango_fc_font_key_get_context_key (const PangoFcFontKey *key);
  56. #endif
  57. /*
  58. * PangoFcFontMap
  59. */
  60. #define PANGO_TYPE_FC_FONT_MAP (pango_fc_font_map_get_type ())
  61. #define PANGO_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMap))
  62. #define PANGO_IS_FC_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FC_FONT_MAP))
  63. typedef struct _PangoFcFontMap PangoFcFontMap;
  64. typedef struct _PangoFcFontMapClass PangoFcFontMapClass;
  65. typedef struct _PangoFcFontMapPrivate PangoFcFontMapPrivate;
  66. #ifdef PANGO_ENABLE_BACKEND
  67. #define PANGO_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
  68. #define PANGO_IS_FC_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FC_FONT_MAP))
  69. #define PANGO_FC_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FC_FONT_MAP, PangoFcFontMapClass))
  70. /**
  71. * PangoFcFontMap:
  72. *
  73. * #PangoFcFontMap is a base class for font map implementations
  74. * using the Fontconfig and FreeType libraries. To create a new
  75. * backend using Fontconfig and FreeType, you derive from this class
  76. * and implement a new_font() virtual function that creates an
  77. * instance deriving from #PangoFcFont.
  78. **/
  79. struct _PangoFcFontMap
  80. {
  81. PangoFontMap parent_instance;
  82. PangoFcFontMapPrivate *priv;
  83. };
  84. /**
  85. * PangoFcFontMapClass:
  86. * @default_substitute: (nullable): Substitutes in default
  87. * values for unspecified fields in a #FcPattern. This will
  88. * be called prior to creating a font for the pattern. May be
  89. * %NULL. Deprecated in favor of @font_key_substitute().
  90. * @new_font: Creates a new #PangoFcFont for the specified
  91. * pattern of the appropriate type for this font map. The
  92. * @pattern argument must be passed to the "pattern" property
  93. * of #PangoFcFont when you call g_object_new(). Deprecated
  94. * in favor of @create_font().
  95. * @get_resolution: Gets the resolution (the scale factor
  96. * between logical and absolute font sizes) that the backend
  97. * will use for a particular fontmap and context. @context
  98. * may be null.
  99. * @context_key_get: Gets an opaque key holding backend
  100. * specific options for the context that will affect
  101. * fonts created by @create_font(). The result must point to
  102. * persistant storage owned by the fontmap. This key
  103. * is used to index hash tables used to look up fontsets
  104. * and fonts.
  105. * @context_key_copy: Copies a context key. Pango uses this
  106. * to make a persistant copy of the value returned from
  107. * @context_key_get.
  108. * @context_key_free: Frees a context key copied with
  109. * @context_key_copy.
  110. * @context_key_hash: Gets a hash value for a context key
  111. * @context_key_equal: Compares two context keys for equality.
  112. * @fontset_key_substitute: (nullable): Substitutes in
  113. * default values for unspecified fields in a
  114. * #FcPattern. This will be called prior to creating a font
  115. * for the pattern. May be %NULL. (Since: 1.24)
  116. * @create_font: (nullable): Creates a new #PangoFcFont for
  117. * the specified pattern of the appropriate type for this
  118. * font map using information from the font key that is
  119. * passed in. The @pattern member of @font_key can be
  120. * retrieved using pango_fc_font_key_get_pattern() and must
  121. * be passed to the "pattern" property of #PangoFcFont when
  122. * you call g_object_new(). If %NULL, new_font() is used.
  123. * (Since: 1.24)
  124. *
  125. * Class structure for #PangoFcFontMap.
  126. **/
  127. struct _PangoFcFontMapClass
  128. {
  129. /*< private >*/
  130. PangoFontMapClass parent_class;
  131. /*< public >*/
  132. /* Deprecated in favor of fontset_key_substitute */
  133. void (*default_substitute) (PangoFcFontMap *fontmap,
  134. FcPattern *pattern);
  135. /* Deprecated in favor of create_font */
  136. PangoFcFont *(*new_font) (PangoFcFontMap *fontmap,
  137. FcPattern *pattern);
  138. double (*get_resolution) (PangoFcFontMap *fcfontmap,
  139. PangoContext *context);
  140. gconstpointer (*context_key_get) (PangoFcFontMap *fcfontmap,
  141. PangoContext *context);
  142. gpointer (*context_key_copy) (PangoFcFontMap *fcfontmap,
  143. gconstpointer key);
  144. void (*context_key_free) (PangoFcFontMap *fcfontmap,
  145. gpointer key);
  146. guint32 (*context_key_hash) (PangoFcFontMap *fcfontmap,
  147. gconstpointer key);
  148. gboolean (*context_key_equal) (PangoFcFontMap *fcfontmap,
  149. gconstpointer key_a,
  150. gconstpointer key_b);
  151. void (*fontset_key_substitute)(PangoFcFontMap *fontmap,
  152. PangoFcFontsetKey *fontsetkey,
  153. FcPattern *pattern);
  154. PangoFcFont *(*create_font) (PangoFcFontMap *fontmap,
  155. PangoFcFontKey *fontkey);
  156. /*< private >*/
  157. /* Padding for future expansion */
  158. void (*_pango_reserved1) (void);
  159. void (*_pango_reserved2) (void);
  160. void (*_pango_reserved3) (void);
  161. void (*_pango_reserved4) (void);
  162. };
  163. #ifndef PANGO_DISABLE_DEPRECATED
  164. G_DEPRECATED_FOR(pango_font_map_create_context)
  165. PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
  166. #endif
  167. void pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap);
  168. #endif
  169. GType pango_fc_font_map_get_type (void) G_GNUC_CONST;
  170. void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap);
  171. void
  172. pango_fc_font_map_config_changed (PangoFcFontMap *fcfontmap);
  173. void
  174. pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap,
  175. FcConfig *fcconfig);
  176. FcConfig *
  177. pango_fc_font_map_get_config (PangoFcFontMap *fcfontmap);
  178. /**
  179. * PangoFcDecoderFindFunc:
  180. * @pattern: a fully resolved #FcPattern specifying the font on the system
  181. * @user_data: user data passed to pango_fc_font_map_add_decoder_find_func()
  182. *
  183. * Callback function passed to pango_fc_font_map_add_decoder_find_func().
  184. *
  185. * Return value: a new reference to a custom decoder for this pattern,
  186. * or %NULL if the default decoder handling should be used.
  187. **/
  188. typedef PangoFcDecoder * (*PangoFcDecoderFindFunc) (FcPattern *pattern,
  189. gpointer user_data);
  190. void pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap,
  191. PangoFcDecoderFindFunc findfunc,
  192. gpointer user_data,
  193. GDestroyNotify dnotify);
  194. PangoFcDecoder *pango_fc_font_map_find_decoder (PangoFcFontMap *fcfontmap,
  195. FcPattern *pattern);
  196. PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern,
  197. gboolean include_size);
  198. /**
  199. * PANGO_FC_GRAVITY:
  200. *
  201. * String representing a fontconfig property name that Pango sets on any
  202. * fontconfig pattern it passes to fontconfig if a #PangoGravity other
  203. * than %PANGO_GRAVITY_SOUTH is desired.
  204. *
  205. * The property will have a #PangoGravity value as a string, like "east".
  206. * This can be used to write fontconfig configuration rules to choose
  207. * different fonts for horizontal and vertical writing directions.
  208. *
  209. * Since: 1.20
  210. */
  211. #define PANGO_FC_GRAVITY "pangogravity"
  212. /**
  213. * PANGO_FC_VERSION:
  214. *
  215. * String representing a fontconfig property name that Pango sets on any
  216. * fontconfig pattern it passes to fontconfig.
  217. *
  218. * The property will have an integer value equal to what
  219. * pango_version() returns.
  220. * This can be used to write fontconfig configuration rules that only affect
  221. * certain pango versions (or only pango-using applications, or only
  222. * non-pango-using applications).
  223. *
  224. * Since: 1.20
  225. */
  226. #define PANGO_FC_VERSION "pangoversion"
  227. /**
  228. * PANGO_FC_PRGNAME:
  229. *
  230. * String representing a fontconfig property name that Pango sets on any
  231. * fontconfig pattern it passes to fontconfig.
  232. *
  233. * The property will have a string equal to what
  234. * g_get_prgname() returns.
  235. * This can be used to write fontconfig configuration rules that only affect
  236. * certain applications.
  237. *
  238. * This is equivalent to FC_PRGNAME in versions of fontconfig that have that.
  239. *
  240. * Since: 1.24
  241. */
  242. #define PANGO_FC_PRGNAME "prgname"
  243. /**
  244. * PANGO_FC_FONT_FEATURES:
  245. *
  246. * String representing a fontconfig property name that Pango reads from font
  247. * patterns to populate list of OpenType features to be enabled for the font
  248. * by default.
  249. *
  250. * The property will have a number of string elements, each of which is the
  251. * OpenType feature tag of one feature to enable.
  252. *
  253. * This is equivalent to FC_FONT_FEATURES in versions of fontconfig that have that.
  254. *
  255. * Since: 1.34
  256. */
  257. #define PANGO_FC_FONT_FEATURES "fontfeatures"
  258. G_END_DECLS
  259. #endif /* __PANGO_FC_FONT_MAP_H__ */