summaryrefslogtreecommitdiffstats
path: root/src/st/croco/cr-fonts.h
blob: 9eaeeeb981efb3292c8f168a4912a8e098981789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */

/*
 * This file is part of The Croco Library
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2.1 of 
 * the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the 
 * GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 *
 * Author: Dodji Seketeli
 * See COPYRIGHTS file for copyright information.
 */

#ifndef __CR_FONTS_H__
#define __CR_FONTS_H__

#include "cr-utils.h"
#include "cr-num.h"

/**
 *@file
 *Various type declarations about font selection related
 *properties.
 */
G_BEGIN_DECLS


enum CRFontFamilyType
{
	FONT_FAMILY_SANS_SERIF,
	FONT_FAMILY_SERIF,	
	FONT_FAMILY_CURSIVE,
	FONT_FAMILY_FANTASY,
	FONT_FAMILY_MONOSPACE,
	FONT_FAMILY_NON_GENERIC,
	FONT_FAMILY_INHERIT,
	/**/
	NB_FONT_FAMILIE_TYPES
} ;

typedef struct _CRFontFamily CRFontFamily ;

struct _CRFontFamily
{
	enum CRFontFamilyType type ;

	/*
	 *The name of the font family, in case
	 *it is non generic.
	 *Is set only if the type is FONT_FAMILY_NON_GENERIC.
	 */
	guchar *name ;

	CRFontFamily *next ;
	CRFontFamily *prev ;
} ;


/**
 *The different types
 *of absolute font size.
 *This is used by the 'font-size'
 *property defined in css2 spec
 *in chapter 15.2.4 .
 *These values a indexes of 
 *table of size so please, do not
 *change their definition order unless
 *you know what you are doing.
 */
enum CRPredefinedAbsoluteFontSize
{
        FONT_SIZE_XX_SMALL=0,
        FONT_SIZE_X_SMALL,
        FONT_SIZE_SMALL,
        FONT_SIZE_MEDIUM,
        FONT_SIZE_LARGE,
        FONT_SIZE_X_LARGE,
        FONT_SIZE_XX_LARGE,
	FONT_SIZE_INHERIT,
        NB_PREDEFINED_ABSOLUTE_FONT_SIZES
} ;

/**
 *The different types
 *of relative font size.
 *This is used by the 'font-size'
 *property defined in css2 spec
 *in chapter 15.2.4 .
 *These values a indexes of 
 *table of size so please, do not
 *change their definition order unless
 *you know what you are doing.
 */
enum CRRelativeFontSize
{        
        FONT_SIZE_LARGER,
        FONT_SIZE_SMALLER,
        NB_RELATIVE_FONT_SIZE
} ;

/**
 *The type of font-size property.
 *Used to define the type of #CRFontSize .
 *See css2 spec chapter 15.2.4 to understand.
 */
enum CRFontSizeType {
        /**
         *If the type of #CRFontSize is
         *PREDEFINED_ABSOLUTE_FONT_SIZE,
         *the CRFontSize::value.predefined_absolute 
         *field will be defined.
         */
        PREDEFINED_ABSOLUTE_FONT_SIZE,
        
        /**
         *If the type of #CRFontSize is
         *ABSOLUTE_FONT_SIZE,
         *the CRFontSize::value.absolute 
         *field will be defined.
         */
        ABSOLUTE_FONT_SIZE,

        /**
         *If the type of #CRFontSize is
         *RELATIVE_FONT_SIZE,
         *the CRFontSize::value.relative
         *field will be defined.
         */
        RELATIVE_FONT_SIZE,

        /**
         *If the type of #CRFontSize is
         *INHERITED_FONT_SIZE,
         *the None of the field of the CRFontSize::value enum
         *will be defined.
         */
        INHERITED_FONT_SIZE,

        NB_FONT_SIZE_TYPE
} ;

typedef struct _CRFontSize CRFontSize ;
struct _CRFontSize {
        enum CRFontSizeType type ;
        union  {
                enum CRPredefinedAbsoluteFontSize predefined ;
                enum CRRelativeFontSize relative ;
                CRNum absolute ;
        } value;
} ;

enum CRFontSizeAdjustType
{
        FONT_SIZE_ADJUST_NONE = 0,
        FONT_SIZE_ADJUST_NUMBER,
        FONT_SIZE_ADJUST_INHERIT
} ;
typedef struct _CRFontSizeAdjust CRFontSizeAdjust ;
struct _CRFontSizeAdjust
{
        enum CRFontSizeAdjustType type ;
        CRNum *num ;
} ;

enum CRFontStyle
{
        FONT_STYLE_NORMAL=0,
        FONT_STYLE_ITALIC,
        FONT_STYLE_OBLIQUE,
        FONT_STYLE_INHERIT
} ;

