From: Jürgen Spitzmüller Date: Fri, 26 Nov 2010 09:42:03 +0000 (+0000) Subject: Implement GUI for LuaTeX. File format change due to the renaming of the \use_xetex... X-Git-Tag: 2.0.0~1680 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2dc2e4770b779391657fdb405a9890abf0f9e4ab;p=features.git Implement GUI for LuaTeX. File format change due to the renaming of the \use_xetex buffer param. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36500 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/FORMAT b/development/FORMAT index 3c584ce233..bdb712cbfe 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2010-11-28 Jürgen Spitzmüller + * Format incremented to 409: + Rename buffer param \use_xetex to \use_non_tex_fonts. + + 2010-11-21 Georg Baum * Format incremented to 408 (r36424) New inset for sub/superscripts: diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index b3a9fe0fe7..cf37d6d5e2 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -2361,6 +2361,28 @@ def revert_script(document): add_to_preamble(document, ['\\usepackage{subscript}']) +def convert_use_xetex(document): + " convert \\use_xetex to \\use_non_tex_fonts " + i = 0 + i = find_token(document.header, "\\use_xetex", 0) + if i == -1: + document.warning("Malformed document. No \\use_xetex param!") + else: + val = get_value(document.header, "\\use_xetex", 0) + document.header[i] = "\\use_non_tex_fonts " + val + + +def revert_use_xetex(document): + " revert \\use_non_tex_fonts to \\use_xetex " + i = 0 + i = find_token(document.header, "\\use_non_tex_fonts", 0) + if i == -1: + document.warning("Malformed document. No \\use_non_tex_fonts param!") + else: + val = get_value(document.header, "\\use_non_tex_fonts", 0) + document.header[i] = "\\use_xetex " + val + + ## # Conversion hub # @@ -2428,10 +2450,12 @@ convert = [[346, []], [405, []], [406, [convert_passthru]], [407, []], - [408, []] + [408, []], + [409, [convert_use_xetex]] ] -revert = [[407, [revert_script]], +revert = [[408, [revert_use_xetex]], + [407, [revert_script]], [406, [revert_multirowOffset]], [405, [revert_passthru]], [404, []], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 4e18634dd4..28ee885900 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -128,7 +128,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 408; // gb add script inset +int const LYX_FORMAT = 409; // spitz use_xetex -> use_non_tex_fonts typedef map DepClean; typedef map > RefCache; @@ -3043,7 +3043,7 @@ void Buffer::getSourceCode(odocstream & os, pit_type par_begin, { OutputParams runparams(¶ms().encoding()); runparams.nice = true; - runparams.flavor = params().useXetex ? + runparams.flavor = params().useNonTeXFonts ? OutputParams::XETEX : OutputParams::LATEX; runparams.linelen = lyxrc.plaintext_linelen; // No side effect of file copying and image conversion @@ -3322,7 +3322,7 @@ string Buffer::bufferFormat() const { string format = params().documentClass().outputFormat(); if (format == "latex") { - if (params().useXetex) + if (params().useNonTeXFonts) return "xetex"; if (params().encoding().package() == Encoding::japanese) return "platex"; @@ -3340,7 +3340,7 @@ string Buffer::getDefaultOutputFormat() const Formats formats = exportableFormats(true); if (isDocBook() || isLiterate() - || params().useXetex + || params().useNonTeXFonts || params().encoding().package() == Encoding::japanese) { if (formats.empty()) return string(); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index c09f5bbbad..f1e655a138 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -379,7 +379,7 @@ BufferParams::BufferParams() fontsSans = "default"; fontsTypewriter = "default"; fontsDefaultFamily = "default"; - useXetex = false; + useNonTeXFonts = false; fontsSC = false; fontsOSF = false; fontsSansScale = 100; @@ -627,8 +627,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, fontsTypewriter = lex.getString(); } else if (token == "\\font_default_family") { lex >> fontsDefaultFamily; - } else if (token == "\\use_xetex") { - lex >> useXetex; + } else if (token == "\\use_non_tex_fonts") { + lex >> useNonTeXFonts; } else if (token == "\\font_sc") { lex >> fontsSC; } else if (token == "\\font_osf") { @@ -951,7 +951,7 @@ void BufferParams::writeFile(ostream & os) const << "\n\\font_sans " << fontsSans << "\n\\font_typewriter " << fontsTypewriter << "\n\\font_default_family " << fontsDefaultFamily - << "\n\\use_xetex " << convert(useXetex) + << "\n\\use_non_tex_fonts " << convert(useNonTeXFonts) << "\n\\font_sc " << convert(fontsSC) << "\n\\font_osf " << convert(fontsOSF) << "\n\\font_sf_scale " << fontsSansScale @@ -1339,7 +1339,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, texrow.newline(); // end of \documentclass defs - if (useXetex) { + if (useNonTeXFonts) { os << "\\usepackage{fontspec}\n"; texrow.newline(); } @@ -1348,7 +1348,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, string const fonts = loadFonts(fontsRoman, fontsSans, fontsTypewriter, fontsSC, fontsOSF, - fontsSansScale, fontsTypewriterScale, useXetex); + fontsSansScale, fontsTypewriterScale, useNonTeXFonts); if (!fonts.empty()) { os << from_ascii(fonts); texrow.newline(); @@ -2553,7 +2553,7 @@ string const BufferParams::loadFonts(string const & rm, string const & sf, string const & tt, bool const & sc, bool const & osf, int const & sfscale, int const & ttscale, - bool const & xetex) const + bool const & use_systemfonts) const { /* The LaTeX font world is in a flux. In the PSNFSS font interface, several packages have been replaced by others, that might not @@ -2573,7 +2573,7 @@ string const BufferParams::loadFonts(string const & rm, ostringstream os; - if (xetex) { + if (use_systemfonts) { if (rm != "default") { os << "\\setmainfont[Mapping=tex-text"; if (osf) @@ -2721,7 +2721,11 @@ string const BufferParams::loadFonts(string const & rm, Encoding const & BufferParams::encoding() const { - if (useXetex) + // FIXME: actually, we should check for the flavor + // or runparams.isFullyUnicode() here. + // useNonTeXFonts happens to match the flavors, but + // this may well likely change! + if (useNonTeXFonts) return *(encodings.fromLaTeXName("utf8-plain")); if (inputenc == "auto" || inputenc == "default") return *language->encoding(); diff --git a/src/BufferParams.h b/src/BufferParams.h index ffeb33c671..93fbe68d05 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -215,8 +215,8 @@ public: std::string fontsTypewriter; /// the default family (rm, sf, tt) std::string fontsDefaultFamily; - /// use the XeTeX processor - bool useXetex; + /// use the fonts of the OS (OpenType, True Type) directly + bool useNonTeXFonts; /// use expert Small Caps bool fontsSC; /// use Old Style Figures @@ -374,7 +374,7 @@ public: std::string const & sf, std::string const & tt, bool const & sc, bool const & osf, int const & sfscale, int const & ttscale, - bool const & xetex) const; + bool const & use_nonlatexfonts) const; /// get the appropriate cite engine (natbib handling) CiteEngine citeEngine() const; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 5c2f6b4e68..db27f00f2b 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -726,10 +726,6 @@ GuiDocument::GuiDocument(GuiView & lv) // output outputModule = new UiWidget; - connect(outputModule->xetexCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); - connect(outputModule->xetexCB, SIGNAL(toggled(bool)), - this, SLOT(xetexChanged(bool))); connect(outputModule->defaultFormatCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(outputModule->mathimgSB, SIGNAL(valueChanged(double)), @@ -750,6 +746,10 @@ GuiDocument::GuiDocument(GuiView & lv) // fonts fontModule = new UiWidget; + connect(fontModule->osFontsCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); + connect(fontModule->osFontsCB, SIGNAL(toggled(bool)), + this, SLOT(osFontsChanged(bool))); connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), @@ -1585,38 +1585,39 @@ void GuiDocument::deleteBoxBackgroundColor() } -void GuiDocument::xetexChanged(bool xetex) +void GuiDocument::osFontsChanged(bool nontexfonts) { + bool const tex_fonts = !nontexfonts; updateFontlist(); updateDefaultFormat(); - langModule->encodingCO->setEnabled(!xetex && + langModule->encodingCO->setEnabled(tex_fonts && !langModule->defaultencodingRB->isChecked()); - langModule->defaultencodingRB->setEnabled(!xetex); - langModule->otherencodingRB->setEnabled(!xetex); + langModule->defaultencodingRB->setEnabled(tex_fonts); + langModule->otherencodingRB->setEnabled(tex_fonts); - fontModule->fontsDefaultCO->setEnabled(!xetex); - fontModule->fontsDefaultLA->setEnabled(!xetex); - fontModule->cjkFontLE->setEnabled(!xetex); - fontModule->cjkFontLA->setEnabled(!xetex); + fontModule->fontsDefaultCO->setEnabled(tex_fonts); + fontModule->fontsDefaultLA->setEnabled(tex_fonts); + fontModule->cjkFontLE->setEnabled(tex_fonts); + fontModule->cjkFontLA->setEnabled(tex_fonts); string font; - if (!xetex) + if (tex_fonts) font = tex_fonts_sans[fontModule->fontsSansCO->currentIndex()]; bool scaleable = providesScale(font); fontModule->scaleSansSB->setEnabled(scaleable); fontModule->scaleSansLA->setEnabled(scaleable); - if (!xetex) + if (tex_fonts) font = tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()]; scaleable = providesScale(font); fontModule->scaleTypewriterSB->setEnabled(scaleable); fontModule->scaleTypewriterLA->setEnabled(scaleable); - if (!xetex) + if (tex_fonts) font = tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()]; fontModule->fontScCB->setEnabled(providesSC(font)); fontModule->fontOsfCB->setEnabled(providesOSF(font)); - fontModule->fontencLA->setEnabled(!xetex); - fontModule->fontencCO->setEnabled(!xetex); - if (xetex) + fontModule->fontencLA->setEnabled(tex_fonts); + fontModule->fontencCO->setEnabled(tex_fonts); + if (!tex_fonts) fontModule->fontencLE->setEnabled(false); else fontencChanged(fontModule->fontencCO->currentIndex()); @@ -1648,7 +1649,7 @@ void GuiDocument::updateFontlist() fontModule->fontsTypewriterCO->clear(); // With XeTeX, we have access to all system fonts, but not the LaTeX fonts - if (outputModule->xetexCB->isChecked()) { + if (fontModule->osFontsCB->isChecked()) { fontModule->fontsRomanCO->addItem(qt_("Default")); fontModule->fontsSansCO->addItem(qt_("Default")); fontModule->fontsTypewriterCO->addItem(qt_("Default")); @@ -1692,7 +1693,7 @@ void GuiDocument::fontencChanged(int item) void GuiDocument::romanChanged(int item) { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) return; string const font = tex_fonts_roman[item]; fontModule->fontScCB->setEnabled(providesSC(font)); @@ -1702,7 +1703,7 @@ void GuiDocument::romanChanged(int item) void GuiDocument::sansChanged(int item) { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) return; string const font = tex_fonts_sans[item]; bool scaleable = providesScale(font); @@ -1713,7 +1714,7 @@ void GuiDocument::sansChanged(int item) void GuiDocument::ttChanged(int item) { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) return; string const font = tex_fonts_monospaced[item]; bool scaleable = providesScale(font); @@ -2073,7 +2074,8 @@ void GuiDocument::updateDefaultFormat() return; // make a copy in order to consider unapplied changes Buffer * tmpbuf = buffer().clone(); - tmpbuf->params().useXetex = outputModule->xetexCB->isChecked(); + tmpbuf->params().useNonTeXFonts = + fontModule->osFontsCB->isChecked(); int idx = latexModule->classCO->currentIndex(); if (idx >= 0) { string const classname = classes_model_.getIDString(idx); @@ -2389,8 +2391,8 @@ void GuiDocument::applyView() bp_.defaultOutputFormat = fromqstr(outputModule->defaultFormatCO->itemData( outputModule->defaultFormatCO->currentIndex()).toString()); - bool const xetex = outputModule->xetexCB->isChecked(); - bp_.useXetex = xetex; + bool const nontexfonts = fontModule->osFontsCB->isChecked(); + bp_.useNonTeXFonts = nontexfonts; bp_.output_sync = outputModule->outputsyncCB->isChecked(); bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText()); @@ -2405,7 +2407,7 @@ void GuiDocument::applyView() bp_.html_math_img_scale = outputModule->mathimgSB->value(); // fonts - if (xetex) { + if (nontexfonts) { if (fontModule->fontsRomanCO->currentIndex() == 0) bp_.fontsRoman = "default"; else @@ -2452,7 +2454,7 @@ void GuiDocument::applyView() bp_.fontsOSF = fontModule->fontOsfCB->isChecked(); - if (xetex) + if (nontexfonts) bp_.fontsDefaultFamily = "default"; else bp_.fontsDefaultFamily = GuiDocument::fontfamilies[ @@ -2825,9 +2827,9 @@ void GuiDocument::paramsToDialog() if (index == -1) index = 0; outputModule->defaultFormatCO->setCurrentIndex(index); - outputModule->xetexCB->setEnabled(bp_.baseClass()->outputType() == lyx::LATEX); - outputModule->xetexCB->setChecked( - bp_.baseClass()->outputType() == lyx::LATEX && bp_.useXetex); + fontModule->osFontsCB->setEnabled(bp_.baseClass()->outputType() == lyx::LATEX); + fontModule->osFontsCB->setChecked( + bp_.baseClass()->outputType() == lyx::LATEX && bp_.useNonTeXFonts); outputModule->outputsyncCB->setChecked(bp_.output_sync); outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro)); @@ -2840,7 +2842,7 @@ void GuiDocument::paramsToDialog() updateFontsize(documentClass().opt_fontsize(), bp_.fontsize); - if (bp_.useXetex) { + if (bp_.useNonTeXFonts) { fontModule->fontencLA->setEnabled(false); fontModule->fontencCO->setEnabled(false); fontModule->fontencLE->setEnabled(false); @@ -3366,7 +3368,7 @@ bool GuiDocument::isFontAvailable(string const & font) const bool GuiDocument::providesOSF(string const & font) const { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) // FIXME: we should check if the fonts really // have OSF support. But how? return true; @@ -3380,7 +3382,7 @@ bool GuiDocument::providesOSF(string const & font) const bool GuiDocument::providesSC(string const & font) const { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) return false; if (font == "palatino") return isFontAvailable("mathpazo"); @@ -3392,7 +3394,7 @@ bool GuiDocument::providesSC(string const & font) const bool GuiDocument::providesScale(string const & font) const { - if (outputModule->xetexCB->isChecked()) + if (fontModule->osFontsCB->isChecked()) return true; return font == "helvet" || font == "luximono" || font == "berasans" || font == "beramono"; diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 2d3a92f290..b2b15e1fcd 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -115,7 +115,7 @@ private Q_SLOTS: void deleteNoteFontColor(); void changeBoxBackgroundColor(); void deleteBoxBackgroundColor(); - void xetexChanged(bool); + void osFontsChanged(bool); void branchesRename(docstring const &, docstring const &); private: /// validate listings parameters and return an error message, if any diff --git a/src/frontends/qt4/ui/FontUi.ui b/src/frontends/qt4/ui/FontUi.ui index 893f74cbe8..bf0d93efd9 100644 --- a/src/frontends/qt4/ui/FontUi.ui +++ b/src/frontends/qt4/ui/FontUi.ui @@ -5,15 +5,38 @@ 0 0 - 404 - 256 + 407 + 285 FontUi - + + + + Use OpenType- and TrueType fonts directly (requires XeTeX or LuaTeX) + + + &Use non-TeX fonts (via XeTeX/LuaTeX) + + + + + + + Qt::Horizontal + + + + 59 + 20 + + + + + &Default Family: @@ -23,14 +46,14 @@ - + Select the default family for the document - + &Base Size: @@ -40,14 +63,14 @@ - + - + LaTe&X font encoding: @@ -57,17 +80,17 @@ - + - + Specify the font encoding (e.g., T1). - + &Roman: @@ -77,14 +100,14 @@ - + Select the roman (serif) typeface - + &Sans Serif: @@ -94,14 +117,14 @@ - + Select the Sans Serif (grotesque) typeface - + S&cale (%): @@ -111,7 +134,7 @@ - + Scale the Sans Serif font to match the base font's dimensions @@ -124,7 +147,7 @@ - + &Typewriter: @@ -134,14 +157,14 @@ - + Select the typewriter (monospaced) typeface - + Sc&ale (%): @@ -151,7 +174,7 @@ - + Scale the Typewriter font to match the base font's dimensions @@ -164,7 +187,7 @@ - + C&JK: @@ -174,14 +197,14 @@ - + Input the font to be used for Chinese, Japanese or Korean (CJK) script - + Use a real small caps shape, if the font provides one @@ -191,7 +214,7 @@ - + Use old style instead of lining figures @@ -201,7 +224,7 @@ - + Qt::Vertical diff --git a/src/frontends/qt4/ui/OutputUi.ui b/src/frontends/qt4/ui/OutputUi.ui index 862183cde9..9fb84e4219 100644 --- a/src/frontends/qt4/ui/OutputUi.ui +++ b/src/frontends/qt4/ui/OutputUi.ui @@ -1,7 +1,7 @@ - + OutputUi - - + + 0 0 @@ -9,104 +9,94 @@ 334 - + Form - - - - + + + + Output Format - + true - - + + 9 - + 6 - - - + + + 6 - + 0 - - + + Specify the default output format (for view/update) - + De&fault Output Format: - + defaultFormatCO - - + + Specify the default output format (for view/update) - - - - Use the XeTeX processing engine - - - Use &XeTeX - - - - - - + + + Enable forward/reverse search between editor and output (e.g., SyncTeX) - + S&ynchronize with Output - + true - + true - + false - + - + - - + + C&ustom Macro: - + synccustomCB - - + + Custom LaTeX preamble macro - + true @@ -116,111 +106,111 @@ - - - + + + XHTML Output Options - + true - - - - + + + + Whether to comply strictly with XHTML 1.1. - + &Strict XHTML 1.1 - - - + + + 50 false - + &Math Output: - - mathoutCB + + mathoutCB - - - + + + 50 false - + Format to use for math output. - + MathML - + HTML - + Images - + LaTeX - - - + + + 50 false - + Math &Image Scaling: - - mathimgSB - + + mathimgSB + - - - + + + 50 false - + Scaling factor for images used for math output. - + 0.100000000000000 - + 10.000000000000000 - + 0.100000000000000 - + 1.000000000000000 @@ -228,12 +218,12 @@ - - - + + + Qt::Vertical - + 20 40 @@ -244,7 +234,7 @@ - qt_i18n.h + qt_i18n.h