From bf3e41a93dd7823c298714fff95221e43cf7d8a4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 30 Jan 2004 22:28:32 +0000 Subject: [project @ 2004-01-30 22:28:32 by jmb] Add font-variant support. Update TODO-CSS appropriately svn path=/import/netsurf/; revision=518 --- css/css.c | 8 ++++++++ css/css.h | 1 + css/css_enums | 2 +- css/ruleset.c | 20 +++++++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) (limited to 'css') diff --git a/css/css.c b/css/css.c index fe124d612..4d37ddece 100644 --- a/css/css.c +++ b/css/css.c @@ -46,6 +46,7 @@ const struct css_style css_base_style = { CSS_FONT_FAMILY_SANS_SERIF, CSS_FONT_WEIGHT_NORMAL, CSS_FONT_STYLE_NORMAL, + CSS_FONT_VARIANT_NORMAL, { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_ABSOLUTE, { 1.3 } }, CSS_TEXT_ALIGN_LEFT, @@ -65,6 +66,7 @@ const struct css_style css_empty_style = { CSS_FONT_FAMILY_INHERIT, CSS_FONT_WEIGHT_INHERIT, CSS_FONT_STYLE_INHERIT, + CSS_FONT_VARIANT_INHERIT, { CSS_HEIGHT_INHERIT, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_INHERIT, { 1.3 } }, CSS_TEXT_ALIGN_INHERIT, @@ -84,6 +86,7 @@ const struct css_style css_blank_style = { CSS_FONT_FAMILY_INHERIT, CSS_FONT_WEIGHT_INHERIT, CSS_FONT_STYLE_INHERIT, + CSS_FONT_VARIANT_INHERIT, { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_INHERIT, { 1.3 } }, CSS_TEXT_ALIGN_INHERIT, @@ -658,6 +661,7 @@ void css_dump_style(const struct css_style * const style) default: fprintf(stderr, "UNKNOWN"); break; } fprintf(stderr, " %s", css_font_family_name[style->font_family]); + fprintf(stderr, " %s", css_font_variant_name[style->font_variant]); fprintf(stderr, "; "); fprintf(stderr, "height: "); switch (style->height.height) { @@ -758,6 +762,8 @@ void css_cascade(struct css_style * const style, const struct css_style * const style->font_style = apply->font_style; if (apply->font_weight != CSS_FONT_WEIGHT_INHERIT) style->font_weight = apply->font_weight; + if (apply->font_variant != CSS_FONT_VARIANT_INHERIT) + style->font_variant = apply->font_variant; if (apply->height.height != CSS_HEIGHT_INHERIT) style->height = apply->height; if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT) @@ -831,6 +837,8 @@ void css_merge(struct css_style * const style, const struct css_style * const ap style->font_style = apply->font_style; if (apply->font_weight != CSS_FONT_WEIGHT_INHERIT) style->font_weight = apply->font_weight; + if (apply->font_variant != CSS_FONT_VARIANT_INHERIT) + style->font_variant = apply->font_variant; if (apply->height.height != CSS_HEIGHT_INHERIT) style->height = apply->height; if (apply->line_height.size != CSS_LINE_HEIGHT_INHERIT) diff --git a/css/css.h b/css/css.h index 3c27b0182..545e7e570 100644 --- a/css/css.h +++ b/css/css.h @@ -75,6 +75,7 @@ struct css_style { css_font_family font_family; css_font_weight font_weight; css_font_style font_style; + css_font_variant font_variant; struct { enum { CSS_HEIGHT_INHERIT, diff --git a/css/css_enums b/css/css_enums index 9dd77c9c3..c51e8acc7 100644 --- a/css/css_enums +++ b/css/css_enums @@ -9,7 +9,7 @@ css_display inherit inline block list-item run-in inline-block table inline-tabl css_float inherit none left right css_font_family inherit sans-serif serif monospace cursive fantasy css_font_style inherit normal italic oblique -css_font_variant normal smallcaps +css_font_variant inherit normal small-caps css_font_weight inherit normal bold bolder lighter 100 200 300 400 500 600 700 800 900 css_letter_spacing normal length css_list_style_position outside inside diff --git a/css/ruleset.c b/css/ruleset.c index 578704af6..6e7de6ba5 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -47,6 +47,7 @@ static void parse_font(struct css_style * const s, const struct css_node * v); static void parse_font_family(struct css_style * const s, const struct css_node * v); static void parse_font_size(struct css_style * const s, const struct css_node * const v); static void parse_font_style(struct css_style * const s, const struct css_node * const v); +static void parse_font_variant(struct css_style * const s, const struct css_node * const v); static void parse_font_weight(struct css_style * const s, const struct css_node * const v); static void parse_height(struct css_style * const s, const struct css_node * const v); static void parse_line_height(struct css_style * const s, const struct css_node * const v); @@ -70,6 +71,7 @@ static const struct property_entry property_table[] = { { "font-family", parse_font_family }, { "font-size", parse_font_size }, { "font-style", parse_font_style }, + { "font-variant", parse_font_variant }, { "font-weight", parse_font_weight }, { "height", parse_height }, { "line-height", parse_line_height }, @@ -399,6 +401,7 @@ void parse_font(struct css_style * const s, const struct css_node * v) { css_font_family ff; css_font_style fs; + css_font_variant fv; css_font_weight fw; s->font_family = CSS_FONT_FAMILY_SANS_SERIF; s->font_style = CSS_FONT_STYLE_NORMAL; @@ -414,13 +417,17 @@ void parse_font(struct css_style * const s, const struct css_node * v) s->font_family = ff; break; } - /* font-style, font-variant, or font-weight */ fs = css_font_style_parse(v->data); if (fs != CSS_FONT_STYLE_UNKNOWN) { s->font_style = fs; break; } + fv = css_font_variant_parse(v->data); + if (fv != CSS_FONT_VARIANT_UNKNOWN) { + s->font_variant = fv; + break; + } fw = css_font_weight_parse(v->data); if (fw != CSS_FONT_WEIGHT_UNKNOWN) { s->font_weight = fw; @@ -507,6 +514,16 @@ void parse_font_style(struct css_style * const s, const struct css_node * const s->font_style = z; } +void parse_font_variant(struct css_style * const s, const struct css_node * const v) +{ + css_font_variant z; + if (v->type != CSS_NODE_IDENT || v->next != 0) + return; + z = css_font_variant_parse(v->data); + if (z != CSS_FONT_VARIANT_UNKNOWN) + s->font_variant = z; +} + void parse_font_weight(struct css_style * const s, const struct css_node * const v) { css_font_weight z; @@ -516,6 +533,7 @@ void parse_font_weight(struct css_style * const s, const struct css_node * const if (z != CSS_FONT_WEIGHT_UNKNOWN) s->font_weight = z; } + void parse_height(struct css_style * const s, const struct css_node * const v) { if (v->type == CSS_NODE_IDENT && strcasecmp(v->data, "auto") == 0) -- cgit v1.2.3