** support for CJK font argument. File Format change **

* src/BufferParams.{cpp,h}:
	- new param fontsCJK (font_cjk).

* src/output_latex.cpp:
	- use fontsCJK param.

* src/Buffer.cpp:
	- increase file format

* src/frontends/qt4/GuiDocument.cpp:
* src/frontends/qt4/ui/FontUi.ui:
	- GUI for the CJK font param

* lib/lyx2lyx/lyx_1_6.py:
	- remove font_cjk param on reversion.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25135 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-06-05 06:18:34 +00:00
parent 45a8fed1d5
commit d7eaaba900
8 changed files with 196 additions and 101 deletions

View File

@ -1,6 +1,9 @@
LyX file-format changes
-----------------------
2008-06-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* Format incremented to 336: new param \font_cjk.
2008-05-30 Richard Heck <rgheck@brown.edu>
* Format incremented to 335: fixes for InsetSpace problems.

View File

@ -2500,6 +2500,13 @@ def revert_InsetSpace(document):
document.body[i] = document.body[i].replace('\\begin_inset space', '\\begin_inset Space')
def remove_fontsCJK(document):
' Remove font_cjk param '
i = find_token(document.header, "\\font_cjk", 0)
if i != -1:
del document.header[i]
def convert_plain_layout(document):
" Convert 'PlainLayout' to 'Plain Layout'"
i = 0
@ -2602,9 +2609,11 @@ convert = [[277, [fix_wrong_tables]],
[333, [update_apa_styles]],
[334, [convert_paper_sizes]],
[335, [convert_InsetSpace]],
[336, []],
]
revert = [[334, [revert_InsetSpace]],
revert = [[335, [remove_fontsCJK]],
[334, [revert_InsetSpace]],
[333, [revert_paper_sizes]],
[332, []],
[331, [revert_graphics_group]],

View File

@ -115,7 +115,7 @@ namespace os = support::os;
namespace {
int const LYX_FORMAT = 335;
int const LYX_FORMAT = 336;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@ -459,6 +459,7 @@ int Buffer::readHeader(Lexer & lex)
params().headsep.erase();
params().footskip.erase();
params().columnsep.erase();
params().fontsCJK.erase();
params().listings_params.clear();
params().clearLayoutModules();
params().pdfoptions().clear();

View File

@ -522,6 +522,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
lex >> fontsSansScale;
} else if (token == "\\font_tt_scale") {
lex >> fontsTypewriterScale;
} else if (token == "\\font_cjk") {
lex >> fontsCJK;
} else if (token == "\\paragraph_separation") {
string parsep;
lex >> parsep;
@ -727,7 +729,11 @@ void BufferParams::writeFile(ostream & os) const
<< "\n\\font_osf " << convert<string>(fontsOSF)
<< "\n\\font_sf_scale " << fontsSansScale
<< "\n\\font_tt_scale " << fontsTypewriterScale
<< "\n\\graphics " << graphicsDriver << '\n';
<< '\n';
if (!fontsCJK.empty()) {
os << "\\font_cjk " << fontsCJK << '\n';
}
os << "\n\\graphics " << graphicsDriver << '\n';
if (!float_placement.empty()) {
os << "\\float_placement " << float_placement << '\n';

View File

@ -185,6 +185,8 @@ public:
int fontsSansScale;
/// the scale factor of the tt font
int fontsTypewriterScale;
/// the font used by the CJK command
std::string fontsCJK;
///
Spacing & spacing();
Spacing const & spacing() const;

View File

@ -605,6 +605,8 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
@ -1647,6 +1649,9 @@ void GuiDocument::apply(BufferParams & params)
params.fontsTypewriter =
tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
params.fontsCJK =
fromqstr(fontModule->cjkFontLE->text());
params.fontsSansScale = fontModule->scaleSansSB->value();
params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
@ -1945,6 +1950,12 @@ void GuiDocument::paramsToDialog(BufferParams const & params)
ttChanged(n);
}
if (!params.fontsCJK.empty())
fontModule->cjkFontLE->setText(
toqstr(params.fontsCJK));
else
fontModule->cjkFontLE->setText(QString());
fontModule->fontScCB->setChecked(params.fontsSC);
fontModule->fontOsfCB->setChecked(params.fontsOSF);
fontModule->scaleSansSB->setValue(params.fontsSansScale);

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>409</width>
<height>232</height>
<width>414</width>
<height>268</height>
</rect>
</property>
<property name="windowTitle" >
@ -19,7 +19,7 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="7" column="0" colspan="4" >
<item row="8" column="0" colspan="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
@ -30,100 +30,92 @@
<property name="sizeHint" >
<size>
<width>391</width>
<height>21</height>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2" >
<item row="5" column="0" >
<widget class="QLabel" name="cjkFontLA" >
<property name="text" >
<string>C&amp;JK:</string>
</property>
<property name="buddy" >
<cstring>cjkFontLE</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLineEdit" name="cjkFontLE" >
<property name="toolTip" >
<string>Input the font to be used for Chinese, Japanese or Korean (CJK) script</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="3" >
<widget class="QSpinBox" name="scaleTypewriterSB" >
<property name="maximum" >
<number>200</number>
<item row="7" column="1" >
<widget class="QCheckBox" name="fontOsfCB" >
<property name="toolTip" >
<string>Use old style instead of lining figures</string>
</property>
<property name="minimum" >
<number>10</number>
<property name="text" >
<string>Use &amp;Old Style Figures</string>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QLabel" name="scaleTypewriterLA" >
<item row="6" column="1" >
<widget class="QCheckBox" name="fontScCB" >
<property name="toolTip" >
<string>Use a real small caps shape, if the font provides one</string>
</property>
<property name="text" >
<string>Sc&amp;ale (%):</string>
<string>Use true S&amp;mall Caps</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="fontsDefaultCO" >
<property name="toolTip" >
<string>Select the default family for the document</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="TextLabel2_2" >
<property name="text" >
<string>&amp;Base Size:</string>
</property>
<property name="buddy" >
<cstring>scaleTypewriterSB</cstring>
<cstring>fontsizeCO</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QComboBox" name="fontsTypewriterCO" />
<item row="0" column="3" >
<widget class="QComboBox" name="fontsizeCO" >
<property name="toolTip" >
<string/>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="fontsTypewriterLA" >
<item row="0" column="0" >
<widget class="QLabel" name="fontsDefaultLA" >
<property name="text" >
<string>&amp;Typewriter:</string>
<string>&amp;Default Family:</string>
</property>
<property name="buddy" >
<cstring>fontsTypewriterCO</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QComboBox" name="fontsRomanCO" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="fontsRomanLA" >
<property name="text" >
<string>&amp;Roman:</string>
</property>
<property name="buddy" >
<cstring>fontsRomanCO</cstring>
</property>
</widget>
</item>
<item row="3" column="3" >
<widget class="QSpinBox" name="scaleSansSB" >
<property name="maximum" >
<number>200</number>
</property>
<property name="minimum" >
<number>10</number>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="QLabel" name="scaleSansLA" >
<property name="text" >
<string>S&amp;cale (%):</string>
</property>
<property name="buddy" >
<cstring>scaleSansSB</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QComboBox" name="fontsSansCO" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="fontsSansLA" >
<property name="text" >
<string>&amp;Sans Serif:</string>
</property>
<property name="buddy" >
<cstring>fontsSansCO</cstring>
<cstring>fontsDefaultCO</cstring>
</property>
</widget>
</item>
@ -140,45 +132,115 @@
</property>
</spacer>
</item>
<item row="6" column="1" >
<widget class="QCheckBox" name="fontOsfCB" >
<item row="3" column="0" >
<widget class="QLabel" name="fontsSansLA" >
<property name="text" >
<string>Use &amp;Old Style Figures</string>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QCheckBox" name="fontScCB" >
<property name="text" >
<string>Use true S&amp;mall Caps</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="fontsDefaultLA" >
<property name="text" >
<string>&amp;Default Family:</string>
<string>&amp;Sans Serif:</string>
</property>
<property name="buddy" >
<cstring>fontsDefaultCO</cstring>
<cstring>fontsSansCO</cstring>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QComboBox" name="fontsizeCO" />
<item row="3" column="1" >
<widget class="QComboBox" name="fontsSansCO" >
<property name="toolTip" >
<string>Select the Sans Serif (grotesque) typeface</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="TextLabel2_2" >
<item row="3" column="2" >
<widget class="QLabel" name="scaleSansLA" >
<property name="text" >
<string>&amp;Base Size:</string>
<string>S&amp;cale (%):</string>
</property>
<property name="buddy" >
<cstring>fontsizeCO</cstring>
<cstring>scaleSansSB</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="fontsDefaultCO" />
<item row="3" column="3" >
<widget class="QSpinBox" name="scaleSansSB" >
<property name="toolTip" >
<string>Scale the Sans Serif font to match the base font's dimensions</string>
</property>
<property name="maximum" >
<number>200</number>
</property>
<property name="minimum" >
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="fontsRomanLA" >
<property name="text" >
<string>&amp;Roman:</string>
</property>
<property name="buddy" >
<cstring>fontsRomanCO</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QComboBox" name="fontsRomanCO" >
<property name="toolTip" >
<string>Select the roman (serif) typeface</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="fontsTypewriterLA" >
<property name="text" >
<string>&amp;Typewriter:</string>
</property>
<property name="buddy" >
<cstring>fontsTypewriterCO</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QComboBox" name="fontsTypewriterCO" >
<property name="toolTip" >
<string>Select the typewriter (monospaced) typeface</string>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QLabel" name="scaleTypewriterLA" >
<property name="text" >
<string>Sc&amp;ale (%):</string>
</property>
<property name="buddy" >
<cstring>scaleTypewriterSB</cstring>
</property>
</widget>
</item>
<item row="4" column="3" >
<widget class="QSpinBox" name="scaleTypewriterSB" >
<property name="toolTip" >
<string>Scale the Typewriter font to match the base font's dimensions</string>
</property>
<property name="maximum" >
<number>200</number>
</property>
<property name="minimum" >
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>

View File

@ -183,7 +183,7 @@ TeXEnvironment(Buffer const & buf,
if (par_language->encoding()->package() == Encoding::CJK &&
open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
<< "}{}%\n";
<< "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
open_encoding_ = CJK;
cjk_nested = true;
texrow.newline();
@ -453,7 +453,7 @@ TeXOnePar(Buffer const & buf,
if (par_language->encoding()->package() == Encoding::CJK &&
open_encoding_ != CJK && cjk_inherited_ == 0) {
os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
<< "}{}%\n";
<< "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
open_encoding_ = CJK;
texrow.newline();
}
@ -760,7 +760,7 @@ void latexParagraphs(Buffer const & buf,
// if the document's language is a CJK language
if (maintext && bparams.encoding().package() == Encoding::CJK) {
os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
<< "}{}%\n";
<< "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
texrow.newline();
open_encoding_ = CJK;
}
@ -937,7 +937,8 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
os << "\\egroup";
count += 7;
}
os << "\\begin{CJK}{" << inputenc_arg << "}{}";
os << "\\begin{CJK}{" << inputenc_arg << "}{"
<< from_ascii(bparams.fontsCJK) << "}";
open_encoding_ = CJK;
return make_pair(true, count + 15);
}