]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Treat math style a bit more like other font features
[lyx.git] / src / Font.cpp
index b810e454d4c65335bed03d0bef5c613698d9f9ec..965a8309ef992da27e76503106e05f08add099df 100644 (file)
@@ -143,41 +143,42 @@ void Font::update(Font const & newfont,
 }
 
 
-docstring const stateText(FontInfo const & f)
+docstring const stateText(FontInfo const & f, bool const terse)
 {
        odocstringstream os;
-       if (f.family() != INHERIT_FAMILY)
+       if (f.family() != INHERIT_FAMILY && (!terse || f.family() != IGNORE_FAMILY))
                os << _(GUIFamilyNames[f.family()]) << ", ";
-       if (f.series() != INHERIT_SERIES)
+       if (f.series() != INHERIT_SERIES && (!terse || f.series() != IGNORE_SERIES))
                os << _(GUISeriesNames[f.series()]) << ", ";
-       if (f.shape() != INHERIT_SHAPE)
+       if (f.shape() != INHERIT_SHAPE && (!terse || f.shape() != IGNORE_SHAPE))
                os << _(GUIShapeNames[f.shape()]) << ", ";
-       if (f.size() != FONT_SIZE_INHERIT)
+       if (f.size() != FONT_SIZE_INHERIT && (!terse || f.size() != FONT_SIZE_IGNORE))
                os << _(GUISizeNames[f.size()]) << ", ";
-       if (f.color() != Color_inherit)
+       // FIXME: shall style be handled there? Probably not.
+       if (f.color() != Color_inherit && (!terse || f.color() != Color_ignore))
                os << lcolor.getGUIName(f.color()) << ", ";
        // FIXME: uncomment this when we support background.
        //if (f.background() != Color_inherit)
        //      os << lcolor.getGUIName(f.background()) << ", ";
-       if (f.emph() != FONT_INHERIT)
+       if (f.emph() != FONT_INHERIT && (!terse || f.emph() != FONT_IGNORE))
                os << bformat(_("Emphasis %1$s, "),
                              _(GUIMiscNames[f.emph()]));
-       if (f.underbar() != FONT_INHERIT)
+       if (f.underbar() != FONT_INHERIT && (!terse || f.underbar() == FONT_ON))
                os << bformat(_("Underline %1$s, "),
                              _(GUIMiscNames[f.underbar()]));
-       if (f.strikeout() != FONT_INHERIT)
-               os << bformat(_("Strike out %1$s, "),
-                             _(GUIMiscNames[f.strikeout()]));
-       if (f.xout() != FONT_INHERIT)
-               os << bformat(_("Cross out %1$s, "),
-                             _(GUIMiscNames[f.xout()]));
-       if (f.uuline() != FONT_INHERIT)
+       if (f.uuline() != FONT_INHERIT && (!terse || f.uuline() == FONT_ON))
                os << bformat(_("Double underline %1$s, "),
                              _(GUIMiscNames[f.uuline()]));
-       if (f.uwave() != FONT_INHERIT)
+       if (f.uwave() != FONT_INHERIT && (!terse || f.uwave() == FONT_ON))
                os << bformat(_("Wavy underline %1$s, "),
                              _(GUIMiscNames[f.uwave()]));
-       if (f.noun() != FONT_INHERIT)
+       if (f.strikeout() != FONT_INHERIT && (!terse || f.strikeout() == FONT_ON))
+               os << bformat(_("Strike out %1$s, "),
+                             _(GUIMiscNames[f.strikeout()]));
+       if (f.xout() != FONT_INHERIT && (!terse || f.xout() == FONT_ON))
+               os << bformat(_("Cross out %1$s, "),
+                             _(GUIMiscNames[f.xout()]));
+       if (f.noun() != FONT_INHERIT && (!terse || f.noun() != FONT_IGNORE))
                os << bformat(_("Noun %1$s, "),
                              _(GUIMiscNames[f.noun()]));
        if (f == inherit_font)
@@ -187,13 +188,17 @@ docstring const stateText(FontInfo const & f)
 }
 
 
-docstring const Font::stateText(BufferParams * params) const
+docstring const Font::stateText(BufferParams * params, bool const terse) const
 {
        odocstringstream os;
-       os << lyx::stateText(bits_);
-       if (!params || (language() != params->language))
+       os << lyx::stateText(bits_, terse);
+       if ((!params || (language() != params->language))
+           && (!terse || language() != ignore_language)) {
+               // reset_language is a null pointer!
                os << bformat(_("Language: %1$s, "),
-                             _(language()->display()));
+                             (language() == reset_language) ? _("Default")
+                                                            : _(language()->display()));
+       }
        if (bits_.number() != FONT_OFF)
                os << "  " << bformat(_("Number %1$s"),
                              _(GUIMiscNames[bits_.number()]));
