Pavel Sanda wrote: > Attached is the patch which is applicable against current master.
Slightly updated patch. P
diff --git a/development/FORMAT b/development/FORMAT index 1d24d92..406f076 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2016-02-16 Pavel Sanda <sa...@lyx.org> + * Format incremented to 507. + New parameters "\use_microtype bool" and "\microtype_params string" + for including microtype LaTeX package into preamble. + 2016-01-26 Guillaume Munch <g...@lyx.org> * Format incremented to 506 No new parameters. diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index b2b5731..e7078f1 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -86,7 +86,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)), ("1_6", list(range(277,346)), minor_versions("1.6" , 10)), ("2_0", list(range(346,414)), minor_versions("2.0" , 8)), ("2_1", list(range(414,475)), minor_versions("2.1" , 0)), - ("2_2", list(range(475,507)), minor_versions("2.2" , 0)) + ("2_2", list(range(475,508)), minor_versions("2.2" , 0)) ] #################################################################### diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py index a1f3005..165b47b 100644 --- a/lib/lyx2lyx/lyx_2_2.py +++ b/lib/lyx2lyx/lyx_2_2.py @@ -2212,6 +2212,17 @@ def revert_info_tabular_feature(document): return arg.replace("tabular-feature", "inset-modify tabular") convert_info_insets(document, "shortcut(s)?|icon", f) +def revert_microtype(document): + " Remove microtype settings. " + i = find_token(document.header, "\\use_microtype", 0) + if i == -1: + return + del document.header[i] + i = find_token(document.header, "\\microtype_params", 0) + if i == -1: + return + del document.header[i] + ## # Conversion hub @@ -2253,10 +2264,12 @@ convert = [ [503, []], [504, [convert_save_props]], [505, []], - [506, [convert_info_tabular_feature]] + [506, [convert_info_tabular_feature]], + [507, []] ] revert = [ + [506, [revert_microtype]], [505, [revert_info_tabular_feature]], [504, []], [503, [revert_save_props]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 37dcbca..fda7768 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -887,6 +887,7 @@ int Buffer::readHeader(Lexer & lex) params().footskip.erase(); params().columnsep.erase(); params().fonts_cjk.erase(); + params().microtype_params.erase(); params().listings_params.clear(); params().clearLayoutModules(); params().clearRemovedModules(); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 9d121cb..05c8f00 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -388,6 +388,7 @@ BufferParams::BufferParams() fonts_math[1] = "auto"; fonts_default_family = "default"; useNonTeXFonts = false; + use_microtype = false; fonts_expert_sc = false; fonts_old_figures = false; fonts_sans_scale[0] = 100; @@ -771,6 +772,10 @@ string BufferParams::readToken(Lexer & lex, string const & token, lex >> fonts_typewriter_scale[1]; } else if (token == "\\font_cjk") { lex >> fonts_cjk; + } else if (token == "\\use_microtype") { + lex >> use_microtype; + } else if (token == "\\microtype_params") { + lex >> microtype_params; } else if (token == "\\paragraph_separation") { string parsep; lex >> parsep; @@ -1139,6 +1144,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const if (!fonts_cjk.empty()) { os << "\\font_cjk " << fonts_cjk << '\n'; } + os << "\\use_microtype " << convert<string>(use_microtype) << '\n'; + if (!microtype_params.empty()) + os << "\\microtype_params " << microtype_params << '\n'; os << "\\graphics " << graphics_driver << '\n'; os << "\\default_output_format " << default_output_format << '\n'; os << "\\output_sync " << output_sync << '\n'; @@ -1412,6 +1420,9 @@ void BufferParams::validate(LaTeXFeatures & features) const if (useNonTeXFonts && fontsMath() != "auto") features.require("unicode-math"); + if (use_microtype) + features.require("microtype"); + if (!language->requires().empty()) features.require(language->requires()); } diff --git a/src/BufferParams.h b/src/BufferParams.h index caae01d..f4baa4d 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -279,6 +279,10 @@ public: int fontsTypewriterScale() const { return fonts_typewriter_scale[useNonTeXFonts]; } /// the font used by the CJK command std::string fonts_cjk; + /// use LaTeX microtype package + bool use_microtype; + /// + std::string microtype_params; /// Spacing & spacing(); Spacing const & spacing() const; diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 4fa2c82..69dda2d 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -938,6 +938,13 @@ string const LaTeXFeatures::getPackages() const // The rest of these packages are somewhat more complicated // than those above. + if (mustProvide("microtype")){ + packages << "\\usepackage"; + if (!params_.microtype_params.empty()) + packages << "["<<params_.microtype_params<<"]"; + packages << "{microtype}\n"; + } + // The tipa package and its extensions (tipx, tone) must not // be loaded with non-TeX fonts, since fontspec includes the // respective macros diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index cf64849..ff19c55 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -807,6 +807,10 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); + connect(fontModule->microtypeCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); + connect(fontModule->microtypeLE, SIGNAL(textChanged(const QString &)), + this, SLOT(change_adaptor())); connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), @@ -824,6 +828,8 @@ GuiDocument::GuiDocument(GuiView & lv) fontModule->fontencLE)); fontModule->cjkFontLE->setValidator(new NoNewLineValidator( fontModule->cjkFontLE)); + fontModule->microtypeLE->setValidator(new NoNewLineValidator( + fontModule->microtypeLE)); updateFontlist(); @@ -2887,6 +2893,9 @@ void GuiDocument::applyView() bp_.fonts_cjk = fromqstr(fontModule->cjkFontLE->text()); + bp_.use_microtype = fontModule->microtypeCB->isChecked(); + bp_.microtype_params = fromqstr(fontModule->microtypeLE->text()); + bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value(); bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale; @@ -3364,6 +3373,9 @@ void GuiDocument::paramsToDialog() else fontModule->cjkFontLE->setText(QString()); + fontModule->microtypeCB->setChecked(bp_.use_microtype); + fontModule->microtypeLE->setText(toqstr(bp_.microtype_params)); + fontModule->fontScCB->setChecked(bp_.fonts_expert_sc); fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures); fontModule->scaleSansSB->setValue(bp_.fontsSansScale()); diff --git a/src/frontends/qt4/ui/FontUi.ui b/src/frontends/qt4/ui/FontUi.ui index ba7a5ea..8ad26fd 100644 --- a/src/frontends/qt4/ui/FontUi.ui +++ b/src/frontends/qt4/ui/FontUi.ui @@ -6,47 +6,14 @@ <rect> <x>0</x> <y>0</y> - <width>407</width> - <height>285</height> + <width>464</width> + <height>312</height> </rect> </property> <property name="windowTitle"> <string>FontUi</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="osFontsCB"> - <property name="toolTip"> - <string>Use OpenType and TrueType fonts with the fontspec package (requires XeTeX or LuaTeX)</string> - </property> - <property name="text"> - <string>&Use non-TeX fonts (via XeTeX/LuaTeX)</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>59</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="fontsDefaultLA"> - <property name="text"> - <string>&Default family:</string> - </property> - <property name="buddy"> - <cstring>fontsDefaultCO</cstring> - </property> - </widget> - </item> <item row="1" column="1"> <widget class="QComboBox" name="fontsDefaultCO"> <property name="toolTip"> @@ -108,6 +75,39 @@ </property> </widget> </item> + <item row="0" column="0" colspan="2"> + <widget class="QCheckBox" name="osFontsCB"> + <property name="toolTip"> + <string>Use OpenType and TrueType fonts with the fontspec package (requires XeTeX or LuaTeX)</string> + </property> + <property name="text"> + <string>&Use non-TeX fonts (via XeTeX/LuaTeX)</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>59</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="fontsDefaultLA"> + <property name="text"> + <string>&Default family:</string> + </property> + <property name="buddy"> + <cstring>fontsDefaultCO</cstring> + </property> + </widget> + </item> <item row="4" column="0"> <widget class="QLabel" name="fontsSansLA"> <property name="text"> @@ -135,6 +135,13 @@ </property> </widget> </item> + <item row="5" column="1"> + <widget class="QComboBox" name="fontsTypewriterCO"> + <property name="toolTip"> + <string>Select the typewriter (monospaced) typeface</string> + </property> + </widget> + </item> <item row="4" column="3"> <widget class="QSpinBox" name="scaleSansSB"> <property name="toolTip"> @@ -158,13 +165,6 @@ </property> </widget> </item> - <item row="5" column="1"> - <widget class="QComboBox" name="fontsTypewriterCO"> - <property name="toolTip"> - <string>Select the typewriter (monospaced) typeface</string> - </property> - </widget> - </item> <item row="5" column="2"> <widget class="QLabel" name="scaleTypewriterLA"> <property name="text"> @@ -175,6 +175,13 @@ </property> </widget> </item> + <item row="6" column="1"> + <widget class="QComboBox" name="fontsMathCO"> + <property name="toolTip"> + <string>Select the math typeface</string> + </property> + </widget> + </item> <item row="5" column="3"> <widget class="QSpinBox" name="scaleTypewriterSB"> <property name="toolTip"> @@ -198,13 +205,6 @@ </property> </widget> </item> - <item row="6" column="1"> - <widget class="QComboBox" name="fontsMathCO"> - <property name="toolTip"> - <string>Select the math typeface</string> - </property> - </widget> - </item> <item row="7" column="0"> <widget class="QLabel" name="cjkFontLA"> <property name="text"> @@ -215,14 +215,7 @@ </property> </widget> </item> - <item row="7" 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="8" column="1"> + <item row="9" column="1"> <widget class="QCheckBox" name="fontScCB"> <property name="toolTip"> <string>Use a real small caps shape, if the font provides one</string> @@ -232,17 +225,7 @@ </property> </widget> </item> - <item row="9" column="1"> - <widget class="QCheckBox" name="fontOsfCB"> - <property name="toolTip"> - <string>Use old style instead of lining figures</string> - </property> - <property name="text"> - <string>Use &old style figures</string> - </property> - </widget> - </item> - <item row="10" column="1"> + <item row="12" column="1"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -255,6 +238,40 @@ </property> </spacer> </item> + <item row="7" 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="10" column="1"> + <widget class="QCheckBox" name="fontOsfCB"> + <property name="toolTip"> + <string>Use old style instead of lining figures</string> + </property> + <property name="text"> + <string>Use &old style figures</string> + </property> + </widget> + </item> + <item row="8" column="1"> + <widget class="QLineEdit" name="microtypeLE"> + <property name="toolTip"> + <string>Specific parameters for microtype.</string> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QCheckBox" name="microtypeCB"> + <property name="toolTip"> + <string>Use microtype LaTeX package</string> + </property> + <property name="text"> + <string>Use micr&otype</string> + </property> + </widget> + </item> </layout> </widget> <layoutdefault spacing="6" margin="11"/> @@ -269,7 +286,10 @@ <tabstop>scaleSansSB</tabstop> <tabstop>fontsTypewriterCO</tabstop> <tabstop>scaleTypewriterSB</tabstop> + <tabstop>fontsMathCO</tabstop> <tabstop>cjkFontLE</tabstop> + <tabstop>microtypeCB</tabstop> + <tabstop>microtypeLE</tabstop> <tabstop>fontScCB</tabstop> <tabstop>fontOsfCB</tabstop> </tabstops> diff --git a/src/version.h b/src/version.h index 9a37739..64760b5 100644 --- a/src/version.h +++ b/src/version.h @@ -32,7 +32,7 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 506 // guillaume munch: convert "inset-modify tabular" +#define LYX_FORMAT_LYX 507 // ps: microtype #define LYX_FORMAT_TEX2LYX 506 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX