cr-fonts.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
  2. /*
  3. * This file is part of The Croco Library
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2.1 of
  7. * the GNU Lesser General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the
  16. * GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  19. * USA
  20. *
  21. * Author: Dodji Seketeli
  22. * See COPYRIGHTS file for copyright information.
  23. */
  24. #ifndef __CR_FONTS_H__
  25. #define __CR_FONTS_H__
  26. #include "cr-utils.h"
  27. #include "cr-num.h"
  28. /**
  29. *@file
  30. *Various type declarations about font selection related
  31. *properties.
  32. */
  33. G_BEGIN_DECLS
  34. enum CRFontFamilyType
  35. {
  36. FONT_FAMILY_SANS_SERIF,
  37. FONT_FAMILY_SERIF,
  38. FONT_FAMILY_CURSIVE,
  39. FONT_FAMILY_FANTASY,
  40. FONT_FAMILY_MONOSPACE,
  41. FONT_FAMILY_NON_GENERIC,
  42. FONT_FAMILY_INHERIT,
  43. /**/
  44. NB_FONT_FAMILIE_TYPES
  45. } ;
  46. typedef struct _CRFontFamily CRFontFamily ;
  47. struct _CRFontFamily
  48. {
  49. enum CRFontFamilyType type ;
  50. /*
  51. *The name of the font family, in case
  52. *it is non generic.
  53. *Is set only if the type is FONT_FAMILY_NON_GENERIC.
  54. */
  55. guchar *name ;
  56. CRFontFamily *next ;
  57. CRFontFamily *prev ;
  58. } ;
  59. /**
  60. *The different types
  61. *of absolute font size.
  62. *This is used by the 'font-size'
  63. *property defined in css2 spec
  64. *in chapter 15.2.4 .
  65. *These values a indexes of
  66. *table of size so please, do not
  67. *change their definition order unless
  68. *you know what you are doing.
  69. */
  70. enum CRPredefinedAbsoluteFontSize
  71. {
  72. FONT_SIZE_XX_SMALL=0,
  73. FONT_SIZE_X_SMALL,
  74. FONT_SIZE_SMALL,
  75. FONT_SIZE_MEDIUM,
  76. FONT_SIZE_LARGE,
  77. FONT_SIZE_X_LARGE,
  78. FONT_SIZE_XX_LARGE,
  79. FONT_SIZE_INHERIT,
  80. NB_PREDEFINED_ABSOLUTE_FONT_SIZES
  81. } ;
  82. /**
  83. *The different types
  84. *of relative font size.
  85. *This is used by the 'font-size'
  86. *property defined in css2 spec
  87. *in chapter 15.2.4 .
  88. *These values a indexes of
  89. *table of size so please, do not
  90. *change their definition order unless
  91. *you know what you are doing.
  92. */
  93. enum CRRelativeFontSize
  94. {
  95. FONT_SIZE_LARGER,
  96. FONT_SIZE_SMALLER,
  97. NB_RELATIVE_FONT_SIZE
  98. } ;
  99. /**
  100. *The type of font-size property.
  101. *Used to define the type of #CRFontSize .
  102. *See css2 spec chapter 15.2.4 to understand.
  103. */
  104. enum CRFontSizeType {
  105. /**
  106. *If the type of #CRFontSize is
  107. *PREDEFINED_ABSOLUTE_FONT_SIZE,
  108. *the CRFontSize::value.predefined_absolute
  109. *field will be defined.
  110. */
  111. PREDEFINED_ABSOLUTE_FONT_SIZE,
  112. /**
  113. *If the type of #CRFontSize is
  114. *ABSOLUTE_FONT_SIZE,
  115. *the CRFontSize::value.absolute
  116. *field will be defined.
  117. */
  118. ABSOLUTE_FONT_SIZE,
  119. /**
  120. *If the type of #CRFontSize is
  121. *RELATIVE_FONT_SIZE,
  122. *the CRFontSize::value.relative
  123. *field will be defined.
  124. */
  125. RELATIVE_FONT_SIZE,
  126. /**
  127. *If the type of #CRFontSize is
  128. *INHERITED_FONT_SIZE,
  129. *the None of the field of the CRFontSize::value enum
  130. *will be defined.
  131. */
  132. INHERITED_FONT_SIZE,
  133. NB_FONT_SIZE_TYPE
  134. } ;
  135. typedef struct _CRFontSize CRFontSize ;
  136. struct _CRFontSize {
  137. enum CRFontSizeType type ;
  138. union {
  139. enum CRPredefinedAbsoluteFontSize predefined ;
  140. enum CRRelativeFontSize relative ;
  141. CRNum absolute ;
  142. } value;
  143. } ;
  144. enum CRFontSizeAdjustType
  145. {
  146. FONT_SIZE_ADJUST_NONE = 0,
  147. FONT_SIZE_ADJUST_NUMBER,
  148. FONT_SIZE_ADJUST_INHERIT
  149. } ;
  150. typedef struct _CRFontSizeAdjust CRFontSizeAdjust ;
  151. struct _CRFontSizeAdjust
  152. {
  153. enum CRFontSizeAdjustType type ;
  154. CRNum *num ;
  155. } ;
  156. enum CRFontStyle
  157. {
  158. FONT_STYLE_NORMAL=0,
  159. FONT_STYLE_ITALIC,
  160. FONT_STYLE_OBLIQUE,
  161. FONT_STYLE_INHERIT
  162. } ;
  163. enum CRFontVariant
  164. {
  165. FONT_VARIANT_NORMAL=0,
  166. FONT_VARIANT_SMALL_CAPS,
  167. FONT_VARIANT_INHERIT
  168. } ;
  169. enum CRFontWeight
  170. {
  171. FONT_WEIGHT_NORMAL = 1,
  172. FONT_WEIGHT_BOLD = 1<<1,
  173. FONT_WEIGHT_BOLDER = 1<<2,
  174. FONT_WEIGHT_LIGHTER = 1<<3,
  175. FONT_WEIGHT_100 = 1<<4,
  176. FONT_WEIGHT_200 = 1<<5,
  177. FONT_WEIGHT_300 = 1<<6,
  178. FONT_WEIGHT_400 = 1<<7,
  179. FONT_WEIGHT_500 = 1<<8,
  180. FONT_WEIGHT_600 = 1<<9,
  181. FONT_WEIGHT_700 = 1<<10,
  182. FONT_WEIGHT_800 = 1<<11,
  183. FONT_WEIGHT_900 = 1<<12,
  184. FONT_WEIGHT_INHERIT = 1<<13,
  185. NB_FONT_WEIGHTS
  186. } ;
  187. enum CRFontStretch
  188. {
  189. FONT_STRETCH_NORMAL=0,
  190. FONT_STRETCH_WIDER,
  191. FONT_STRETCH_NARROWER,
  192. FONT_STRETCH_ULTRA_CONDENSED,
  193. FONT_STRETCH_EXTRA_CONDENSED,
  194. FONT_STRETCH_CONDENSED,
  195. FONT_STRETCH_SEMI_CONDENSED,
  196. FONT_STRETCH_SEMI_EXPANDED,
  197. FONT_STRETCH_EXPANDED,
  198. FONT_STRETCH_EXTRA_EXPANDED,
  199. FONT_STRETCH_ULTRA_EXPANDED,
  200. FONT_STRETCH_INHERIT
  201. } ;
  202. /**************************************
  203. *'font-family' manipulation functions
  204. ***************************************/
  205. CRFontFamily *
  206. cr_font_family_new (enum CRFontFamilyType a_type, guchar *a_name) ;
  207. CRFontFamily *
  208. cr_font_family_append (CRFontFamily *a_this,
  209. CRFontFamily *a_family_to_append) ;
  210. guchar *
  211. cr_font_family_to_string (CRFontFamily const *a_this,
  212. gboolean a_walk_font_family_list) ;
  213. CRFontFamily *
  214. cr_font_family_prepend (CRFontFamily *a_this,
  215. CRFontFamily *a_family_to_prepend);
  216. enum CRStatus
  217. cr_font_family_destroy (CRFontFamily *a_this) ;
  218. enum CRStatus
  219. cr_font_family_set_name (CRFontFamily *a_this, guchar *a_name) ;
  220. /************************************
  221. *'font-size' manipulation functions
  222. ***********************************/
  223. CRFontSize * cr_font_size_new (void) ;
  224. enum CRStatus cr_font_size_clear (CRFontSize *a_this) ;
  225. enum CRStatus cr_font_size_copy (CRFontSize *a_dst,
  226. CRFontSize const *a_src) ;
  227. enum CRStatus cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this,
  228. enum CRPredefinedAbsoluteFontSize a_predefined) ;
  229. enum CRStatus cr_font_size_set_relative_font_size (CRFontSize *a_this,
  230. enum CRRelativeFontSize a_relative) ;
  231. enum CRStatus cr_font_size_set_absolute_font_size (CRFontSize *a_this,
  232. enum CRNumType a_num_type,
  233. gdouble a_value) ;
  234. enum CRStatus cr_font_size_set_to_inherit (CRFontSize *a_this) ;
  235. gboolean cr_font_size_is_set_to_inherit (CRFontSize const *a_this) ;
  236. gchar* cr_font_size_to_string (CRFontSize const *a_this) ;
  237. void cr_font_size_destroy (CRFontSize *a_font_size) ;
  238. /*******************************************************
  239. *'font-size-adjust' manipulation function declarations
  240. *******************************************************/
  241. CRFontSizeAdjust * cr_font_size_adjust_new (void) ;
  242. gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust const *a_this) ;
  243. void cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;
  244. void
  245. cr_font_size_get_smaller_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
  246. enum CRPredefinedAbsoluteFontSize *a_smaller_size) ;
  247. void
  248. cr_font_size_get_larger_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
  249. enum CRPredefinedAbsoluteFontSize *a_larger_size) ;
  250. gboolean
  251. cr_font_size_is_predefined_absolute_font_size (enum CRPredefinedAbsoluteFontSize a_font_size) ;
  252. /***********************************
  253. *various other font related functions
  254. ***********************************/
  255. const gchar * cr_font_style_to_string (enum CRFontStyle a_code) ;
  256. const gchar * cr_font_weight_to_string (enum CRFontWeight a_code) ;
  257. enum CRFontWeight
  258. cr_font_weight_get_bolder (enum CRFontWeight a_weight) ;
  259. const gchar * cr_font_variant_to_string (enum CRFontVariant a_code) ;
  260. const gchar * cr_font_stretch_to_string (enum CRFontStretch a_code) ;
  261. G_END_DECLS
  262. #endif