@@ -221,10 +226,13 @@ void Font::lyxWriteChanges(Font const & orgfont,
                os << "\\shape " << LyXShapeNames[bits_.shape()] << "\n";
        if (orgfont.fontInfo().size() != bits_.size())
                os << "\\size " << LyXSizeNames[bits_.size()] << "\n";
+       // FIXME: shall style be handled there? Probably not.
        if (orgfont.fontInfo().emph() != bits_.emph())
                os << "\\emph " << LyXMiscNames[bits_.emph()] << "\n";
        if (orgfont.fontInfo().number() != bits_.number())
                os << "\\numeric " << LyXMiscNames[bits_.number()] << "\n";
+       if (orgfont.fontInfo().nospellcheck() != bits_.nospellcheck())
+               os << "\\nospellcheck " << LyXMiscNames[bits_.nospellcheck()] << "\n";
        if (orgfont.fontInfo().underbar() != bits_.underbar()) {
                // This is only for backwards compatibility
                switch (bits_.underbar()) {
@@ -347,21 +355,6 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                }
        }
 
-       // If the current language is Hebrew, Arabic, or Farsi
-       // the numbers are written Left-to-Right. ArabTeX package
-       // and bidi (polyglossia) reorder the number automatically
-       // but the packages used for Hebrew and Farsi (Arabi) do not.
-       if (!runparams.use_polyglossia
-           && !runparams.pass_thru
-           && bits_.number() == FONT_ON
-           && prev.fontInfo().number() != FONT_ON
-           && (language()->lang() == "hebrew"
-               || language()->lang() == "farsi"
-               || language()->lang() == "arabic_arabi")) {
-               os << "{\\beginL ";
-               count += 9;
-       }
-
        FontInfo f = bits_;
        f.reduce(base.bits_);
        FontInfo p = bits_;
@@ -411,6 +404,20 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                env = true; //We have opened a new environment
        }
        */
+       // If the current language is Hebrew, Arabic, or Farsi
+       // the numbers are written Left-to-Right. ArabTeX package
+       // and bidi (polyglossia) reorder the number automatically
+       // but the packages used for Hebrew and Farsi (Arabi) do not.
+       if (!runparams.use_polyglossia
+           && !runparams.pass_thru
+           && bits_.number() == FONT_ON
+           && prev.fontInfo().number() != FONT_ON
+           && (language()->lang() == "hebrew"
+               || language()->lang() == "farsi"
+               || language()->lang() == "arabic_arabi")) {
+               os << "{\\beginL ";
+               count += 9;
+       }
        if (f.emph() == FONT_ON) {
                os << "\\emph{";
                count += 6;
@@ -619,6 +626,7 @@ string Font::toString(bool const toggle) const
           << "uwave " << bits_.uwave() << '\n'
           << "noun " << bits_.noun() << '\n'
           << "number " << bits_.number() << '\n'
+          << "nospellcheck " << bits_.nospellcheck() << '\n'
           << "color " << bits_.color() << '\n'
           << "language " << lang << '\n'
           << "toggleall " << convert<string>(toggle);
@@ -656,11 +664,12 @@ bool Font::fromString(string const & data, bool & toggle)
                } else if (token == "size") {
                        int const next = lex.getInteger();
                        bits_.setSize(FontSize(next));
-
+               // FIXME: shall style be handled there? Probably not.
                } else if (token == "emph" || token == "underbar"
                        || token == "noun" || token == "number"
                        || token == "uuline" || token == "uwave"
-                       || token == "strikeout" || token == "xout") {
+                       || token == "strikeout" || token == "xout"
+                       || token == "nospellcheck") {
 
                        int const next = lex.getInteger();
                        FontState const misc = FontState(next);
@@ -681,6 +690,8 @@ bool Font::fromString(string const & data, bool & toggle)
                                bits_.setNoun(misc);
                        else if (token == "number")
                                bits_.setNumber(misc);
+                       else if (token == "nospellcheck")
+                               bits_.setNoSpellcheck(misc);
 
                } else if (token == "color") {
                        int const next = lex.getInteger();
@@ -799,6 +810,7 @@ ostream & operator<<(ostream & os, FontInfo const & f)
                << " series " << f.series()
                << " shape " << f.shape()
                << " size " << f.size()
+               << " style " << f.style()
                << " color " << f.color()
                // FIXME: uncomment this when we support background.
                //<< " background " << f.background()
@@ -809,7 +821,8 @@ ostream & operator<<(ostream & os, FontInfo const & f)
                << " uuline " << f.uuline()
                << " uwave " << f.uwave()
                << " noun " << f.noun()
-               << " number " << f.number();
+               << " number " << f.number()
+               << " nospellcheck " << f.nospellcheck();
 }