From 455d441029f19046127d166892c6ffb98bcd4bcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Tue, 29 Apr 2008 00:03:55 +0000 Subject: [PATCH] - tex2lyx/text.cpp: correct font size handling because font size switches don't affect section headings, fixes bug 4807 - box-color-size-space-align.tex: add testcase for the above fix git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24550 a592a061-630c-0410-9148-cb99ea01b6c8 --- ...ign.tex => box-color-size-space-align.tex} | 14 ++++++++++ src/tex2lyx/text.cpp | 28 +++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) rename src/tex2lyx/{box-color-sizes-space-align.tex => box-color-size-space-align.tex} (97%) diff --git a/src/tex2lyx/box-color-sizes-space-align.tex b/src/tex2lyx/box-color-size-space-align.tex similarity index 97% rename from src/tex2lyx/box-color-sizes-space-align.tex rename to src/tex2lyx/box-color-size-space-align.tex index 7eab2a4ae8..5d34d8d358 100644 --- a/src/tex2lyx/box-color-sizes-space-align.tex +++ b/src/tex2lyx/box-color-size-space-align.tex @@ -147,6 +147,20 @@ test \textcolor{violet}{violet} test \Huge Huge text \huge huge text \LARGE LARGE text \Large Large text \large large text \normalsize normalsize text \small small text \footnotesize footnotesize text \scriptsize scriptsize text \tiny tiny text + +\normalsize Font size switches don't affect section headings! + +\scriptsize bla blub + +\section{Font size dummy 1} + +bla blub + +bla blub + +\section*{Font size dummy 2} + +bla blub \normalsize \section{Paragraph spacing} diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 6b3d724408..1f94459ca5 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -133,7 +133,7 @@ char const * const known_coded_quotes[] = { "prd", "ard", "ard", "ard", char const * const known_sizes[] = { "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large", "Large", "LARGE", "huge", "Huge", 0}; -/// the same as known_sizes with .lyx names +/// the same as known_sizes with .lyx names plus a default entry char const * const known_coded_sizes[] = { "default", "tiny", "scriptsize", "footnotesize", "small", "normal", "large", "larger", "largest", "huge", "giant", 0}; @@ -1536,22 +1536,44 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, eat_whitespace(p, os, context, true); } + // Starred section headings // Must attempt to parse "Section*" before "Section". else if ((p.next_token().asInput() == "*") && context.new_layout_allowed && - // The single '=' is meant here. (newlayout = findLayout(context.textclass, t.cs() + '*')) && newlayout->isCommand()) { + TeXFont const oldFont = context.font; + // save the current font size + string const size = oldFont.size; + // reset the font size to default, because the font size switches don't + // affect section headings and the like + context.font.size = known_coded_sizes[0]; + output_font_change(os, oldFont, context.font); + // write the layout p.get_token(); output_command_layout(os, p, outer, context, newlayout); + // set the font size to the original value + context.font.size = size; + output_font_change(os, oldFont, context.font); p.skip_spaces(); } - // The single '=' is meant here. + // Section headings and the like else if (context.new_layout_allowed && (newlayout = findLayout(context.textclass, t.cs())) && newlayout->isCommand()) { + TeXFont const oldFont = context.font; + // save the current font size + string const size = oldFont.size; + // reset the font size to default, because the font size switches don't + // affect section headings and the like + context.font.size = known_coded_sizes[0]; + output_font_change(os, oldFont, context.font); + // write the layout output_command_layout(os, p, outer, context, newlayout); + // set the font size to the original value + context.font.size = size; + output_font_change(os, oldFont, context.font); p.skip_spaces(); } -- 2.39.2