]> git.lyx.org Git - features.git/commitdiff
** support for CJK font argument. File Format change **
authorJürgen Spitzmüller <spitz@lyx.org>
Thu, 5 Jun 2008 06:18:34 +0000 (06:18 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Thu, 5 Jun 2008 06:18:34 +0000 (06:18 +0000)
* 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

development/FORMAT
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/ui/FontUi.ui
src/output_latex.cpp

index c253117c72d2412d644cf19add97b6214693589c..b56bdc510cc0fef02ba8565a47ca491f425a3789 100644 (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.
 
index 3fda0029fba7c421e9c5e9bc180295a28da6df1b..00dbfefa908b14adbd7c943bd3ee80f70246d4b1 100644 (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]],
index ccba24493deeb45d7c6ca5bcdd746f528e6ab7ca..632826fbc6d8c485c52cbc37a1af46d7064affa3 100644 (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();
index b276c95a6034a78a05cb861b437a64b060eb56be..8df7ace37f7f5a603c5109d4b4c5cce92fc186f5 100644 (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';
index dae8c4e3b2a086149e513f1cdef6bfd13685d69b..fe85a3dab86da15f46170427b48490ac393efc02 100644 (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;
index e678a8170b0554242a8f9b0cdafb3e60e9909fa1..9cbaec7436d01f5c9b03d1a537968002d92992ac 100644 (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);
index 64ac16e8bdf9edb2c05d536f852f4eaf759d08d2..20d12b553e56579839d20358107573a71e247736 100644 (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>
      <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>
+      <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>&amp;Roman:</string>
+      <string>&amp;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>
-     </property>
-     <property name="minimum" >
-      <number>10</number>
+   <item row="3" column="1" >
+    <widget class="QComboBox" name="fontsSansCO" >
+     <property name="toolTip" >
+      <string>Select the Sans Serif (grotesque) typeface</string>
      </property>
     </widget>
    </item>
      </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>&amp;Sans Serif:</string>
+      <string>&amp;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>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>182</width>
-       <height>16</height>
-      </size>
+   <item row="2" column="1" >
+    <widget class="QComboBox" name="fontsRomanCO" >
+     <property name="toolTip" >
+      <string>Select the roman (serif) typeface</string>
      </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 &amp;Old Style Figures</string>
+      <string>&amp;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&amp;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>&amp;Default Family:</string>
+      <string>Sc&amp;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>&amp;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 2166425f07f7f8a3d9d9ccf06c799bfa2574dd78..da12b200128fe8a483b00a1f4e652887baa22ab4 100644 (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);
                }