Libcroco
cr-fonts.h
Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
00002 
00003 /*
00004  * This file is part of The Croco Library
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of version 2.1 of 
00008  * the GNU Lesser General Public
00009  * License as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the 
00017  * GNU Lesser General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  *
00022  * Author: Dodji Seketeli
00023  * See COPYRIGHTS file for copyright information.
00024  */
00025 
00026 #ifndef __CR_FONTS_H__
00027 #define __CR_FONTS_H__
00028 
00029 #include "cr-utils.h"
00030 #include "cr-num.h"
00031 
00032 /**
00033  *@file
00034  *Various type declarations about font selection related
00035  *properties.
00036  */
00037 G_BEGIN_DECLS
00038 
00039 
00040 enum CRFontFamilyType
00041 {
00042         FONT_FAMILY_SANS_SERIF,
00043         FONT_FAMILY_SERIF,      
00044         FONT_FAMILY_CURSIVE,
00045         FONT_FAMILY_FANTASY,
00046         FONT_FAMILY_MONOSPACE,
00047         FONT_FAMILY_NON_GENERIC,
00048         FONT_FAMILY_INHERIT,
00049         /**/
00050         NB_FONT_FAMILIE_TYPES
00051 } ;
00052 
00053 typedef struct _CRFontFamily CRFontFamily ;
00054 
00055 struct _CRFontFamily
00056 {
00057         enum CRFontFamilyType type ;
00058 
00059         /*
00060          *The name of the font family, in case
00061          *it is non generic.
00062          *Is set only if the type is FONT_FAMILY_NON_GENERIC.
00063          */
00064         guchar *name ;
00065 
00066         CRFontFamily *next ;
00067         CRFontFamily *prev ;
00068 } ;
00069 
00070 
00071 /**
00072  *The different types
00073  *of absolute font size.
00074  *This is used by the 'font-size'
00075  *property defined in css2 spec
00076  *in chapter 15.2.4 .
00077  *These values a indexes of 
00078  *table of size so please, do not
00079  *change their definition order unless
00080  *you know what you are doing.
00081  */
00082 enum CRPredefinedAbsoluteFontSize
00083 {
00084         FONT_SIZE_XX_SMALL=0,
00085         FONT_SIZE_X_SMALL,
00086         FONT_SIZE_SMALL,
00087         FONT_SIZE_MEDIUM,
00088         FONT_SIZE_LARGE,
00089         FONT_SIZE_X_LARGE,
00090         FONT_SIZE_XX_LARGE,
00091         FONT_SIZE_INHERIT,
00092         NB_PREDEFINED_ABSOLUTE_FONT_SIZES
00093 } ;
00094 
00095 /**
00096  *The different types
00097  *of relative font size.
00098  *This is used by the 'font-size'
00099  *property defined in css2 spec
00100  *in chapter 15.2.4 .
00101  *These values a indexes of 
00102  *table of size so please, do not
00103  *change their definition order unless
00104  *you know what you are doing.
00105  */
00106 enum CRRelativeFontSize
00107 {        
00108         FONT_SIZE_LARGER,
00109         FONT_SIZE_SMALLER,
00110         NB_RELATIVE_FONT_SIZE
00111 } ;
00112 
00113 /**
00114  *The type of font-size property.
00115  *Used to define the type of #CRFontSize .
00116  *See css2 spec chapter 15.2.4 to understand.
00117  */
00118 enum CRFontSizeType {
00119         /**
00120          *If the type of #CRFontSize is
00121          *PREDEFINED_ABSOLUTE_FONT_SIZE,
00122          *the CRFontSize::value.predefined_absolute 
00123          *field will be defined.
00124          */
00125         PREDEFINED_ABSOLUTE_FONT_SIZE,
00126         
00127         /**
00128          *If the type of #CRFontSize is
00129          *ABSOLUTE_FONT_SIZE,
00130          *the CRFontSize::value.absolute 
00131          *field will be defined.
00132          */
00133         ABSOLUTE_FONT_SIZE,
00134 
00135         /**
00136          *If the type of #CRFontSize is
00137          *RELATIVE_FONT_SIZE,
00138          *the CRFontSize::value.relative
00139          *field will be defined.
00140          */
00141         RELATIVE_FONT_SIZE,
00142 
00143         /**
00144          *If the type of #CRFontSize is
00145          *INHERITED_FONT_SIZE,
00146          *the None of the field of the CRFontSize::value enum
00147          *will be defined.
00148          */
00149         INHERITED_FONT_SIZE,
00150 
00151         NB_FONT_SIZE_TYPE
00152 } ;
00153 
00154 typedef struct _CRFontSize CRFontSize ;
00155 struct _CRFontSize {
00156         enum CRFontSizeType type ;
00157         union  {
00158                 enum CRPredefinedAbsoluteFontSize predefined ;
00159                 enum CRRelativeFontSize relative ;
00160                 CRNum absolute ;
00161         } value;
00162 } ;
00163 
00164 enum CRFontSizeAdjustType
00165 {
00166         FONT_SIZE_ADJUST_NONE = 0,
00167         FONT_SIZE_ADJUST_NUMBER,
00168         FONT_SIZE_ADJUST_INHERIT
00169 } ;
00170 typedef struct _CRFontSizeAdjust CRFontSizeAdjust ;
00171 struct _CRFontSizeAdjust
00172 {
00173         enum CRFontSizeAdjustType type ;
00174         CRNum *num ;
00175 } ;
00176 
00177 enum CRFontStyle
00178 {
00179         FONT_STYLE_NORMAL=0,
00180         FONT_STYLE_ITALIC,
00181         FONT_STYLE_OBLIQUE,
00182         FONT_STYLE_INHERIT
00183 } ;
00184 
00185 enum CRFontVariant
00186 {
00187         FONT_VARIANT_NORMAL=0,
00188         FONT_VARIANT_SMALL_CAPS,
00189         FONT_VARIANT_INHERIT
00190 } ;
00191 
00192 enum CRFontWeight
00193 {
00194         FONT_WEIGHT_NORMAL = 1,
00195         FONT_WEIGHT_BOLD = 1<<1,
00196         FONT_WEIGHT_BOLDER = 1<<2,
00197         FONT_WEIGHT_LIGHTER = 1<<3,
00198         FONT_WEIGHT_100 = 1<<4,
00199         FONT_WEIGHT_200 = 1<<5,
00200         FONT_WEIGHT_300 = 1<<6,
00201         FONT_WEIGHT_400 = 1<<7,
00202         FONT_WEIGHT_500 = 1<<8,
00203         FONT_WEIGHT_600 = 1<<9,
00204         FONT_WEIGHT_700 = 1<<10,
00205         FONT_WEIGHT_800 = 1<<11,
00206         FONT_WEIGHT_900 = 1<<12,
00207         FONT_WEIGHT_INHERIT = 1<<13,
00208         NB_FONT_WEIGHTS
00209 } ;
00210 
00211 enum CRFontStretch
00212 {
00213         FONT_STRETCH_NORMAL=0,
00214         FONT_STRETCH_WIDER,
00215         FONT_STRETCH_NARROWER,
00216         FONT_STRETCH_ULTRA_CONDENSED,
00217         FONT_STRETCH_EXTRA_CONDENSED,
00218         FONT_STRETCH_CONDENSED,
00219         FONT_STRETCH_SEMI_CONDENSED,
00220         FONT_STRETCH_SEMI_EXPANDED,
00221         FONT_STRETCH_EXPANDED,
00222         FONT_STRETCH_EXTRA_EXPANDED,
00223         FONT_STRETCH_ULTRA_EXPANDED,
00224         FONT_STRETCH_INHERIT
00225 } ;
00226 
00227 /**************************************
00228  *'font-family' manipulation functions
00229  ***************************************/
00230 CRFontFamily *
00231 cr_font_family_new (enum CRFontFamilyType a_type, guchar *a_name) ;
00232 
00233 CRFontFamily *
00234 cr_font_family_append (CRFontFamily *a_this, 
00235                        CRFontFamily *a_family_to_append) ;
00236 
00237 guchar *
00238 cr_font_family_to_string (CRFontFamily const *a_this,
00239                           gboolean a_walk_font_family_list) ;
00240 
00241 CRFontFamily *
00242 cr_font_family_prepend (CRFontFamily *a_this, 
00243                         CRFontFamily *a_family_to_prepend);
00244 
00245 enum CRStatus
00246 cr_font_family_destroy (CRFontFamily *a_this) ;
00247 
00248 enum CRStatus
00249 cr_font_family_set_name (CRFontFamily *a_this, guchar *a_name) ;
00250 
00251 
00252 /************************************
00253  *'font-size' manipulation functions
00254  ***********************************/
00255 
00256 CRFontSize * cr_font_size_new (void) ;
00257 
00258 enum CRStatus cr_font_size_clear (CRFontSize *a_this) ;
00259 
00260 enum CRStatus cr_font_size_copy (CRFontSize *a_dst, 
00261                                  CRFontSize const *a_src) ;
00262 enum CRStatus cr_font_size_set_predefined_absolute_font_size (CRFontSize *a_this, 
00263                                                               enum CRPredefinedAbsoluteFontSize a_predefined) ;
00264 enum CRStatus cr_font_size_set_relative_font_size (CRFontSize *a_this,
00265                                                    enum CRRelativeFontSize a_relative) ;
00266 
00267 enum CRStatus cr_font_size_set_absolute_font_size (CRFontSize *a_this,
00268                                                    enum CRNumType a_num_type,
00269                                                    gdouble a_value) ;
00270 
00271 enum CRStatus cr_font_size_set_to_inherit (CRFontSize *a_this) ;
00272 
00273 gboolean cr_font_size_is_set_to_inherit (CRFontSize const *a_this) ;
00274 
00275 gchar* cr_font_size_to_string (CRFontSize const *a_this) ;
00276 
00277 void cr_font_size_destroy (CRFontSize *a_font_size) ;
00278 
00279 /*******************************************************
00280  *'font-size-adjust' manipulation function declarations
00281  *******************************************************/
00282 
00283 CRFontSizeAdjust * cr_font_size_adjust_new (void) ;
00284 
00285 gchar * cr_font_size_adjust_to_string (CRFontSizeAdjust const *a_this) ;
00286 
00287 void cr_font_size_adjust_destroy (CRFontSizeAdjust *a_this) ;
00288 
00289 void 
00290 cr_font_size_get_smaller_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
00291                                                enum CRPredefinedAbsoluteFontSize *a_smaller_size) ;
00292 void
00293 cr_font_size_get_larger_predefined_font_size (enum CRPredefinedAbsoluteFontSize a_font_size,
00294                                               enum CRPredefinedAbsoluteFontSize *a_larger_size) ;
00295 
00296 gboolean
00297 cr_font_size_is_predefined_absolute_font_size (enum CRPredefinedAbsoluteFontSize a_font_size) ;
00298 
00299 /***********************************
00300  *various other font related functions
00301  ***********************************/
00302 const gchar * cr_font_style_to_string (enum CRFontStyle a_code) ;
00303 
00304 const gchar * cr_font_weight_to_string (enum CRFontWeight a_code)  ;
00305 
00306 enum CRFontWeight
00307 cr_font_weight_get_bolder (enum CRFontWeight a_weight) ;
00308 
00309 const gchar * cr_font_variant_to_string (enum CRFontVariant a_code) ;
00310 
00311 const gchar * cr_font_stretch_to_string (enum CRFontStretch a_code) ;
00312 
00313 G_END_DECLS
00314 
00315 #endif