Get font sizes working for XHTML.

This commit is contained in:
Richard Heck 2013-05-13 12:22:41 -04:00
parent c713030edb
commit 8b858d113f
3 changed files with 157 additions and 4 deletions

View File

@ -2867,6 +2867,8 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
bool shap_flag = false;
// family tags
bool faml_flag = false;
// size tags
bool size_flag = false;
Layout const & style = *d->layout_;
@ -2875,8 +2877,9 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
FontShape curr_fs = INHERIT_SHAPE;
FontFamily curr_fam = INHERIT_FAMILY;
FontShape curr_fs = INHERIT_SHAPE;
FontFamily curr_fam = INHERIT_FAMILY;
FontSize curr_size = FONT_SIZE_INHERIT;
string const default_family =
buf.masterBuffer()->params().fonts_default_family;
@ -2928,6 +2931,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
if (font_old.series() != font.fontInfo().series())
doFontSwitch(tagsToOpen, tagsToClose, bold_flag, curstate, html::FT_BOLD);
// Font shape
curr_fs = font.fontInfo().shape();
FontShape old_fs = font_old.shape();
if (old_fs != curr_fs) {
@ -2975,6 +2979,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
}
}
// Font family
curr_fam = font.fontInfo().family();
FontFamily old_fam = font_old.family();
if (old_fam != curr_fam) {
@ -3028,6 +3033,110 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
}
}
// Font size
curr_size = font.fontInfo().size();
FontSize old_size = font_old.size();
if (old_size != curr_size) {
if (size_flag) {
switch (old_size) {
case FONT_SIZE_TINY:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_TINY));
break;
case FONT_SIZE_SCRIPT:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SCRIPT));
break;
case FONT_SIZE_FOOTNOTE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_FOOTNOTE));
break;
case FONT_SIZE_SMALL:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SMALL));
break;
case FONT_SIZE_LARGE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGE));
break;
case FONT_SIZE_LARGER:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGER));
break;
case FONT_SIZE_LARGEST:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGEST));
break;
case FONT_SIZE_HUGE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGE));
break;
case FONT_SIZE_HUGER:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGER));
break;
case FONT_SIZE_INCREASE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_INCREASE));
break;
case FONT_SIZE_DECREASE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_DECREASE));
break;
case FONT_SIZE_INHERIT:
case FONT_SIZE_NORMAL:
break;
default:
// the other tags are for internal use
LATTEST(false);
break;
}
size_flag = false;
}
switch (curr_size) {
case FONT_SIZE_TINY:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_TINY));
size_flag = true;
break;
case FONT_SIZE_SCRIPT:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SCRIPT));
size_flag = true;
break;
case FONT_SIZE_FOOTNOTE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_FOOTNOTE));
size_flag = true;
break;
case FONT_SIZE_SMALL:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SMALL));
size_flag = true;
break;
case FONT_SIZE_LARGE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGE));
size_flag = true;
break;
case FONT_SIZE_LARGER:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGER));
size_flag = true;
break;
case FONT_SIZE_LARGEST:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGEST));
size_flag = true;
break;
case FONT_SIZE_HUGE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGE));
size_flag = true;
break;
case FONT_SIZE_HUGER:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGER));
size_flag = true;
break;
case FONT_SIZE_INCREASE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_INCREASE));
size_flag = true;
break;
case FONT_SIZE_DECREASE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_DECREASE));
size_flag = true;
break;
case FONT_SIZE_NORMAL:
case FONT_SIZE_INHERIT:
break;
default:
// the other tags are for internal use
LATTEST(false);
break;
}
}
// FIXME XHTML
// Other such tags? What about the other text ranges?

View File

@ -227,6 +227,18 @@ string fontToTag(html::FontTypes type)
case FT_ROMAN:
case FT_SANS:
case FT_TYPE:
case FT_SIZE_TINY:
case FT_SIZE_SCRIPT:
case FT_SIZE_FOOTNOTE:
case FT_SIZE_SMALL:
case FT_SIZE_NORMAL:
case FT_SIZE_LARGE:
case FT_SIZE_LARGER:
case FT_SIZE_LARGEST:
case FT_SIZE_HUGE:
case FT_SIZE_HUGER:
case FT_SIZE_INCREASE:
case FT_SIZE_DECREASE:
return "span";
}
// kill warning
@ -265,6 +277,26 @@ StartTag fontToStartTag(html::FontTypes type)
return html::StartTag(tag, "style='font-family:sans-serif;'");
case FT_TYPE:
return html::StartTag(tag, "style='font-family:monospace;'");
case FT_SIZE_TINY:
case FT_SIZE_SCRIPT:
case FT_SIZE_FOOTNOTE:
return html::StartTag(tag, "style='font-size:x-small;'");
case FT_SIZE_SMALL:
return html::StartTag(tag, "style='font-size:small;'");
case FT_SIZE_NORMAL:
return html::StartTag(tag, "style='font-size:normal;'");
case FT_SIZE_LARGE:
return html::StartTag(tag, "style='font-size:large;'");
case FT_SIZE_LARGER:
case FT_SIZE_LARGEST:
return html::StartTag(tag, "style='font-size:x-large;'");
case FT_SIZE_HUGE:
case FT_SIZE_HUGER:
return html::StartTag(tag, "style='font-size:xx-large;'");
case FT_SIZE_INCREASE:
return html::StartTag(tag, "style='font-size:larger;'");
case FT_SIZE_DECREASE:
return html::StartTag(tag, "style='font-size:smaller;'");
}
// kill warning
return StartTag("");

View File

@ -146,8 +146,20 @@ enum FontTypes {
// families
FT_ROMAN,
FT_SANS,
FT_TYPE
// SIZES?
FT_TYPE,
// sizes
FT_SIZE_TINY,
FT_SIZE_SCRIPT,
FT_SIZE_FOOTNOTE,
FT_SIZE_SMALL,
FT_SIZE_NORMAL,
FT_SIZE_LARGE,
FT_SIZE_LARGER,
FT_SIZE_LARGEST,
FT_SIZE_HUGE,
FT_SIZE_HUGER,
FT_SIZE_INCREASE,
FT_SIZE_DECREASE
};