The attached patch lets the user customize the font argument in the CJK command
\begin{CJK}{<encoding>}{<font>} globally on a per-document basis (in Document->Settings->Fonts). Currently, this argument is always empty, which means that CJK falls back to the default font (song). This apparently does not work for many users, and I also think that restricting CJK to one font only is a bit boring. Being not a CJK user myself, I'm not sure if we should also support different fonts for different (CJK) scripts, which would mean that the CJK font should also be customizable in the paragraph dialog. However, that's something for later anyway. Since this is a file format change and we're in a freeze (?), I'm awaiting José's decision. Jürgen
Index: lib/lyx2lyx/lyx_1_6.py =================================================================== --- lib/lyx2lyx/lyx_1_6.py (Revision 25111) +++ lib/lyx2lyx/lyx_1_6.py (Arbeitskopie) @@ -2482,6 +2482,13 @@ 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] + + ## # Conversion hub # @@ -2546,9 +2553,11 @@ [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]], Index: development/FORMAT =================================================================== --- development/FORMAT (Revision 25111) +++ development/FORMAT (Arbeitskopie) @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2008-06-04 Jürgen Spitzmüller <[EMAIL PROTECTED]> + * Format incremented to 336: new param \font_cjk. + 2008-05-30 Richard Heck <[EMAIL PROTECTED]> * Format incremented to 335: fixes for InsetSpace problems. Index: src/BufferParams.h =================================================================== --- src/BufferParams.h (Revision 25111) +++ src/BufferParams.h (Arbeitskopie) @@ -185,6 +185,8 @@ 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; Index: src/frontends/qt4/GuiDocument.cpp =================================================================== --- src/frontends/qt4/GuiDocument.cpp (Revision 25111) +++ src/frontends/qt4/GuiDocument.cpp (Arbeitskopie) @@ -605,6 +605,8 @@ 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 @@ 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 @@ 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); Index: src/frontends/qt4/ui/FontUi.ui =================================================================== --- src/frontends/qt4/ui/FontUi.ui (Revision 25111) +++ src/frontends/qt4/ui/FontUi.ui (Arbeitskopie) @@ -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,78 +30,123 @@ <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&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 &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&ale (%):</string> + <string>Use true S&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>&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>&Typewriter:</string> + <string>&Default Family:</string> </property> <property name="buddy" > - <cstring>fontsTypewriterCO</cstring> + <cstring>fontsDefaultCO</cstring> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QComboBox" name="fontsRomanCO" /> + <item row="1" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>182</width> + <height>16</height> + </size> + </property> + </spacer> </item> - <item row="2" column="0" > - <widget class="QLabel" name="fontsRomanLA" > + <item row="3" column="0" > + <widget class="QLabel" name="fontsSansLA" > <property name="text" > - <string>&Roman:</string> + <string>&Sans Serif:</string> </property> <property name="buddy" > - <cstring>fontsRomanCO</cstring> + <cstring>fontsSansCO</cstring> </property> </widget> </item> - <item row="3" column="3" > - <widget class="QSpinBox" name="scaleSansSB" > - <property name="maximum" > - <number>200</number> + <item row="3" column="1" > + <widget class="QComboBox" name="fontsSansCO" > + <property name="toolTip" > + <string>Select the Sans Serif (grotesque) typeface</string> </property> - <property name="minimum" > - <number>10</number> - </property> </widget> </item> <item row="3" column="2" > @@ -114,71 +159,88 @@ </property> </widget> </item> - <item row="3" column="1" > - <widget class="QComboBox" name="fontsSansCO" /> + <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="3" column="0" > - <widget class="QLabel" name="fontsSansLA" > + <item row="2" column="0" > + <widget class="QLabel" name="fontsRomanLA" > <property name="text" > - <string>&Sans Serif:</string> + <string>&Roman:</string> </property> <property name="buddy" > - <cstring>fontsSansCO</cstring> + <cstring>fontsRomanCO</cstring> </property> </widget> </item> - <item row="1" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> + <item row="2" column="1" > + <widget class="QComboBox" name="fontsRomanCO" > + <property name="toolTip" > + <string>Select the roman (serif) typeface</string> </property> - <property name="sizeHint" > - <size> - <width>182</width> - <height>16</height> - </size> - </property> - </spacer> + </widget> </item> - <item row="6" column="1" > - <widget class="QCheckBox" name="fontOsfCB" > + <item row="4" column="0" > + <widget class="QLabel" name="fontsTypewriterLA" > <property name="text" > - <string>Use &Old Style Figures</string> + <string>&Typewriter:</string> </property> + <property name="buddy" > + <cstring>fontsTypewriterCO</cstring> + </property> </widget> </item> - <item row="5" column="1" > - <widget class="QCheckBox" name="fontScCB" > - <property name="text" > - <string>Use true S&mall Caps</string> + <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="0" column="0" > - <widget class="QLabel" name="fontsDefaultLA" > + <item row="4" column="2" > + <widget class="QLabel" name="scaleTypewriterLA" > <property name="text" > - <string>&Default Family:</string> + <string>Sc&ale (%):</string> </property> <property name="buddy" > - <cstring>fontsDefaultCO</cstring> + <cstring>scaleTypewriterSB</cstring> </property> </widget> </item> - <item row="0" column="3" > - <widget class="QComboBox" name="fontsizeCO" /> - </item> - <item row="0" column="2" > - <widget class="QLabel" name="TextLabel2_2" > - <property name="text" > - <string>&Base Size:</string> + <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="buddy" > - <cstring>fontsizeCO</cstring> + <property name="maximum" > + <number>200</number> </property> + <property name="minimum" > + <number>10</number> + </property> </widget> </item> - <item row="0" column="1" > - <widget class="QComboBox" name="fontsDefaultCO" /> + <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> Index: src/output_latex.cpp =================================================================== --- src/output_latex.cpp (Revision 25111) +++ src/output_latex.cpp (Arbeitskopie) @@ -183,7 +183,7 @@ 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 @@ 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 @@ // 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 @@ 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); } Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (Revision 25111) +++ src/Buffer.cpp (Arbeitskopie) @@ -115,7 +115,7 @@ 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; @@ -453,6 +453,7 @@ params().headsep.erase(); params().footskip.erase(); params().columnsep.erase(); + params().fontsCJK.erase(); params().listings_params.clear(); params().clearLayoutModules(); params().pdfoptions().clear(); Index: src/BufferParams.cpp =================================================================== --- src/BufferParams.cpp (Revision 25111) +++ src/BufferParams.cpp (Arbeitskopie) @@ -522,6 +522,8 @@ 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 @@ << "\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';