-----------------------
+2016-06-16 Pavel Sanda <sanda@lyx.org>
+ * Format incremented to 509.
+ New parameter "\use_microtype bool" for including microtype LaTeX
+ package into preamble.
+
2016-04-05 Enrico Forestieri <forenr@lyx.org>
* Format incremented to 508
New kind of Separator inset (latexpar). The old parbreak separator
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
("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))
]
####################################################################
lyx_2_0.py \
lyx_2_1.py \
lyx_2_2.py \
+ lyx_2_3.py \
profiling.py \
test_parser_tools.py
--- /dev/null
+# -*- 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
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;
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;
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';
if (useNonTeXFonts && fontsMath() != "auto")
features.require("unicode-math");
+
+ if (use_microtype)
+ features.require("microtype");
if (!language->requires().empty())
features.require(language->requires());
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;
if (mustProvide("footmisc"))
packages << "\\PassOptionsToPackage{stable}{footmisc}\n";
+ if (mustProvide("microtype")){
+ packages << "\\usepackage{microtype}\n";
+ }
+
return packages.str();
}
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)),
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;
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);
<rect>
<x>0</x>
<y>0</y>
- <width>407</width>
- <height>285</height>
+ <width>541</width>
+ <height>319</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">
</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">
</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">
</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">
</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">
</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">
</property>
</widget>
</item>
- <item row="10" column="1">
+ <item row="11" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
+ <item row="10" column="1">
+ <widget class="QCheckBox" name="microtypeCB">
+ <property name="toolTip">
+ <string>Activate extensions such as character protusion and font expansion via the microtype package</string>
+ </property>
+ <property name="text">
+ <string>Enable micr&o-typographic extensions</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
Preamble::Preamble() : one_language(true), explicit_babel(false),
- title_layout_found(false), index_number(0), h_font_cjk_set(false)
+ title_layout_found(false), index_number(0), h_font_cjk_set(false),
+ h_use_microtype(false)
{
//h_backgroundcolor;
//h_boxbgcolor;
h_use_geometry = "false";
h_use_default_options = "false";
h_use_hyperref = "false";
+ h_use_microtype = false;
h_use_refstyle = false;
h_use_packages["amsmath"] = "1";
h_use_packages["amssymb"] = "0";
h_options += ',' + join(options, ",");
}
}
+ else if (name == "microtype") {
+ //we internally support only microtype without params
+ if (options.empty())
+ h_use_microtype = true;
+ else
+ h_preamble << "\\usepackage[" << opts << "]{microtype}";
+ }
else if (!in_lyx_preamble) {
if (options.empty())
<< ' ' << h_font_tt_scale[1] << '\n';
if (!h_font_cjk.empty())
os << "\\font_cjk " << h_font_cjk << '\n';
- os << "\\graphics " << h_graphics << '\n'
+ os << "\\use_microtype " << h_use_microtype << '\n'
+ << "\\graphics " << h_graphics << '\n'
<< "\\default_output_format " << h_default_output_format << "\n"
<< "\\output_sync " << h_output_sync << "\n";
if (h_output_sync == "1")
std::string h_font_tt_scale[2];
bool h_font_cjk_set;
std::string h_font_cjk;
+ bool h_use_microtype;
std::string h_graphics;
std::string h_default_output_format;
std::string h_html_be_strict;
// 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