Store both sets of font selections

This is one part of bug 9744: If you toggle between TeX fonts and non-TeX
fonts, the settings of the other choice are no longer thrown away, but stored
and re-activated if you switch back. Most parts of the patch are purely
mechanical (duplicating some BufferParams members), the only non-mechanical
change is in the GUI logic.
This commit is contained in:
Georg Baum 2015-11-09 07:33:57 +01:00
parent 76cf124ab3
commit 2fc430d5ae
27 changed files with 425 additions and 239 deletions

View File

@ -11,6 +11,15 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2015-11-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* Format incremented to 501
\fonts_roman, \fonts_sans, \fonts_typewriter and \fonts_math,
take now two quoted values instead of one unquoted one.
The first one is for TeX fonts, the second one for non-TeX fonts.
\font_sf_scale and \font_tt_scale
take now two values instead of one.
The first one is for TeX fonts, the second one for non-TeX fonts.
2015-11-04 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 500
No new parameters.

View File

@ -85,7 +85,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,501)), minor_versions("2.2" , 0))
("2_2", list(range(475,502)), minor_versions("2.2" , 0))
]
####################################################################

View File

@ -2019,6 +2019,79 @@ def revert_achemso(document):
i += 1
fontsettings = ["\\font_roman", "\\font_sans", "\\font_typewriter", "\\font_math", \
"\\font_sf_scale", "\\font_tt_scale"]
fontdefaults = ["default", "default", "default", "auto", "100", "100"]
fontquotes = [True, True, True, True, False, False]
def convert_fontsettings(document):
" Duplicate font settings "
i = find_token(document.header, "\\use_non_tex_fonts ", 0)
if i == -1:
document.warning("Malformed LyX document: No \\use_non_tex_fonts!")
use_non_tex_fonts = "false"
else:
use_non_tex_fonts = get_value(document.header, "\\use_non_tex_fonts", i)
j = 0
for f in fontsettings:
i = find_token(document.header, f + " ", 0)
if i == -1:
document.warning("Malformed LyX document: No " + f + "!")
j = j + 1
continue
value = document.header[i][len(f):].strip()
if fontquotes[j]:
if use_non_tex_fonts == "true":
document.header[i:i+1] = [f + ' "' + fontdefaults[j] + '" "' + value + '"']
else:
document.header[i:i+1] = [f + ' "' + value + '" "' + fontdefaults[j] + '"']
else:
if use_non_tex_fonts == "true":
document.header[i:i+1] = [f + ' ' + fontdefaults[j] + ' ' + value]
else:
document.header[i:i+1] = [f + ' ' + value + ' ' + fontdefaults[j]]
j = j + 1
def revert_fontsettings(document):
" Merge font settings "
i = find_token(document.header, "\\use_non_tex_fonts ", 0)
if i == -1:
document.warning("Malformed LyX document: No \\use_non_tex_fonts!")
use_non_tex_fonts = "false"
else:
use_non_tex_fonts = get_value(document.header, "\\use_non_tex_fonts", i)
j = 0
for f in fontsettings:
i = find_token(document.header, f + " ", 0)
if i == -1:
document.warning("Malformed LyX document: No " + f + "!")
j = j + 1
continue
line = get_value(document.header, f, i)
if fontquotes[j]:
q1 = line.find('"')
q2 = line.find('"', q1+1)
q3 = line.find('"', q2+1)
q4 = line.find('"', q3+1)
if q1 == -1 or q2 == -1 or q3 == -1 or q4 == -1:
document.warning("Malformed LyX document: Missing quotes!")
j = j + 1
continue
if use_non_tex_fonts == "true":
document.header[i:i+1] = [f + ' ' + line[q3+1:q4]]
else:
document.header[i:i+1] = [f + ' ' + line[q1+1:q2]]
else:
if use_non_tex_fonts == "true":
document.header[i:i+1] = [f + ' ' + line.split()[2]]
else:
document.header[i:i+1] = [f + ' ' + line.split()[1]]
j = j + 1
##
# Conversion hub
#
@ -2053,10 +2126,12 @@ convert = [
[497, [convert_external_bbox]],
[498, []],
[499, [convert_moderncv]],
[500, []]
[500, []],
[501, [convert_fontsettings]]
]
revert = [
[500, [revert_fontsettings]],
[499, [revert_achemso]],
[498, [revert_moderncv_1, revert_moderncv_2]],
[497, [revert_tcolorbox_1, revert_tcolorbox_2,

View File

@ -377,16 +377,22 @@ BufferParams::BufferParams()
tocdepth = 3;
language = default_language;
fontenc = "global";
fonts_roman = "default";
fonts_sans = "default";
fonts_typewriter = "default";
fonts_math = "auto";
fonts_roman[0] = "default";
fonts_roman[1] = "default";
fonts_sans[0] = "default";
fonts_sans[1] = "default";
fonts_typewriter[0] = "default";
fonts_typewriter[1] = "default";
fonts_math[0] = "auto";
fonts_math[1] = "auto";
fonts_default_family = "default";
useNonTeXFonts = false;
fonts_expert_sc = false;
fonts_old_figures = false;
fonts_sans_scale = 100;
fonts_typewriter_scale = 100;
fonts_sans_scale[0] = 100;
fonts_sans_scale[1] = 100;
fonts_typewriter_scale[0] = 100;
fonts_typewriter_scale[1] = 100;
inputenc = "auto";
lang_package = "default";
graphics_driver = "default";
@ -726,17 +732,17 @@ string BufferParams::readToken(Lexer & lex, string const & token,
lex.eatLine();
fontenc = lex.getString();
} else if (token == "\\font_roman") {
lex.eatLine();
fonts_roman = lex.getString();
lex >> fonts_roman[0];
lex >> fonts_roman[1];
} else if (token == "\\font_sans") {
lex.eatLine();
fonts_sans = lex.getString();
lex >> fonts_sans[0];
lex >> fonts_sans[1];
} else if (token == "\\font_typewriter") {
lex.eatLine();
fonts_typewriter = lex.getString();
lex >> fonts_typewriter[0];
lex >> fonts_typewriter[1];
} else if (token == "\\font_math") {
lex.eatLine();
fonts_math = lex.getString();
lex >> fonts_math[0];
lex >> fonts_math[1];
} else if (token == "\\font_default_family") {
lex >> fonts_default_family;
} else if (token == "\\use_non_tex_fonts") {
@ -746,9 +752,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
} else if (token == "\\font_osf") {
lex >> fonts_old_figures;
} else if (token == "\\font_sf_scale") {
lex >> fonts_sans_scale;
lex >> fonts_sans_scale[0];
lex >> fonts_sans_scale[1];
} else if (token == "\\font_tt_scale") {
lex >> fonts_typewriter_scale;
lex >> fonts_typewriter_scale[0];
lex >> fonts_typewriter_scale[1];
} else if (token == "\\font_cjk") {
lex >> fonts_cjk;
} else if (token == "\\paragraph_separation") {
@ -1092,16 +1100,22 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
os << "\\language_package " << lang_package
<< "\n\\inputencoding " << inputenc
<< "\n\\fontencoding " << fontenc
<< "\n\\font_roman " << fonts_roman
<< "\n\\font_sans " << fonts_sans
<< "\n\\font_typewriter " << fonts_typewriter
<< "\n\\font_math " << fonts_math
<< "\n\\font_roman \"" << fonts_roman[0]
<< "\" \"" << fonts_roman[1] << '"'
<< "\n\\font_sans \"" << fonts_sans[0]
<< "\" \"" << fonts_sans[1] << '"'
<< "\n\\font_typewriter \"" << fonts_typewriter[0]
<< "\" \"" << fonts_typewriter[1] << '"'
<< "\n\\font_math " << fonts_math[0]
<< "\" \"" << fonts_math[1] << '"'
<< "\n\\font_default_family " << fonts_default_family
<< "\n\\use_non_tex_fonts " << convert<string>(useNonTeXFonts)
<< "\n\\font_sc " << convert<string>(fonts_expert_sc)
<< "\n\\font_osf " << convert<string>(fonts_old_figures)
<< "\n\\font_sf_scale " << fonts_sans_scale
<< "\n\\font_tt_scale " << fonts_typewriter_scale
<< "\n\\font_sf_scale " << fonts_sans_scale[0]
<< ' ' << fonts_sans_scale[1]
<< "\n\\font_tt_scale " << fonts_typewriter_scale[0]
<< ' ' << fonts_typewriter_scale[1]
<< '\n';
if (!fonts_cjk.empty()) {
os << "\\font_cjk " << fonts_cjk << '\n';
@ -1373,7 +1387,7 @@ void BufferParams::validate(LaTeXFeatures & features) const
|| useNonTeXFonts))
features.require("polyglossia");
if (useNonTeXFonts && fonts_math != "auto")
if (useNonTeXFonts && fontsMath() != "auto")
features.require("unicode-math");
if (!language->requires().empty())
@ -1540,7 +1554,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
string const ams = features.loadAMSPackages();
bool const ot1 = (font_encoding() == "default" || font_encoding() == "OT1");
bool const use_newtxmath =
theLaTeXFonts().getLaTeXFont(from_ascii(fonts_math)).getUsedPackage(
theLaTeXFonts().getLaTeXFont(from_ascii(fontsMath())).getUsedPackage(
ot1, false, false) == "newtxmath";
if ((useNonTeXFonts || use_newtxmath) && !ams.empty())
os << from_ascii(ams);
@ -3033,9 +3047,9 @@ string const BufferParams::parseFontName(string const & name) const
string const BufferParams::loadFonts(LaTeXFeatures & features) const
{
if (fonts_roman == "default" && fonts_sans == "default"
&& fonts_typewriter == "default"
&& (fonts_math == "default" || fonts_math == "auto"))
if (fontsRoman() == "default" && fontsSans() == "default"
&& fontsTypewriter() == "default"
&& (fontsMath() == "default" || fontsMath() == "auto"))
//nothing to do
return string();
@ -3064,28 +3078,28 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
string const texmapping =
(features.runparams().flavor == OutputParams::XETEX) ?
"Mapping=tex-text" : "Ligatures=TeX";
if (fonts_roman != "default") {
if (fontsRoman() != "default") {
os << "\\setmainfont[" << texmapping;
if (fonts_old_figures)
os << ",Numbers=OldStyle";
os << "]{" << parseFontName(fonts_roman) << "}\n";
os << "]{" << parseFontName(fontsRoman()) << "}\n";
}
if (fonts_sans != "default") {
string const sans = parseFontName(fonts_sans);
if (fonts_sans_scale != 100)
if (fontsSans() != "default") {
string const sans = parseFontName(fontsSans());
if (fontsSansScale() != 100)
os << "\\setsansfont[Scale="
<< float(fonts_sans_scale) / 100
<< float(fontsSansScale()) / 100
<< "," << texmapping << "]{"
<< sans << "}\n";
else
os << "\\setsansfont[" << texmapping << "]{"
<< sans << "}\n";
}
if (fonts_typewriter != "default") {
string const mono = parseFontName(fonts_typewriter);
if (fonts_typewriter_scale != 100)
if (fontsTypewriter() != "default") {
string const mono = parseFontName(fontsTypewriter());
if (fontsTypewriterScale() != 100)
os << "\\setmonofont[Scale="
<< float(fonts_typewriter_scale) / 100
<< float(fontsTypewriterScale()) / 100
<< "]{"
<< mono << "}\n";
else
@ -3098,26 +3112,26 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
// Tex Fonts
bool const ot1 = (font_encoding() == "default" || font_encoding() == "OT1");
bool const dryrun = features.runparams().dryrun;
bool const complete = (fonts_sans == "default" && fonts_typewriter == "default");
bool const nomath = (fonts_math == "default");
bool const complete = (fontsSans() == "default" && fontsTypewriter() == "default");
bool const nomath = (fontsMath() == "default");
// ROMAN FONTS
os << theLaTeXFonts().getLaTeXFont(from_ascii(fonts_roman)).getLaTeXCode(
os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsRoman())).getLaTeXCode(
dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
nomath);
// SANS SERIF
os << theLaTeXFonts().getLaTeXFont(from_ascii(fonts_sans)).getLaTeXCode(
os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsSans())).getLaTeXCode(
dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
nomath, fonts_sans_scale);
nomath, fontsSansScale());
// MONOSPACED/TYPEWRITER
os << theLaTeXFonts().getLaTeXFont(from_ascii(fonts_typewriter)).getLaTeXCode(
os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsTypewriter())).getLaTeXCode(
dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
nomath, fonts_typewriter_scale);
nomath, fontsTypewriterScale());
// MATH
os << theLaTeXFonts().getLaTeXFont(from_ascii(fonts_math)).getLaTeXCode(
os << theLaTeXFonts().getLaTeXFont(from_ascii(fontsMath())).getLaTeXCode(
dryrun, ot1, complete, fonts_expert_sc, fonts_old_figures,
nomath);

View File

@ -245,14 +245,22 @@ public:
std::string index_command;
/// font encoding(s) requested for this document
std::string fontenc;
/// the rm font: [0] for TeX fonts, [1] for non-TeX fonts
std::string fonts_roman[2];
/// the rm font
std::string fonts_roman;
std::string const & fontsRoman() const { return fonts_roman[useNonTeXFonts]; }
/// the sf font: [0] for TeX fonts, [1] for non-TeX fonts
std::string fonts_sans[2];
/// the sf font
std::string fonts_sans;
std::string const & fontsSans() const { return fonts_sans[useNonTeXFonts]; }
/// the tt font: [0] for TeX fonts, [1] for non-TeX fonts
std::string fonts_typewriter[2];
/// the tt font
std::string fonts_typewriter;
std::string const & fontsTypewriter() const { return fonts_typewriter[useNonTeXFonts]; }
/// the math font: [0] for TeX fonts, [1] for non-TeX fonts
std::string fonts_math[2];
/// the math font
std::string fonts_math;
std::string const & fontsMath() const { return fonts_math[useNonTeXFonts]; }
/// the default family (rm, sf, tt)
std::string fonts_default_family;
/// use the fonts of the OS (OpenType, True Type) directly
@ -261,10 +269,14 @@ public:
bool fonts_expert_sc;
/// use Old Style Figures
bool fonts_old_figures;
/// the scale factor of the sf font: [0] for TeX fonts, [1] for non-TeX fonts
int fonts_sans_scale[2];
/// the scale factor of the sf font
int fonts_sans_scale;
int fontsSansScale() const { return fonts_sans_scale[useNonTeXFonts]; }
/// the scale factor of the tt font: [0] for TeX fonts, [1] for non-TeX fonts
int fonts_typewriter_scale[2];
/// the scale factor of the tt font
int fonts_typewriter_scale;
int fontsTypewriterScale() const { return fonts_typewriter_scale[useNonTeXFonts]; }
/// the font used by the CJK command
std::string fonts_cjk;
///

View File

@ -516,24 +516,24 @@ bool LaTeXFeatures::isProvided(string const & name) const
bool const ot1 = (params_.font_encoding() == "default"
|| params_.font_encoding() == "OT1");
bool const complete = (params_.fonts_sans == "default")
&& (params_.fonts_typewriter == "default");
bool const nomath = (params_.fonts_math == "default");
bool const complete = (params_.fontsSans() == "default"
&& params_.fontsTypewriter() == "default");
bool const nomath = (params_.fontsMath() == "default");
return params_.documentClass().provides(name)
|| theLaTeXFonts().getLaTeXFont(
from_ascii(params_.fonts_roman)).provides(name, ot1,
from_ascii(params_.fontsRoman())).provides(name, ot1,
complete,
nomath)
|| theLaTeXFonts().getLaTeXFont(
from_ascii(params_.fonts_sans)).provides(name, ot1,
from_ascii(params_.fontsSans())).provides(name, ot1,
complete,
nomath)
|| theLaTeXFonts().getLaTeXFont(
from_ascii(params_.fonts_typewriter)).provides(name, ot1,
from_ascii(params_.fontsTypewriter())).provides(name, ot1,
complete,
nomath)
|| theLaTeXFonts().getLaTeXFont(
from_ascii(params_.fonts_math)).provides(name, ot1,
from_ascii(params_.fontsMath())).provides(name, ot1,
complete,
nomath);
// TODO: "textbaltic" provided, if the font-encoding is "L7x"
@ -934,7 +934,7 @@ string const LaTeXFeatures::getPackages() const
string const amsPackages = loadAMSPackages();
bool const ot1 = (params_.font_encoding() == "default" || params_.font_encoding() == "OT1");
bool const use_newtxmath =
theLaTeXFonts().getLaTeXFont(from_ascii(params_.fonts_math)).getUsedPackage(
theLaTeXFonts().getLaTeXFont(from_ascii(params_.fontsMath())).getUsedPackage(
ot1, false, false) == "newtxmath";
if (!params_.useNonTeXFonts && !use_newtxmath && !amsPackages.empty())

View File

@ -774,7 +774,7 @@ GuiDocument::GuiDocument(GuiView & lv)
outputModule->synccustomCB));
// fonts
fontModule = new UiWidget<Ui::FontUi>;
fontModule = new FontModule;
connect(fontModule->osFontsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
@ -1775,6 +1775,18 @@ void GuiDocument::languageChanged(int i)
void GuiDocument::osFontsChanged(bool nontexfonts)
{
bool const tex_fonts = !nontexfonts;
// store current fonts
QString const font_roman = fontModule->fontsRomanCO->itemData(
fontModule->fontsRomanCO->currentIndex()).toString();
QString const font_sans = fontModule->fontsSansCO->itemData(
fontModule->fontsSansCO->currentIndex()).toString();
QString const font_typewriter = fontModule->fontsTypewriterCO->itemData(
fontModule->fontsTypewriterCO->currentIndex()).toString();
QString const font_math = fontModule->fontsMathCO->itemData(
fontModule->fontsMathCO->currentIndex()).toString();
int const font_sf_scale = fontModule->scaleSansSB->value();
int const font_tt_scale = fontModule->scaleTypewriterSB->value();
updateFontlist();
// store default format
QString const dformat = outputModule->defaultFormatCO->itemData(
@ -1786,6 +1798,28 @@ void GuiDocument::osFontsChanged(bool nontexfonts)
if (index == -1)
index = 0;
outputModule->defaultFormatCO->setCurrentIndex(index);
// try to restore fonts which were selected two toggles ago
index = fontModule->fontsRomanCO->findData(fontModule->font_roman);
if (index != -1)
fontModule->fontsRomanCO->setCurrentIndex(index);
index = fontModule->fontsSansCO->findData(fontModule->font_sans);
if (index != -1)
fontModule->fontsSansCO->setCurrentIndex(index);
index = fontModule->fontsTypewriterCO->findData(fontModule->font_typewriter);
if (index != -1)
fontModule->fontsTypewriterCO->setCurrentIndex(index);
index = fontModule->fontsMathCO->findData(fontModule->font_math);
if (index != -1)
fontModule->fontsMathCO->setCurrentIndex(index);
// save fonts for next next toggle
fontModule->font_roman = font_roman;
fontModule->font_sans = font_sans;
fontModule->font_typewriter = font_typewriter;
fontModule->font_math = font_math;
fontModule->font_sf_scale = font_sf_scale;
fontModule->font_tt_scale = font_tt_scale;
langModule->encodingCO->setEnabled(tex_fonts &&
!langModule->defaultencodingRB->isChecked());
langModule->defaultencodingRB->setEnabled(tex_fonts);
@ -2823,21 +2857,25 @@ void GuiDocument::applyView()
bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
// fonts
bp_.fonts_roman =
bp_.fonts_roman[nontexfonts] =
fromqstr(fontModule->fontsRomanCO->
itemData(fontModule->fontsRomanCO->currentIndex()).toString());
bp_.fonts_roman[!nontexfonts] = fromqstr(fontModule->font_roman);
bp_.fonts_sans =
bp_.fonts_sans[nontexfonts] =
fromqstr(fontModule->fontsSansCO->
itemData(fontModule->fontsSansCO->currentIndex()).toString());
bp_.fonts_sans[!nontexfonts] = fromqstr(fontModule->font_sans);
bp_.fonts_typewriter =
bp_.fonts_typewriter[nontexfonts] =
fromqstr(fontModule->fontsTypewriterCO->
itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
bp_.fonts_typewriter[!nontexfonts] = fromqstr(fontModule->font_typewriter);
bp_.fonts_math =
bp_.fonts_math[nontexfonts] =
fromqstr(fontModule->fontsMathCO->
itemData(fontModule->fontsMathCO->currentIndex()).toString());
bp_.fonts_math[!nontexfonts] = fromqstr(fontModule->font_math);
QString const fontenc =
fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
@ -2849,9 +2887,11 @@ void GuiDocument::applyView()
bp_.fonts_cjk =
fromqstr(fontModule->cjkFontLE->text());
bp_.fonts_sans_scale = fontModule->scaleSansSB->value();
bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
bp_.fonts_typewriter_scale = fontModule->scaleTypewriterSB->value();
bp_.fonts_typewriter_scale[nontexfonts] = fontModule->scaleTypewriterSB->value();
bp_.fonts_typewriter_scale[!nontexfonts] = fontModule->font_tt_scale;
bp_.fonts_expert_sc = fontModule->fontScCB->isChecked();
@ -3269,37 +3309,41 @@ void GuiDocument::paramsToDialog()
updateFontsize(documentClass().opt_fontsize(),
bp_.fontsize);
QString font = toqstr(bp_.fonts_roman);
QString font = toqstr(bp_.fontsRoman());
int rpos = fontModule->fontsRomanCO->findData(font);
if (rpos == -1) {
rpos = fontModule->fontsRomanCO->count();
fontModule->fontsRomanCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsRomanCO->setCurrentIndex(rpos);
fontModule->font_roman = toqstr(bp_.fonts_roman[!bp_.useNonTeXFonts]);
font = toqstr(bp_.fonts_sans);
font = toqstr(bp_.fontsSans());
int spos = fontModule->fontsSansCO->findData(font);
if (spos == -1) {
spos = fontModule->fontsSansCO->count();
fontModule->fontsSansCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsSansCO->setCurrentIndex(spos);
fontModule->font_sans = toqstr(bp_.fonts_sans[!bp_.useNonTeXFonts]);
font = toqstr(bp_.fonts_typewriter);
font = toqstr(bp_.fontsTypewriter());
int tpos = fontModule->fontsTypewriterCO->findData(font);
if (tpos == -1) {
tpos = fontModule->fontsTypewriterCO->count();
fontModule->fontsTypewriterCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
fontModule->font_typewriter = toqstr(bp_.fonts_typewriter[!bp_.useNonTeXFonts]);
font = toqstr(bp_.fonts_math);
font = toqstr(bp_.fontsMath());
int mpos = fontModule->fontsMathCO->findData(font);
if (mpos == -1) {
mpos = fontModule->fontsMathCO->count();
fontModule->fontsMathCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsMathCO->setCurrentIndex(mpos);
fontModule->font_math = toqstr(bp_.fonts_math[!bp_.useNonTeXFonts]);
if (bp_.useNonTeXFonts && os_fonts_available) {
fontModule->fontencLA->setEnabled(false);
@ -3322,8 +3366,10 @@ void GuiDocument::paramsToDialog()
fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
fontModule->scaleSansSB->setValue(bp_.fonts_sans_scale);
fontModule->scaleTypewriterSB->setValue(bp_.fonts_typewriter_scale);
fontModule->scaleSansSB->setValue(bp_.fontsSansScale());
fontModule->font_sf_scale = bp_.fonts_sans_scale[!bp_.useNonTeXFonts];
fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale());
fontModule->font_tt_scale = bp_.fonts_typewriter_scale[!bp_.useNonTeXFonts];
int nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
if (nn >= 0)

View File

@ -51,6 +51,7 @@ class GuiIndices;
class ModuleSelectionManager;
class PreambleModule;
class LocalLayout;
class FontModule;
///
typedef void const * BufferId;
@ -134,7 +135,7 @@ private:
UiWidget<Ui::TextLayoutUi> *textLayoutModule;
UiWidget<Ui::MasterChildUi> *masterChildModule;
UiWidget<Ui::FontUi> *fontModule;
FontModule *fontModule;
UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
UiWidget<Ui::MarginsUi> *marginsModule;
UiWidget<Ui::LanguageUi> *langModule;
@ -329,6 +330,25 @@ private:
};
class FontModule : public UiWidget<Ui::FontUi>
{
Q_OBJECT
public:
/// The roman font currently not selected by osFontsCB->isChecked()
QString font_roman;
/// The sans font currently not selected by osFontsCB->isChecked()
QString font_sans;
/// The typewriter font currently not selected by osFontsCB->isChecked()
QString font_typewriter;
/// The math font currently not selected by osFontsCB->isChecked()
QString font_math;
/// The sans font scale currently not selected by osFontsCB->isChecked()
int font_sf_scale;
/// The typewriter font scale currently not selected by osFontsCB->isChecked()
int font_tt_scale;
};
} // namespace frontend
} // namespace lyx

View File

@ -473,16 +473,22 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
//h_float_placement;
//h_fontcolor;
h_fontencoding = "default";
h_font_roman = "default";
h_font_sans = "default";
h_font_typewriter = "default";
h_font_math = "auto";
h_font_roman[0] = "default";
h_font_roman[1] = "default";
h_font_sans[0] = "default";
h_font_sans[1] = "default";
h_font_typewriter[0] = "default";
h_font_typewriter[1] = "default";
h_font_math[0] = "auto";
h_font_math[1] = "auto";
h_font_default_family = "default";
h_use_non_tex_fonts = false;
h_font_sc = "false";
h_font_osf = "false";
h_font_sf_scale = "100";
h_font_tt_scale = "100";
h_font_sf_scale[0] = "100";
h_font_sf_scale[1] = "100";
h_font_tt_scale[0] = "100";
h_font_tt_scale[1] = "100";
//h_font_cjk
h_graphics = "default";
h_default_output_format = "default";
@ -684,25 +690,25 @@ void Preamble::handle_package(Parser &p, string const & name,
// roman fonts
if (is_known(name, known_roman_fonts))
h_font_roman = name;
h_font_roman[0] = name;
if (name == "fourier") {
h_font_roman = "utopia";
h_font_roman[0] = "utopia";
// when font uses real small capitals
if (opts == "expert")
h_font_sc = "true";
}
if (name == "garamondx") {
h_font_roman = "garamondx";
h_font_roman[0] = "garamondx";
if (opts == "osfI")
h_font_osf = "true";
}
if (name == "libertine") {
h_font_roman = "libertine";
h_font_roman[0] = "libertine";
// this automatically invokes biolinum
h_font_sans = "biolinum";
h_font_sans[0] = "biolinum";
if (opts == "osf")
h_font_osf = "true";
else if (opts == "lining")
@ -710,7 +716,7 @@ void Preamble::handle_package(Parser &p, string const & name,
}
if (name == "libertine-type1") {
h_font_roman = "libertine";
h_font_roman[0] = "libertine";
// NOTE: contrary to libertine.sty, libertine-type1
// does not automatically invoke biolinum
if (opts == "lining")
@ -721,11 +727,11 @@ void Preamble::handle_package(Parser &p, string const & name,
if (name == "mathdesign") {
if (opts.find("charter") != string::npos)
h_font_roman = "md-charter";
h_font_roman[0] = "md-charter";
if (opts.find("garamond") != string::npos)
h_font_roman = "md-garamond";
h_font_roman[0] = "md-garamond";
if (opts.find("utopia") != string::npos)
h_font_roman = "md-utopia";
h_font_roman[0] = "md-utopia";
if (opts.find("expert") != string::npos) {
h_font_sc = "true";
h_font_osf = "true";
@ -733,22 +739,22 @@ void Preamble::handle_package(Parser &p, string const & name,
}
else if (name == "mathpazo")
h_font_roman = "palatino";
h_font_roman[0] = "palatino";
else if (name == "mathptmx")
h_font_roman = "times";
h_font_roman[0] = "times";
// sansserif fonts
if (is_known(name, known_sans_fonts)) {
h_font_sans = name;
h_font_sans[0] = name;
if (options.size() >= 1) {
if (scale_as_percentage(opts, h_font_sf_scale))
if (scale_as_percentage(opts, h_font_sf_scale[0]))
options.clear();
}
}
if (name == "biolinum-type1") {
h_font_sans = "biolinum";
h_font_sans[0] = "biolinum";
// biolinum can have several options, e.g. [osf,scaled=0.97]
string::size_type pos = opts.find("osf");
if (pos != string::npos)
@ -760,16 +766,16 @@ void Preamble::handle_package(Parser &p, string const & name,
// fourier can be set as roman font _only_
// fourier as typewriter is handled in handling of \ttdefault
if (name != "fourier") {
h_font_typewriter = name;
h_font_typewriter[0] = name;
if (options.size() >= 1) {
if (scale_as_percentage(opts, h_font_tt_scale))
if (scale_as_percentage(opts, h_font_tt_scale[0]))
options.clear();
}
}
}
if (name == "libertineMono-type1") {
h_font_typewriter = "libertine-mono";
h_font_typewriter[0] = "libertine-mono";
}
// font uses old-style figure
@ -778,26 +784,26 @@ void Preamble::handle_package(Parser &p, string const & name,
// math fonts
if (is_known(name, known_math_fonts))
h_font_math = name;
h_font_math[0] = name;
if (name == "newtxmath") {
if (opts.empty())
h_font_math = "newtxmath";
h_font_math[0] = "newtxmath";
else if (opts == "garamondx")
h_font_math = "garamondx-ntxm";
h_font_math[0] = "garamondx-ntxm";
else if (opts == "libertine")
h_font_math = "libertine-ntxm";
h_font_math[0] = "libertine-ntxm";
else if (opts == "minion")
h_font_math = "minion-ntxm";
h_font_math[0] = "minion-ntxm";
}
if (name == "iwona")
if (opts == "math")
h_font_math = "iwona-math";
h_font_math[0] = "iwona-math";
if (name == "kurier")
if (opts == "math")
h_font_math = "kurier-math";
h_font_math[0] = "kurier-math";
// after the detection and handling of special cases, we can remove the
// fonts, otherwise they would appear in the preamble, see bug #7856
@ -1138,16 +1144,20 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
<< "\\language_package " << h_language_package << "\n"
<< "\\inputencoding " << h_inputencoding << "\n"
<< "\\fontencoding " << h_fontencoding << "\n"
<< "\\font_roman " << h_font_roman << "\n"
<< "\\font_sans " << h_font_sans << "\n"
<< "\\font_typewriter " << h_font_typewriter << "\n"
<< "\\font_math " << h_font_math << "\n"
<< "\\font_roman \"" << h_font_roman[0]
<< "\" \"" << h_font_roman[1] << "\"\n"
<< "\\font_sans \"" << h_font_sans[0] << "\" \"" << h_font_sans[1] << "\"\n"
<< "\\font_typewriter \"" << h_font_typewriter[0]
<< "\" \"" << h_font_typewriter[1] << "\"\n"
<< "\\font_math \"" << h_font_math[0] << "\" \"" << h_font_math[1] << "\"\n"
<< "\\font_default_family " << h_font_default_family << "\n"
<< "\\use_non_tex_fonts " << (h_use_non_tex_fonts ? "true" : "false") << '\n'
<< "\\font_sc " << h_font_sc << "\n"
<< "\\font_osf " << h_font_osf << "\n"
<< "\\font_sf_scale " << h_font_sf_scale << "\n"
<< "\\font_tt_scale " << h_font_tt_scale << '\n';
<< "\\font_sf_scale " << h_font_sf_scale[0]
<< ' ' << h_font_sf_scale[1] << '\n'
<< "\\font_tt_scale " << h_font_tt_scale[0]
<< ' ' << h_font_tt_scale[1] << '\n';
if (!h_font_cjk.empty())
os << "\\font_cjk " << h_font_cjk << '\n';
os << "\\graphics " << h_graphics << '\n'
@ -1357,7 +1367,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
else if (t.cs() == "setmainfont") {
// we don't care about the option
p.hasOpt() ? p.getOpt() : string();
h_font_roman = p.getArg('{', '}');
h_font_roman[1] = p.getArg('{', '}');
}
else if (t.cs() == "setsansfont" || t.cs() == "setmonofont") {
@ -1377,12 +1387,12 @@ void Preamble::parse(Parser & p, string const & forceclass,
}
if (t.cs() == "setsansfont") {
if (!scale.empty())
h_font_sf_scale = scale;
h_font_sans = p.getArg('{', '}');
h_font_sf_scale[1] = scale;
h_font_sans[1] = p.getArg('{', '}');
} else {
if (!scale.empty())
h_font_tt_scale = scale;
h_font_typewriter = p.getArg('{', '}');
h_font_tt_scale[1] = scale;
h_font_typewriter[1] = p.getArg('{', '}');
}
}
@ -1528,19 +1538,19 @@ void Preamble::parse(Parser & p, string const & forceclass,
// font settings
if (name == "\\rmdefault")
if (is_known(body, known_roman_fonts)) {
h_font_roman = body;
h_font_roman[0] = body;
p.skip_spaces();
in_lyx_preamble = true;
}
if (name == "\\sfdefault")
if (is_known(body, known_sans_fonts)) {
h_font_sans = body;
h_font_sans[0] = body;
p.skip_spaces();
in_lyx_preamble = true;
}
if (name == "\\ttdefault")
if (is_known(body, known_typewriter_fonts)) {
h_font_typewriter = body;
h_font_typewriter[0] = body;
p.skip_spaces();
in_lyx_preamble = true;
}

View File

@ -131,16 +131,16 @@ private:
std::string h_float_placement;
std::string h_fontcolor;
std::string h_fontencoding;
std::string h_font_math;
std::string h_font_roman;
std::string h_font_sans;
std::string h_font_typewriter;
std::string h_font_math[2];
std::string h_font_roman[2];
std::string h_font_sans[2];
std::string h_font_typewriter[2];
std::string h_font_default_family;
bool h_use_non_tex_fonts;
std::string h_font_sc;
std::string h_font_osf;
std::string h_font_sf_scale;
std::string h_font_tt_scale;
std::string h_font_sf_scale[2];
std::string h_font_tt_scale[2];
bool h_font_cjk_set;
std::string h_font_cjk;
std::string h_graphics;

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -21,16 +21,16 @@
\language_package default
\inputencoding utf8
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -21,16 +21,16 @@
\language_package default
\inputencoding utf8-cjk
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -10,16 +10,16 @@
\language_package none
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -10,16 +10,16 @@
\language_package none
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -20,16 +20,16 @@
\language_package default
\inputencoding auto
\fontencoding default
\font_roman Linux Libertine O
\font_sans Linux Biolinum O
\font_typewriter Linux Biolinum O
\font_math auto
\font_roman "default" "Linux Libertine O"
\font_sans "default" "Linux Biolinum O"
\font_typewriter "default" "Linux Biolinum O"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 75
\font_tt_scale 100
\font_sf_scale 100 75
\font_tt_scale 100 100
\graphics default
\default_output_format pdf4
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -19,16 +19,16 @@ algorithm2e
\language_package none
\inputencoding iso8859-1
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -45,16 +45,16 @@
\language_package none
\inputencoding iso8859-15
\fontencoding T1
\font_roman cmr
\font_sans berasans
\font_typewriter default
\font_math auto
\font_roman "cmr" "default"
\font_sans "berasans" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family sfdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -46,16 +46,16 @@
\language_package none
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -22,16 +22,16 @@
\language_package none
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -17,16 +17,16 @@
\language_package default
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -17,16 +17,16 @@ theorems-ams
\language_package default
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -17,16 +17,16 @@ theorems-ams
\language_package default
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -14,16 +14,16 @@
\language_package default
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -49,16 +49,16 @@ logicalmkup
\language_package default
\inputencoding iso8859-15
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 1

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -21,16 +21,16 @@
\language_package none
\inputencoding auto
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
\lyxformat 500
\lyxformat 501
\begin_document
\begin_header
\origin roundtrip
@ -10,16 +10,16 @@
\language_package none
\inputencoding auto
\fontencoding default
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0

View File

@ -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 500 // uwestoehr: achemso layout improvement
#define LYX_FORMAT_TEX2LYX 500
#define LYX_FORMAT_LYX 501 // gb: store both TeX and non-TeX font selections
#define LYX_FORMAT_TEX2LYX 501
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER