You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

387 lines
15 KiB

  1. /* Pango
  2. * pango-font.h: Font handling
  3. *
  4. * Copyright (C) 2000 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_FONT_H__
  22. #define __PANGO_FONT_H__
  23. #include <pango/pango-coverage.h>
  24. #include <pango/pango-types.h>
  25. #include <glib-object.h>
  26. G_BEGIN_DECLS
  27. typedef struct _PangoFontDescription PangoFontDescription;
  28. typedef struct _PangoFontMetrics PangoFontMetrics;
  29. /**
  30. * PangoStyle:
  31. * @PANGO_STYLE_NORMAL: the font is upright.
  32. * @PANGO_STYLE_OBLIQUE: the font is slanted, but in a roman style.
  33. * @PANGO_STYLE_ITALIC: the font is slanted in an italic style.
  34. *
  35. * An enumeration specifying the various slant styles possible for a font.
  36. **/
  37. typedef enum {
  38. PANGO_STYLE_NORMAL,
  39. PANGO_STYLE_OBLIQUE,
  40. PANGO_STYLE_ITALIC
  41. } PangoStyle;
  42. typedef enum {
  43. PANGO_VARIANT_NORMAL,
  44. PANGO_VARIANT_SMALL_CAPS
  45. } PangoVariant;
  46. typedef enum {
  47. PANGO_WEIGHT_THIN = 100,
  48. PANGO_WEIGHT_ULTRALIGHT = 200,
  49. PANGO_WEIGHT_LIGHT = 300,
  50. PANGO_WEIGHT_BOOK = 380,
  51. PANGO_WEIGHT_NORMAL = 400,
  52. PANGO_WEIGHT_MEDIUM = 500,
  53. PANGO_WEIGHT_SEMIBOLD = 600,
  54. PANGO_WEIGHT_BOLD = 700,
  55. PANGO_WEIGHT_ULTRABOLD = 800,
  56. PANGO_WEIGHT_HEAVY = 900,
  57. PANGO_WEIGHT_ULTRAHEAVY = 1000
  58. } PangoWeight;
  59. typedef enum {
  60. PANGO_STRETCH_ULTRA_CONDENSED,
  61. PANGO_STRETCH_EXTRA_CONDENSED,
  62. PANGO_STRETCH_CONDENSED,
  63. PANGO_STRETCH_SEMI_CONDENSED,
  64. PANGO_STRETCH_NORMAL,
  65. PANGO_STRETCH_SEMI_EXPANDED,
  66. PANGO_STRETCH_EXPANDED,
  67. PANGO_STRETCH_EXTRA_EXPANDED,
  68. PANGO_STRETCH_ULTRA_EXPANDED
  69. } PangoStretch;
  70. typedef enum {
  71. PANGO_FONT_MASK_FAMILY = 1 << 0,
  72. PANGO_FONT_MASK_STYLE = 1 << 1,
  73. PANGO_FONT_MASK_VARIANT = 1 << 2,
  74. PANGO_FONT_MASK_WEIGHT = 1 << 3,
  75. PANGO_FONT_MASK_STRETCH = 1 << 4,
  76. PANGO_FONT_MASK_SIZE = 1 << 5,
  77. PANGO_FONT_MASK_GRAVITY = 1 << 6
  78. } PangoFontMask;
  79. /* CSS scale factors (1.2 factor between each size) */
  80. #define PANGO_SCALE_XX_SMALL ((double)0.5787037037037)
  81. #define PANGO_SCALE_X_SMALL ((double)0.6444444444444)
  82. #define PANGO_SCALE_SMALL ((double)0.8333333333333)
  83. #define PANGO_SCALE_MEDIUM ((double)1.0)
  84. #define PANGO_SCALE_LARGE ((double)1.2)
  85. #define PANGO_SCALE_X_LARGE ((double)1.4399999999999)
  86. #define PANGO_SCALE_XX_LARGE ((double)1.728)
  87. /*
  88. * PangoFontDescription
  89. */
  90. #define PANGO_TYPE_FONT_DESCRIPTION (pango_font_description_get_type ())
  91. GType pango_font_description_get_type (void) G_GNUC_CONST;
  92. PangoFontDescription *pango_font_description_new (void);
  93. PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc);
  94. PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription *desc);
  95. guint pango_font_description_hash (const PangoFontDescription *desc) G_GNUC_PURE;
  96. gboolean pango_font_description_equal (const PangoFontDescription *desc1,
  97. const PangoFontDescription *desc2) G_GNUC_PURE;
  98. void pango_font_description_free (PangoFontDescription *desc);
  99. void pango_font_descriptions_free (PangoFontDescription **descs,
  100. int n_descs);
  101. void pango_font_description_set_family (PangoFontDescription *desc,
  102. const char *family);
  103. void pango_font_description_set_family_static (PangoFontDescription *desc,
  104. const char *family);
  105. G_CONST_RETURN char *pango_font_description_get_family (const PangoFontDescription *desc) G_GNUC_PURE;
  106. void pango_font_description_set_style (PangoFontDescription *desc,
  107. PangoStyle style);
  108. PangoStyle pango_font_description_get_style (const PangoFontDescription *desc) G_GNUC_PURE;
  109. void pango_font_description_set_variant (PangoFontDescription *desc,
  110. PangoVariant variant);
  111. PangoVariant pango_font_description_get_variant (const PangoFontDescription *desc) G_GNUC_PURE;
  112. void pango_font_description_set_weight (PangoFontDescription *desc,
  113. PangoWeight weight);
  114. PangoWeight pango_font_description_get_weight (const PangoFontDescription *desc) G_GNUC_PURE;
  115. void pango_font_description_set_stretch (PangoFontDescription *desc,
  116. PangoStretch stretch);
  117. PangoStretch pango_font_description_get_stretch (const PangoFontDescription *desc) G_GNUC_PURE;
  118. void pango_font_description_set_size (PangoFontDescription *desc,
  119. gint size);
  120. gint pango_font_description_get_size (const PangoFontDescription *desc) G_GNUC_PURE;
  121. void pango_font_description_set_absolute_size (PangoFontDescription *desc,
  122. double size);
  123. gboolean pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE;
  124. void pango_font_description_set_gravity (PangoFontDescription *desc,
  125. PangoGravity gravity);
  126. PangoGravity pango_font_description_get_gravity (const PangoFontDescription *desc) G_GNUC_PURE;
  127. PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE;
  128. void pango_font_description_unset_fields (PangoFontDescription *desc,
  129. PangoFontMask to_unset);
  130. void pango_font_description_merge (PangoFontDescription *desc,
  131. const PangoFontDescription *desc_to_merge,
  132. gboolean replace_existing);
  133. void pango_font_description_merge_static (PangoFontDescription *desc,
  134. const PangoFontDescription *desc_to_merge,
  135. gboolean replace_existing);
  136. gboolean pango_font_description_better_match (const PangoFontDescription *desc,
  137. const PangoFontDescription *old_match,
  138. const PangoFontDescription *new_match) G_GNUC_PURE;
  139. PangoFontDescription *pango_font_description_from_string (const char *str);
  140. char * pango_font_description_to_string (const PangoFontDescription *desc);
  141. char * pango_font_description_to_filename (const PangoFontDescription *desc);
  142. /*
  143. * PangoFontMetrics
  144. */
  145. #define PANGO_TYPE_FONT_METRICS (pango_font_metrics_get_type ())
  146. GType pango_font_metrics_get_type (void) G_GNUC_CONST;
  147. PangoFontMetrics *pango_font_metrics_ref (PangoFontMetrics *metrics);
  148. void pango_font_metrics_unref (PangoFontMetrics *metrics);
  149. int pango_font_metrics_get_ascent (PangoFontMetrics *metrics) G_GNUC_PURE;
  150. int pango_font_metrics_get_descent (PangoFontMetrics *metrics) G_GNUC_PURE;
  151. int pango_font_metrics_get_approximate_char_width (PangoFontMetrics *metrics) G_GNUC_PURE;
  152. int pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE;
  153. int pango_font_metrics_get_underline_position (PangoFontMetrics *metrics) G_GNUC_PURE;
  154. int pango_font_metrics_get_underline_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
  155. int pango_font_metrics_get_strikethrough_position (PangoFontMetrics *metrics) G_GNUC_PURE;
  156. int pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
  157. #ifdef PANGO_ENABLE_BACKEND
  158. PangoFontMetrics *pango_font_metrics_new (void);
  159. struct _PangoFontMetrics
  160. {
  161. guint ref_count;
  162. int ascent;
  163. int descent;
  164. int approximate_char_width;
  165. int approximate_digit_width;
  166. int underline_position;
  167. int underline_thickness;
  168. int strikethrough_position;
  169. int strikethrough_thickness;
  170. };
  171. #endif /* PANGO_ENABLE_BACKEND */
  172. /*
  173. * PangoFontFamily
  174. */
  175. #define PANGO_TYPE_FONT_FAMILY (pango_font_family_get_type ())
  176. #define PANGO_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily))
  177. #define PANGO_IS_FONT_FAMILY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY))
  178. typedef struct _PangoFontFamily PangoFontFamily;
  179. typedef struct _PangoFontFace PangoFontFace;
  180. GType pango_font_family_get_type (void) G_GNUC_CONST;
  181. void pango_font_family_list_faces (PangoFontFamily *family,
  182. PangoFontFace ***faces,
  183. int *n_faces);
  184. G_CONST_RETURN char *pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE;
  185. gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE;
  186. #ifdef PANGO_ENABLE_BACKEND
  187. #define PANGO_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
  188. #define PANGO_IS_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY))
  189. #define PANGO_FONT_FAMILY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
  190. typedef struct _PangoFontFamilyClass PangoFontFamilyClass;
  191. struct _PangoFontFamily
  192. {
  193. GObject parent_instance;
  194. };
  195. struct _PangoFontFamilyClass
  196. {
  197. GObjectClass parent_class;
  198. /*< public >*/
  199. void (*list_faces) (PangoFontFamily *family,
  200. PangoFontFace ***faces,
  201. int *n_faces);
  202. const char * (*get_name) (PangoFontFamily *family);
  203. gboolean (*is_monospace) (PangoFontFamily *family);
  204. /*< private >*/
  205. /* Padding for future expansion */
  206. void (*_pango_reserved2) (void);
  207. void (*_pango_reserved3) (void);
  208. void (*_pango_reserved4) (void);
  209. };
  210. #endif /* PANGO_ENABLE_BACKEND */
  211. /*
  212. * PangoFontFace
  213. */
  214. #define PANGO_TYPE_FONT_FACE (pango_font_face_get_type ())
  215. #define PANGO_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace))
  216. #define PANGO_IS_FONT_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE))
  217. GType pango_font_face_get_type (void) G_GNUC_CONST;
  218. PangoFontDescription *pango_font_face_describe (PangoFontFace *face);
  219. G_CONST_RETURN char *pango_font_face_get_face_name (PangoFontFace *face) G_GNUC_PURE;
  220. void pango_font_face_list_sizes (PangoFontFace *face,
  221. int **sizes,
  222. int *n_sizes);
  223. gboolean pango_font_face_is_synthesized (PangoFontFace *face) G_GNUC_PURE;
  224. #ifdef PANGO_ENABLE_BACKEND
  225. #define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
  226. #define PANGO_IS_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE))
  227. #define PANGO_FONT_FACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
  228. typedef struct _PangoFontFaceClass PangoFontFaceClass;
  229. struct _PangoFontFace
  230. {
  231. GObject parent_instance;
  232. };
  233. struct _PangoFontFaceClass
  234. {
  235. GObjectClass parent_class;
  236. /*< public >*/
  237. const char * (*get_face_name) (PangoFontFace *face);
  238. PangoFontDescription * (*describe) (PangoFontFace *face);
  239. void (*list_sizes) (PangoFontFace *face,
  240. int **sizes,
  241. int *n_sizes);
  242. gboolean (*is_synthesized) (PangoFontFace *face);
  243. /*< private >*/
  244. /* Padding for future expansion */
  245. void (*_pango_reserved3) (void);
  246. void (*_pango_reserved4) (void);
  247. };
  248. #endif /* PANGO_ENABLE_BACKEND */
  249. /*
  250. * PangoFont
  251. */
  252. #define PANGO_TYPE_FONT (pango_font_get_type ())
  253. #define PANGO_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont))
  254. #define PANGO_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT))
  255. GType pango_font_get_type (void) G_GNUC_CONST;
  256. PangoFontDescription *pango_font_describe (PangoFont *font);
  257. PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont *font);
  258. PangoCoverage * pango_font_get_coverage (PangoFont *font,
  259. PangoLanguage *language);
  260. PangoEngineShape * pango_font_find_shaper (PangoFont *font,
  261. PangoLanguage *language,
  262. guint32 ch);
  263. PangoFontMetrics * pango_font_get_metrics (PangoFont *font,
  264. PangoLanguage *language);
  265. void pango_font_get_glyph_extents (PangoFont *font,
  266. PangoGlyph glyph,
  267. PangoRectangle *ink_rect,
  268. PangoRectangle *logical_rect);
  269. PangoFontMap *pango_font_get_font_map (PangoFont *font);
  270. #ifdef PANGO_ENABLE_BACKEND
  271. #define PANGO_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
  272. #define PANGO_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT))
  273. #define PANGO_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass))
  274. typedef struct _PangoFontClass PangoFontClass;
  275. struct _PangoFont
  276. {
  277. GObject parent_instance;
  278. };
  279. struct _PangoFontClass
  280. {
  281. GObjectClass parent_class;
  282. /*< public >*/
  283. PangoFontDescription *(*describe) (PangoFont *font);
  284. PangoCoverage * (*get_coverage) (PangoFont *font,
  285. PangoLanguage *lang);
  286. PangoEngineShape * (*find_shaper) (PangoFont *font,
  287. PangoLanguage *lang,
  288. guint32 ch);
  289. void (*get_glyph_extents) (PangoFont *font,
  290. PangoGlyph glyph,
  291. PangoRectangle *ink_rect,
  292. PangoRectangle *logical_rect);
  293. PangoFontMetrics * (*get_metrics) (PangoFont *font,
  294. PangoLanguage *language);
  295. PangoFontMap * (*get_font_map) (PangoFont *font);
  296. PangoFontDescription *(*describe_absolute) (PangoFont *font);
  297. /*< private >*/
  298. /* Padding for future expansion */
  299. void (*_pango_reserved1) (void);
  300. void (*_pango_reserved2) (void);
  301. };
  302. /* used for very rare and miserable situtations that we cannot even
  303. * draw a hexbox
  304. */
  305. #define PANGO_UNKNOWN_GLYPH_WIDTH 10
  306. #define PANGO_UNKNOWN_GLYPH_HEIGHT 14
  307. #endif /* PANGO_ENABLE_BACKEND */
  308. #define PANGO_GLYPH_EMPTY ((PangoGlyph)0x0FFFFFFF)
  309. #define PANGO_GLYPH_INVALID_INPUT ((PangoGlyph)0xFFFFFFFF)
  310. #define PANGO_GLYPH_UNKNOWN_FLAG ((PangoGlyph)0x10000000)
  311. #define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG)
  312. G_END_DECLS
  313. #endif /* __PANGO_FONT_H__ */