您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

271 行
9.9 KiB

  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 <fontconfig/fontconfig.h>
  24. #include <pango/pango-fontmap.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: Substitutes in default values for
  87. * unspecified fields in a #FcPattern. This will be called
  88. * prior to creating a font for the pattern. May be %NULL.
  89. * 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: Substitutes in default values for
  113. * unspecified fields in a #FcPattern. This will be called
  114. * prior to creating a font for the pattern. May be %NULL.
  115. * (Since: 1.24)
  116. * @create_font: Creates a new #PangoFcFont for the specified
  117. * pattern of the appropriate type for this font map using
  118. * information from the font key that is passed in. The
  119. * @pattern member of @font_key can be retrieved using
  120. * pango_fc_font_key_get_pattern() and must be passed to
  121. * the "pattern" property of #PangoFcFont when you call
  122. * 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. PangoContext * pango_fc_font_map_create_context (PangoFcFontMap *fcfontmap);
  165. #endif
  166. void pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap);
  167. #endif
  168. GType pango_fc_font_map_get_type (void) G_GNUC_CONST;
  169. void pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap);
  170. /**
  171. * PangoFcDecoderFindFunc:
  172. * @pattern: a fully resolved #FcPattern specifying the font on the system
  173. * @user_data: user data passed to pango_fc_font_map_add_decoder_find_func()
  174. *
  175. * Callback function passed to pango_fc_font_map_add_decoder_find_func().
  176. *
  177. * Return value: a new reference to a custom decoder for this pattern,
  178. * or %NULL if the default decoder handling should be used.
  179. **/
  180. typedef PangoFcDecoder * (*PangoFcDecoderFindFunc) (FcPattern *pattern,
  181. gpointer user_data);
  182. void pango_fc_font_map_add_decoder_find_func (PangoFcFontMap *fcfontmap,
  183. PangoFcDecoderFindFunc findfunc,
  184. gpointer user_data,
  185. GDestroyNotify dnotify);
  186. PangoFcDecoder *pango_fc_font_map_find_decoder (PangoFcFontMap *fcfontmap,
  187. FcPattern *pattern);
  188. PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern,
  189. gboolean include_size);
  190. /**
  191. * PANGO_FC_GRAVITY:
  192. *
  193. * String representing a fontconfig property name that Pango sets on any
  194. * fontconfig pattern it passes to fontconfig if a #PangoGravity other
  195. * than %PangoGravitySouth is desired.
  196. *
  197. * The property will have a #PangoGravity value as a string, like "east".
  198. * This can be used to write fontconfig configuration rules to choose
  199. * different fonts for horizontal and vertical writing directions.
  200. *
  201. * Since: 1.20
  202. */
  203. #define PANGO_FC_GRAVITY "pangogravity"
  204. /**
  205. * PANGO_FC_VERSION:
  206. *
  207. * String representing a fontconfig property name that Pango sets on any
  208. * fontconfig pattern it passes to fontconfig.
  209. *
  210. * The property will have an integer value equal to what
  211. * pango_version() returns.
  212. * This can be used to write fontconfig configuration rules that only affect
  213. * certain pango versions (or only pango-using applications, or only
  214. * non-pango-using applications).
  215. *
  216. * Since: 1.20
  217. */
  218. #define PANGO_FC_VERSION "pangoversion"
  219. /**
  220. * PANGO_FC_PRGNAME:
  221. *
  222. * String representing a fontconfig property name that Pango sets on any
  223. * fontconfig pattern it passes to fontconfig.
  224. *
  225. * The property will have a string equal to what
  226. * g_get_prgname() returns.
  227. * This can be used to write fontconfig configuration rules that only affect
  228. * certain applications.
  229. *
  230. * Since: 1.24
  231. */
  232. #define PANGO_FC_PRGNAME "pangoprgname"
  233. G_END_DECLS
  234. #endif /* __PANGO_FC_FONT_MAP_H__ */