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