From 0738ff08baa63c598b08e5a6538edf76a1718551 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 13 Jul 2019 14:55:07 +0200 Subject: [PATCH] Consider CompleteFont with MoreOptions --- src/LaTeXFonts.cpp | 15 ++++++++++ src/LaTeXFonts.h | 2 +- src/frontends/qt4/GuiDocument.cpp | 48 +++++++++++++++++++------------ src/frontends/qt4/GuiDocument.h | 2 ++ 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp index 422c8c7ca3..c2e934539d 100644 --- a/src/LaTeXFonts.cpp +++ b/src/LaTeXFonts.cpp @@ -137,6 +137,21 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath) return (!scaleoption_.empty()); } + +bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath) +{ + docstring const usedfont = getUsedFont(ot1, complete, nomath); + + if (usedfont.empty()) + return false; + else if (usedfont != name_) + return altFont(usedfont).providesMoreOptions(ot1, complete, nomath); + else if (!available(ot1, nomath)) + return false; + + return (moreopts_); +} + bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool nomath) { docstring const usedfont = getUsedFont(ot1, complete, nomath); diff --git a/src/LaTeXFonts.h b/src/LaTeXFonts.h index d15281cd97..50ec71ad90 100644 --- a/src/LaTeXFonts.h +++ b/src/LaTeXFonts.h @@ -59,7 +59,7 @@ public: /// A package option for font scaling docstring const & scaleoption() { return scaleoption_; } /// Does this provide additional options? - bool moreoptions() const { return moreopts_; } + bool providesMoreOptions(bool ot1, bool complete, bool nomath); /// Alternative requirement to test for docstring const & requires() { return requires_; } /// Does this font provide a given \p feature diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index f1b4f8e7b3..c40736cfe7 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2427,7 +2427,7 @@ void GuiDocument::fontScToggled(bool state) } -void GuiDocument::updateFontOptions() +void GuiDocument::updateExtraOpts() { bool const tex_fonts = !fontModule->osFontsCB->isChecked(); QString font; @@ -2438,15 +2438,34 @@ void GuiDocument::updateFontOptions() if (tex_fonts) font = fontModule->fontsSansCO->itemData( fontModule->fontsSansCO->currentIndex()).toString(); - bool scaleable = providesScale(font); bool const sf_opts = providesExtraOpts(font); + if (tex_fonts) + font = fontModule->fontsTypewriterCO->itemData( + fontModule->fontsTypewriterCO->currentIndex()).toString(); + bool const tt_opts = providesExtraOpts(font); + fontModule->fontspecRomanLA->setEnabled(!tex_fonts || rm_opts); + fontModule->fontspecRomanLE->setEnabled(!tex_fonts || rm_opts); + fontModule->fontspecSansLA->setEnabled(!tex_fonts || sf_opts); + fontModule->fontspecSansLE->setEnabled(!tex_fonts || sf_opts); + fontModule->fontspecTypewriterLA->setEnabled(!tex_fonts || tt_opts); + fontModule->fontspecTypewriterLE->setEnabled(!tex_fonts || tt_opts); +} + + +void GuiDocument::updateFontOptions() +{ + bool const tex_fonts = !fontModule->osFontsCB->isChecked(); + QString font; + if (tex_fonts) + font = fontModule->fontsSansCO->itemData( + fontModule->fontsSansCO->currentIndex()).toString(); + bool scaleable = providesScale(font); fontModule->scaleSansSB->setEnabled(scaleable); fontModule->scaleSansLA->setEnabled(scaleable); if (tex_fonts) font = fontModule->fontsTypewriterCO->itemData( fontModule->fontsTypewriterCO->currentIndex()).toString(); scaleable = providesScale(font); - bool const tt_opts = providesExtraOpts(font); fontModule->scaleTypewriterSB->setEnabled(scaleable); fontModule->scaleTypewriterLA->setEnabled(scaleable); if (tex_fonts) @@ -2454,12 +2473,7 @@ void GuiDocument::updateFontOptions() fontModule->fontsRomanCO->currentIndex()).toString(); fontModule->fontScCB->setEnabled(providesSC(font)); fontModule->fontOsfCB->setEnabled(providesOSF(font)); - fontModule->fontspecRomanLA->setEnabled(!tex_fonts || rm_opts); - fontModule->fontspecRomanLE->setEnabled(!tex_fonts || rm_opts); - fontModule->fontspecSansLA->setEnabled(!tex_fonts || sf_opts); - fontModule->fontspecSansLE->setEnabled(!tex_fonts || sf_opts); - fontModule->fontspecTypewriterLA->setEnabled(!tex_fonts || tt_opts); - fontModule->fontspecTypewriterLE->setEnabled(!tex_fonts || tt_opts); + updateExtraOpts(); updateMathFonts(font); } @@ -2637,11 +2651,9 @@ void GuiDocument::romanChanged(int item) return; QString const font = fontModule->fontsRomanCO->itemData(item).toString(); - bool const opts = providesExtraOpts(font); fontModule->fontScCB->setEnabled(providesSC(font)); fontModule->fontOsfCB->setEnabled(providesOSF(font)); - fontModule->fontspecRomanLA->setEnabled(opts); - fontModule->fontspecRomanLE->setEnabled(opts); + updateExtraOpts(); updateMathFonts(font); } @@ -2653,11 +2665,9 @@ void GuiDocument::sansChanged(int item) QString const font = fontModule->fontsSansCO->itemData(item).toString(); bool const scaleable = providesScale(font); - bool const opts = providesExtraOpts(font); fontModule->scaleSansSB->setEnabled(scaleable); fontModule->scaleSansLA->setEnabled(scaleable); - fontModule->fontspecSansLA->setEnabled(opts); - fontModule->fontspecSansLE->setEnabled(opts); + updateExtraOpts(); } @@ -2668,11 +2678,9 @@ void GuiDocument::ttChanged(int item) QString const font = fontModule->fontsTypewriterCO->itemData(item).toString(); bool scaleable = providesScale(font); - bool const opts = providesExtraOpts(font); fontModule->scaleTypewriterSB->setEnabled(scaleable); fontModule->scaleTypewriterLA->setEnabled(scaleable); - fontModule->fontspecTypewriterLA->setEnabled(opts); - fontModule->fontspecTypewriterLE->setEnabled(opts); + updateExtraOpts(); } @@ -4957,7 +4965,9 @@ bool GuiDocument::providesExtraOpts(QString const & font) const if (fontModule->osFontsCB->isChecked()) return true; return theLaTeXFonts().getLaTeXFont( - qstring_to_ucs4(font)).moreoptions(); + qstring_to_ucs4(font)).providesMoreOptions(ot1(), + completeFontset(), + noMathFont()); } diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 219861bf94..9647f3b60c 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -307,6 +307,8 @@ private: /// void updateMathFonts(QString const & rm); /// + void updateExtraOpts(); + /// void updateFontOptions(); /// bool ot1() const;