** 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 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> 2008-05-30 Richard Heck <rgheck@brown.edu>
* Format incremented to 335: fixes for InsetSpace problems. * 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') 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): def convert_plain_layout(document):
" Convert 'PlainLayout' to 'Plain Layout'" " Convert 'PlainLayout' to 'Plain Layout'"
i = 0 i = 0
@ -2602,9 +2609,11 @@ convert = [[277, [fix_wrong_tables]],
[333, [update_apa_styles]], [333, [update_apa_styles]],
[334, [convert_paper_sizes]], [334, [convert_paper_sizes]],
[335, [convert_InsetSpace]], [335, [convert_InsetSpace]],
[336, []],
] ]
revert = [[334, [revert_InsetSpace]], revert = [[335, [remove_fontsCJK]],
[334, [revert_InsetSpace]],
[333, [revert_paper_sizes]], [333, [revert_paper_sizes]],
[332, []], [332, []],
[331, [revert_graphics_group]], [331, [revert_graphics_group]],

View File

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

View File

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

View File

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

View File

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

View File

@ -5,8 +5,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>409</width> <width>414</width>
<height>232</height> <height>268</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -19,7 +19,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="7" column="0" colspan="4" > <item row="8" column="0" colspan="4" >
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -30,100 +30,92 @@
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>391</width> <width>391</width>
<height>21</height> <height>16</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </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> <spacer>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>131</width> <width>151</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="3" > <item row="7" column="1" >
<widget class="QSpinBox" name="scaleTypewriterSB" > <widget class="QCheckBox" name="fontOsfCB" >
<property name="maximum" > <property name="toolTip" >
<number>200</number> <string>Use old style instead of lining figures</string>
</property> </property>
<property name="minimum" > <property name="text" >
<number>10</number> <string>Use &amp;Old Style Figures</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="2" > <item row="6" column="1" >
<widget class="QLabel" name="scaleTypewriterLA" > <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" > <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>
<property name="buddy" > <property name="buddy" >
<cstring>scaleTypewriterSB</cstring> <cstring>fontsizeCO</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" > <item row="0" column="3" >
<widget class="QComboBox" name="fontsTypewriterCO" /> <widget class="QComboBox" name="fontsizeCO" >
<property name="toolTip" >
<string/>
</property>
</widget>
</item> </item>
<item row="4" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="fontsTypewriterLA" > <widget class="QLabel" name="fontsDefaultLA" >
<property name="text" > <property name="text" >
<string>&amp;Typewriter:</string> <string>&amp;Default Family:</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>fontsTypewriterCO</cstring> <cstring>fontsDefaultCO</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>
</property> </property>
</widget> </widget>
</item> </item>
@ -140,45 +132,115 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="1" > <item row="3" column="0" >
<widget class="QCheckBox" name="fontOsfCB" > <widget class="QLabel" name="fontsSansLA" >
<property name="text" > <property name="text" >
<string>Use &amp;Old Style Figures</string> <string>&amp;Sans Serif:</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>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>fontsDefaultCO</cstring> <cstring>fontsSansCO</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3" > <item row="3" column="1" >
<widget class="QComboBox" name="fontsizeCO" /> <widget class="QComboBox" name="fontsSansCO" >
<property name="toolTip" >
<string>Select the Sans Serif (grotesque) typeface</string>
</property>
</widget>
</item> </item>
<item row="0" column="2" > <item row="3" column="2" >
<widget class="QLabel" name="TextLabel2_2" > <widget class="QLabel" name="scaleSansLA" >
<property name="text" > <property name="text" >
<string>&amp;Base Size:</string> <string>S&amp;cale (%):</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>fontsizeCO</cstring> <cstring>scaleSansSB</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="3" column="3" >
<widget class="QComboBox" name="fontsDefaultCO" /> <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> </item>
</layout> </layout>
</widget> </widget>

View File

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