diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2004-01-31 21:18:44 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2004-01-31 21:18:44 +0000 |
commit | 00ef17153cd5e0b4fe47dddea4db74450ee06bb1 (patch) | |
tree | 7beebb42d0dce3874ce6106ec306ee504975054e /render/box.c | |
parent | f53642c94b8a7bcdddc0bd6e7fcb248403d50ae4 (diff) | |
download | netsurf-00ef17153cd5e0b4fe47dddea4db74450ee06bb1.tar.gz netsurf-00ef17153cd5e0b4fe47dddea4db74450ee06bb1.tar.bz2 |
[project @ 2004-01-31 21:18:44 by jmb]
text-transform support.
svn path=/import/netsurf/; revision=521
Diffstat (limited to 'render/box.c')
-rw-r--r-- | render/box.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/render/box.c b/render/box.c index e51078a12..4a9bdb9fc 100644 --- a/render/box.c +++ b/render/box.c @@ -389,6 +389,33 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content, box->space = 1; box->length--; } + switch (parent_style->text_transform) { + /* perform text-transform */ + unsigned int ch; + case CSS_TEXT_TRANSFORM_UPPERCASE: + for (ch=0; ch!=box->length; ch++) { + box->text[ch] = toupper(box->text[ch]); + } + break; + case CSS_TEXT_TRANSFORM_LOWERCASE: + for (ch=0; ch!=box->length; ch++) { + box->text[ch] = tolower(box->text[ch]); + } + break; + case CSS_TEXT_TRANSFORM_CAPITALIZE: + for (ch=0; ch!=box->length; ch++) { + if (ch == 0) { + box->text[ch] = toupper(box->text[ch]); + } + else if (!((box->text[ch-1] > 64 && box->text[ch-1] < 91) || + (box->text[ch-1] > 96 && box->text[ch-1] < 123))) { + box->text[ch] = toupper(box->text[ch]); + } + } + break; + default: + break; + } if (parent_style->white_space == CSS_WHITE_SPACE_NOWRAP) { unsigned int i; for (i = 0; i != box->length; i++) @@ -431,6 +458,37 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content, box->style_clone = 1; box->text = xstrdup(current); box->length = strlen(box->text); + switch (parent_style->text_transform) { + /* perform text-transform */ + unsigned int ch; + case CSS_TEXT_TRANSFORM_UPPERCASE: + for (ch=0; ch!=box->length; ch++) { + box->text[ch] = + toupper(box->text[ch]); + } + break; + case CSS_TEXT_TRANSFORM_LOWERCASE: + for (ch=0; ch!=box->length; ch++) { + box->text[ch] = + tolower(box->text[ch]); + } + break; + case CSS_TEXT_TRANSFORM_CAPITALIZE: + for (ch=0; ch!=box->length; ch++) { + if (ch == 0) { + box->text[ch] = + toupper(box->text[ch]); + } + else if (!((box->text[ch-1] > 64 && box->text[ch-1] < 91) || + (box->text[ch-1] > 96 && box->text[ch-1] < 123))) { + box->text[ch] = + toupper(box->text[ch]); + } + } + break; + default: + break; + } box->font = font_open(content->data.html.fonts, box->style); box_add_child(inline_container, box); current[len] = old; |