enum CRFontVariant
{
        FONT_VARIANT_NORMAL=0,
        FONT_VARIANT_SMALL_CAPS,
        FONT_VARIANT_INHERIT
} ;

enum CRFontWeight
{
        FONT_WEIGHT_NORMAL = 1,
        FONT_WEIGHT_BOLD = 1<<1,
        FONT_WEIGHT_BOLDER = 1<<2,
        FONT_WEIGHT_LIGHTER = 1<<3,
        FONT_WEIGHT_100 = 1<<4,
        FONT_WEIGHT_200 = 1<<5,
        FONT_WEIGHT_300 = 1<<6,
        FONT_WEIGHT_400 = 1<<7,
        FONT_WEIGHT_500 = 1<<8,
        FONT_WEIGHT_600 = 1<<9,
        FONT_WEIGHT_700 = 1<<10,
        FONT_WEIGHT_800 = 1<<11,
        FONT_WEIGHT_900 = 1<<12,
        FONT_WEIGHT_INHERIT = 1<<13,
        NB_FONT_WEIGHTS
} ;

enum CRFontStretch
{
        FONT_STRETCH_NORMAL=0,
        FONT_STRETCH_WIDER,
        FONT_STRETCH_NARROWER,
        FONT_STRETCH_ULTRA_CONDENSED,
        FONT_STRETCH_EXTRA_CONDENSED,
        FONT_STRETCH_CONDENSED,
        FONT_STRETCH_SEMI_CONDENSED,
        FONT_STRETCH_SEMI_EXPANDED,
        FONT_STRETCH_EXPANDED,
        FONT_STRETCH_EXTRA_EXPANDED,
        FONT_STRETCH_ULTRA_EXPANDED,
        FONT_STRETCH_INHERIT
} ;

/**************************************
 *'font-family' manipulation functions
 ***************************************/
CRFontFamily *
cr_font_family_new (enum CRFontFamilyType a_type, guchar *a_name) ;

CRFontFamily *
cr_font_family_append (CRFontFamily *a_this, 
		       CRFontFamily *a_family_to_append) ;

guchar *
cr_font_family_to_string (CRFontFamily const *a_this,
                          gboolean a_walk_font_family_list) ;

CRFontFamily *
cr_font_family_prepend (CRFontFamily *a_this, 
			CRFontFamily *a_family_to_prepend);

enum CRStatus
cr_font_family_destroy (CRFontFamily *a_this) ;

enum CRStatus
cr_font_family_set_name (CRFontFamily *a_this, guchar *a_name) ;


/************************************
 *'font-size' manipulation functions
 ***********************************/

CRFontSize * cr_font_size_new (void) ;

enum CRStatus cr_font_size_clear (CRFontSize *a_this) ;

enum CRStatus cr_font_size_copy (CRFontSize *a_dst, 
                                 CRFontSize const *a_src) ;
enum CRStatus cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this, 
                                                              enum CRPredefinedAbsoluteFontSize a_predefined) ;
enum CRStatus cr_font_size_set_relative_font_size (CRFontSize *a_this,
                                                   enum CRRelativeFontSize a_relative) ;

enum CRStatus cr_font_size_set_absolute_font_size (CRFontSize *a_this,
                                                   enum CRNumType a_num_type,
                                                   gdouble a_value) ;

enum CRStatus cr_font_size_set_to_inherit (CRFontSize *a_this) ;

gboolean cr_font_size_is_set_to_inherit (CRFontSize const *a_this) ;

gchar* cr_font_size_to_string (CRFontSize const *a_this) ;

void cr_font_size_destroy (CRFontSize *a_font_size) ;

/*******************************************************
 *'font-size-adjust' manipulation function declarations
 *******************************************************/

CRFontSizeAdjust * cr_font_size_adjust_new (void) ;

gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust const *a_this) ;

void cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;

void 
cr_font_size_get_smaller_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
                                               enum CRPredefinedAbsoluteFontSize *a_smaller_size) ;
void
cr_font_size_get_larger_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
                                              enum CRPredefinedAbsoluteFontSize *a_larger_size) ;

gboolean
cr_font_size_is_predefined_absolute_font_size (enum CRPredefinedAbsoluteFontSize a_font_size) ;

/***********************************
 *various other font related functions
 ***********************************/
const gchar * cr_font_style_to_string (enum CRFontStyle a_code) ;

const gchar * cr_font_weight_to_string (enum CRFontWeight a_code)  ;

enum CRFontWeight
cr_font_weight_get_bolder (enum CRFontWeight a_weight) ;

const gchar * cr_font_variant_to_string (enum CRFontVariant a_code) ;

const gchar * cr_font_stretch_to_string (enum CRFontStretch a_code) ;

G_END_DECLS

#endif