[Gybe-css-commits] gtkcssrc/src font.c
Status: Planning
Brought to you by:
keizie
From: Kang <ke...@us...> - 2003-06-10 17:59:01
|
keizi 03/06/10 10:58:58 Modified: src font.c Log: relative keyword may resolve into absolute one of ancestor Revision Changes Path 1.3 +53 -8 gtkcssrc/src/font.c Index: font.c =================================================================== RCS file: /cvsroot/gybe/gtkcssrc/src/font.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- font.c 9 Jun 2003 18:26:25 -0000 1.2 +++ font.c 10 Jun 2003 17:58:57 -0000 1.3 @@ -70,15 +70,60 @@ } } +/** + * cr_style_get_font_stretch: + * @style: a #CRStyle + * + * Gets field "font_stretch" of @style. If relative keyword found, + * scan ancestors of @style 'til absolute keyword found. + * + * Return value: a #CRFontStretch that is field "font_stretch" of @style or one of its ancestor. + **/ +static enum CRFontStretch +cr_style_get_font_stretch (CRStyle *style) +{ + gint calc; + enum CRFontStretch retval = style->font_stretch; + + /* Increased or decreased by number of wider/narrow keywords */ + calc = 0; + + do switch (retval) { + case FONT_STRETCH_INHERIT: { + style = style->parent_style; + retval = style->font_stretch; + continue; + } + case FONT_STRETCH_WIDER: { + calc++; + style = style->parent_style; + retval = style->font_stretch; + continue; + } + case FONT_STRETCH_NARROWER: { + calc--; + style = style->parent_style; + retval = style->font_stretch; + continue; + } + } while(0); /* on default:, no continue; and (0) end loop. */ + + retval += calc; + + if (retval < FONT_STRETCH_ULTRA_CONDENSED) + retval = FONT_STRETCH_ULTRA_CONDENSED; + else + if (retval > FONT_STRETCH_ULTRA_EXPANDED) + retval = FONT_STRETCH_ULTRA_EXPANDED; + + return retval; +} + static PangoStretch pango_stretch_from_CRStyle (CRStyle *cr_style) { - switch (cr_style->font_stretch) { - case FONT_STRETCH_NORMAL: - return PANGO_STRETCH_NORMAL; - case FONT_STRETCH_WIDER: /* TODO */ - case FONT_STRETCH_NARROWER: /* TODO */ - return 0; + switch (cr_style_get_font_stretch (cr_style)) + { case FONT_STRETCH_ULTRA_CONDENSED: return PANGO_STRETCH_ULTRA_CONDENSED; case FONT_STRETCH_EXTRA_CONDENSED: @@ -87,6 +132,8 @@ return PANGO_STRETCH_CONDENSED; case FONT_STRETCH_SEMI_CONDENSED: return PANGO_STRETCH_SEMI_CONDENSED; + case FONT_STRETCH_NORMAL: + return PANGO_STRETCH_NORMAL; case FONT_STRETCH_SEMI_EXPANDED: return PANGO_STRETCH_SEMI_EXPANDED; case FONT_STRETCH_EXPANDED: @@ -95,8 +142,6 @@ return PANGO_STRETCH_EXTRA_EXPANDED; case FONT_STRETCH_ULTRA_EXPANDED: return PANGO_STRETCH_ULTRA_EXPANDED; - case FONT_STRETCH_INHERIT: - return pango_stretch_from_CRStyle (cr_style->parent_style); } } |