So updated patch for master. I decided to make fileformat change instead of module.
Will commit unless there are some comments. Pavel Sanda wrote: > Guenter Milde wrote: > > I got the same impression after some tests with a *.tex file here. > > This is also what the documentation tells: it works for all three of > > pdflatex, xelatex, and lualatex but only pdflatex supports all features. > > There is no error with "plain" latex (DVI, PS, PDF (ps2pdf), PDF (dvipdfm) > > but no effect either. > > > > A tooltip should hint to limited support (linking to the documentation) Done. > > > People who use custom parameters are on their own. But is there an > > > advantage of letting users enter custom params via a line edit, instead > > > of letting them write it by hand in the preamble? It does not seem to > > > me that the GUI helps here. Or do you have further plans for this > > > feature? > > I do not have plan, just got some (unf.) private response to this thread. > I will ask on users list whether people tend to use some params. Since people on users list did use params either, I killed the optional line edit. Pavel
diff --git a/development/FORMAT b/development/FORMAT index 01319df..f7bb30f 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2016-06-16 Pavel Sanda <sa...@lyx.org> + * Format incremented to 509. + New parameter "\use_microtype bool" for including microtype LaTeX + package into preamble. + 2016-04-05 Enrico Forestieri <for...@lyx.org> * Format incremented to 508 New kind of Separator inset (latexpar). The old parbreak separator diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 1e2147d..fa2bbba 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -33,7 +33,7 @@ try: import lyx2lyx_version version__ = lyx2lyx_version.version except: # we are running from build directory so assume the last version - version__ = '2.2' + version__ = '2.3' default_debug__ = 2 @@ -86,7 +86,8 @@ 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" , 5)), - ("2_2", list(range(475,509)), minor_versions("2.2" , 0)) + ("2_2", list(range(475,509)), minor_versions("2.2" , 0)), + ("2_3", list(range(509,510)), minor_versions("2.3" , 0)) ] #################################################################### diff --git a/lib/lyx2lyx/Makefile.am b/lib/lyx2lyx/Makefile.am index 4490cb7..89ba23b 100644 --- a/lib/lyx2lyx/Makefile.am +++ b/lib/lyx2lyx/Makefile.am @@ -33,6 +33,7 @@ dist_lyx2lyx_PYTHON = \ lyx_2_0.py \ lyx_2_1.py \ lyx_2_2.py \ + lyx_2_3.py \ profiling.py \ test_parser_tools.py diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 9d121cb..bcf8d64 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,8 @@ 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 == "\\paragraph_separation") { string parsep; lex >> parsep; @@ -1139,6 +1142,7 @@ 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'; os << "\\graphics " << graphics_driver << '\n'; os << "\\default_output_format " << default_output_format << '\n'; os << "\\output_sync " << output_sync << '\n'; @@ -1411,6 +1415,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 f62911c..7314b42 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -278,6 +278,8 @@ 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; /// Spacing & spacing(); Spacing const & spacing() const; diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 4fa2c82..3a2e775 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -1132,6 +1132,10 @@ string const LaTeXFeatures::getPackages() const if (mustProvide("footmisc")) packages << "\\PassOptionsToPackage{stable}{footmisc}\n"; + if (mustProvide("microtype")){ + packages << "\\usepackage{microtype}\n"; + } + return packages.str(); } diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 15fb719..25356d9 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -809,6 +809,8 @@ 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->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), @@ -2889,6 +2891,8 @@ void GuiDocument::applyView() bp_.fonts_cjk = fromqstr(fontModule->cjkFontLE->text()); + bp_.use_microtype = fontModule->microtypeCB->isChecked(); + bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value(); bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale; @@ -3368,6 +3372,8 @@ void GuiDocument::paramsToDialog() toqstr(bp_.fonts_cjk)); else fontModule->cjkFontLE->setText(QString()); + + fontModule->microtypeCB->setChecked(bp_.use_microtype); fontModule->fontScCB->setChecked(bp_.fonts_expert_sc); fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures); diff --git a/src/frontends/qt4/ui/FontUi.ui b/src/frontends/qt4/ui/FontUi.ui index ba7a5ea..cfd1949 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>429</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"> @@ -101,6 +68,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="3" column="1"> <widget class="QComboBox" name="fontsRomanCO"> <property name="toolTip"> @@ -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"> @@ -242,7 +242,7 @@ </property> </widget> </item> - <item row="10" column="1"> + <item row="11" column="1"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -255,6 +255,16 @@ </property> </spacer> </item> + <item row="10" column="1"> + <widget class="QCheckBox" name="microtypeCB"> + <property name="toolTip"> + <string>Only pdflatex supports all features</string> + </property> + <property name="text"> + <string>Use micr&otype</string> + </property> + </widget> + </item> </layout> </widget> <layoutdefault spacing="6" margin="11"/> diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 24c403d..95212ae 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -554,6 +554,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false), h_use_packages["stackrel"] = "0"; h_use_packages["stmaryrd"] = "0"; h_use_packages["undertilde"] = "0"; + h_use_packages["microtype"] = "0"; } @@ -813,7 +814,7 @@ void Preamble::handle_package(Parser &p, string const & name, else if (name == "amsmath" || name == "amssymb" || name == "cancel" || name == "esint" || name == "mhchem" || name == "mathdots" || name == "mathtools" || name == "stackrel" || - name == "stmaryrd" || name == "undertilde") + name == "stmaryrd" || name == "undertilde" || name == "microtype") h_use_packages[name] = "2"; else if (name == "babel") { diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 5305fea..b19a711 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -83,6 +83,7 @@ Format LaTeX feature LyX feature \twocolumn[]{}{} Layout Twocolumn, InsetArgument \item[]<> InsetArgument \begin{enumerate|itemize|...}[] InsetArgument +509 microtype.sty \use_microtype General diff --git a/src/version.h b/src/version.h index 757f43f..d8aecdd 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ 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 508 // forenr: convert parbreak to latexpar -#define LYX_FORMAT_TEX2LYX 508 +#define LYX_FORMAT_LYX 509 // ps: microtype +#define LYX_FORMAT_TEX2LYX 509 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py new file mode 100644 index 0000000..08ca2f0 --- /dev/null +++ b/lib/lyx2lyx/lyx_2_3.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# This file is part of lyx2lyx +# -*- coding: utf-8 -*- +# Copyright (C) 2016 The LyX team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +""" Convert files to the file format generated by lyx 2.3""" + +import re, string +import unicodedata +import sys, os + +# Uncomment only what you need to import, please. + +#from parser_tools import find_token, find_end_of, find_tokens, \ +# find_token_exact, find_end_of_inset, find_end_of_layout, \ +# find_token_backwards, is_in_inset, get_value, get_quoted_value, \ +# del_token, check_token, get_option_value + +#from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, lyx2latex, \ +# lyx2verbatim, length_in_bp, convert_info_insets +# insert_to_preamble, latex_length, revert_flex_inset, \ +# revert_font_attrs, hex2ratio, str2bool + +from parser_tools import find_token + +#################################################################### +# Private helper functions + + + +############################################################################### +### +### Conversion and reversion routines +### +############################################################################### + +def revert_microtype(document): + " Remove microtype settings. " + i = find_token(document.header, "\\use_microtype", 0) + if i == -1: + return + del document.header[i] + + + +## +# Conversion hub +# + +supported_versions = ["2.3.0", "2.3"] +convert = [ + [509, []] + ] + +revert = [ + [508, [revert_microtype]] + ] + + +if __name__ == "__main__": + pass