3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
12 * Full author contact details are available in file CREDITS.
19 #include "BufferParams.h" // stateText
25 #include "LaTeXFeatures.h"
28 #include "output_latex.h"
29 #include "OutputParams.h"
31 #include "support/convert.h"
32 #include "support/lstrings.h"
37 using std::ostringstream;
38 using std::istringstream;
41 #ifndef CXX_GLOBAL_CSTD
48 using support::ascii_lowercase;
49 using support::bformat;
59 char const * GUIFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
60 { N_("Roman"), N_("Sans Serif"), N_("Typewriter"), N_("Symbol"),
61 "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
62 N_("Inherit"), N_("Ignore") };
64 char const * GUISeriesNames[4] =
65 { N_("Medium"), N_("Bold"), N_("Inherit"), N_("Ignore") };
67 char const * GUIShapeNames[6] =
68 { N_("Upright"), N_("Italic"), N_("Slanted"), N_("Smallcaps"), N_("Inherit"),
71 char const * GUISizeNames[14] =
72 { N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"), N_("Large"),
73 N_("Larger"), N_("Largest"), N_("Huge"), N_("Huger"), N_("Increase"), N_("Decrease"),
74 N_("Inherit"), N_("Ignore") };
76 char const * GUIMiscNames[5] =
77 { N_("Off"), N_("On"), N_("Toggle"), N_("Inherit"), N_("Ignore") };
81 // Strings used to read and write .lyx format files
83 char const * LyXFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
84 { "roman", "sans", "typewriter", "symbol",
85 "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
88 char const * LyXSeriesNames[4] =
89 { "medium", "bold", "default", "error" };
91 char const * LyXShapeNames[6] =
92 { "up", "italic", "slanted", "smallcaps", "default", "error" };
94 char const * LyXSizeNames[14] =
95 { "tiny", "scriptsize", "footnotesize", "small", "normal", "large",
96 "larger", "largest", "huge", "giant",
97 "increase", "decrease", "default", "error" };
99 char const * LyXMiscNames[5] =
100 { "off", "on", "toggle", "default", "error" };
103 // Strings used to write LaTeX files
105 char const * LaTeXFamilyNames[6] =
106 { "textrm", "textsf", "texttt", "error1", "error2", "error3" };
108 char const * LaTeXSeriesNames[4] =
109 { "textmd", "textbf", "error4", "error5" };
111 char const * LaTeXShapeNames[6] =
112 { "textup", "textit", "textsl", "textsc", "error6", "error7" };
114 char const * LaTeXSizeNames[14] =
115 { "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
116 "Large", "LARGE", "huge", "Huge", "error8", "error9", "error10", "error11" };
121 // Initialize static member
122 Font::FontBits Font::sane = {
133 // Initialize static member
134 Font::FontBits Font::inherit = {
145 // Initialize static member
146 Font::FontBits Font::ignore = {
158 bool operator==(Font::FontBits const & lhs,
159 Font::FontBits const & rhs)
161 return lhs.family == rhs.family &&
162 lhs.series == rhs.series &&
163 lhs.shape == rhs.shape &&
164 lhs.size == rhs.size &&
165 lhs.color == rhs.color &&
166 lhs.emph == rhs.emph &&
167 lhs.underbar == rhs.underbar &&
168 lhs.noun == rhs.noun &&
169 lhs.number == rhs.number;
174 : bits(sane), lang(default_language), open_encoding_(false)
178 Font::Font(Font::FONT_INIT1)
179 : bits(inherit), lang(default_language), open_encoding_(false)
183 Font::Font(Font::FONT_INIT2)
184 : bits(ignore), lang(ignore_language), open_encoding_(false)
188 Font::Font(Font::FONT_INIT3)
189 : bits(sane), lang(default_language), open_encoding_(false)
193 Font::Font(Font::FONT_INIT1, Language const * l)
194 : bits(inherit), lang(l), open_encoding_(false)
198 Font::Font(Font::FONT_INIT2, Language const * l)
199 : bits(ignore), lang(l), open_encoding_(false)
203 Font::Font(Font::FONT_INIT3, Language const * l)
204 : bits(sane), lang(l), open_encoding_(false)
209 ColorCode Font::color() const
211 return ColorCode(bits.color);
215 bool Font::isRightToLeft() const
217 return lang->rightToLeft();
221 bool Font::isVisibleRightToLeft() const
223 return (lang->rightToLeft() &&
228 void Font::setFamily(Font::FONT_FAMILY f)
234 void Font::setSeries(Font::FONT_SERIES s)
240 void Font::setShape(Font::FONT_SHAPE s)
246 void Font::setSize(Font::FONT_SIZE s)
252 void Font::setEmph(Font::FONT_MISC_STATE e)
258 void Font::setUnderbar(Font::FONT_MISC_STATE u)
264 void Font::setNoun(Font::FONT_MISC_STATE n)
270 void Font::setColor(ColorCode c)
276 void Font::setLanguage(Language const * l)
282 void Font::setNumber(Font::FONT_MISC_STATE n)
288 /// Decreases font size by one
289 Font & Font::decSize()
292 case SIZE_HUGER: setSize(SIZE_HUGE); break;
293 case SIZE_HUGE: setSize(SIZE_LARGEST); break;
294 case SIZE_LARGEST: setSize(SIZE_LARGER); break;
295 case SIZE_LARGER: setSize(SIZE_LARGE); break;
296 case SIZE_LARGE: setSize(SIZE_NORMAL); break;
297 case SIZE_NORMAL: setSize(SIZE_SMALL); break;
298 case SIZE_SMALL: setSize(SIZE_FOOTNOTE); break;
299 case SIZE_FOOTNOTE: setSize(SIZE_SCRIPT); break;
300 case SIZE_SCRIPT: setSize(SIZE_TINY); break;
301 case SIZE_TINY: break;
303 lyxerr << "Can't Font::decSize on INCREASE_SIZE" << endl;
306 lyxerr <<"Can't Font::decSize on DECREASE_SIZE" << endl;
309 lyxerr <<"Can't Font::decSize on INHERIT_SIZE" << endl;
312 lyxerr <<"Can't Font::decSize on IGNORE_SIZE" << endl;
319 /// Increases font size by one
320 Font & Font::incSize()
323 case SIZE_HUGER: break;
324 case SIZE_HUGE: setSize(SIZE_HUGER); break;
325 case SIZE_LARGEST: setSize(SIZE_HUGE); break;
326 case SIZE_LARGER: setSize(SIZE_LARGEST); break;
327 case SIZE_LARGE: setSize(SIZE_LARGER); break;
328 case SIZE_NORMAL: setSize(SIZE_LARGE); break;
329 case SIZE_SMALL: setSize(SIZE_NORMAL); break;
330 case SIZE_FOOTNOTE: setSize(SIZE_SMALL); break;
331 case SIZE_SCRIPT: setSize(SIZE_FOOTNOTE); break;
332 case SIZE_TINY: setSize(SIZE_SCRIPT); break;
334 lyxerr <<"Can't Font::incSize on INCREASE_SIZE" << endl;
337 lyxerr <<"Can't Font::incSize on DECREASE_SIZE" << endl;
340 lyxerr <<"Can't Font::incSize on INHERIT_SIZE" << endl;
343 lyxerr <<"Can't Font::incSize on IGNORE_SIZE" << endl;
350 /// Updates a misc setting according to request
351 Font::FONT_MISC_STATE Font::setMisc(FONT_MISC_STATE newfont,
354 if (newfont == TOGGLE) {
360 lyxerr <<"Font::setMisc: Need state"
361 " ON or OFF to toggle. Setting to ON" << endl;
364 } else if (newfont == IGNORE)
371 /// Updates font settings according to request
372 void Font::update(Font const & newfont,
373 Language const * document_language,
376 if (newfont.family() == family() && toggleall)
377 setFamily(INHERIT_FAMILY); // toggle 'back'
378 else if (newfont.family() != IGNORE_FAMILY)
379 setFamily(newfont.family());
380 // else it's IGNORE_SHAPE
382 // "Old" behaviour: "Setting" bold will toggle bold on/off.
383 switch (newfont.series()) {
386 if (series() == BOLD_SERIES && toggleall)
387 setSeries(MEDIUM_SERIES);
389 setSeries(BOLD_SERIES);
393 setSeries(newfont.series());
399 if (newfont.shape() == shape() && toggleall)
400 setShape(INHERIT_SHAPE); // toggle 'back'
401 else if (newfont.shape() != IGNORE_SHAPE)
402 setShape(newfont.shape());
403 // else it's IGNORE_SHAPE
405 if (newfont.size() != IGNORE_SIZE) {
406 if (newfont.size() == INCREASE_SIZE)
408 else if (newfont.size() == DECREASE_SIZE)
411 setSize(newfont.size());
414 setEmph(setMisc(newfont.emph(), emph()));
415 setUnderbar(setMisc(newfont.underbar(), underbar()));
416 setNoun(setMisc(newfont.noun(), noun()));
418 setNumber(setMisc(newfont.number(), number()));
419 if (newfont.language() == language() && toggleall)
420 if (language() == document_language)
421 setLanguage(default_language);
423 setLanguage(document_language);
424 else if (newfont.language() != ignore_language)
425 setLanguage(newfont.language());
427 if (newfont.color() == color() && toggleall)
428 setColor(Color_inherit); // toggle 'back'
429 else if (newfont.color() != Color_ignore)
430 setColor(newfont.color());
434 /// Reduce font to fall back to template where possible
435 void Font::reduce(Font const & tmplt)
437 if (family() == tmplt.family())
438 setFamily(INHERIT_FAMILY);
439 if (series() == tmplt.series())
440 setSeries(INHERIT_SERIES);
441 if (shape() == tmplt.shape())
442 setShape(INHERIT_SHAPE);
443 if (size() == tmplt.size())
444 setSize(INHERIT_SIZE);
445 if (emph() == tmplt.emph())
447 if (underbar() == tmplt.underbar())
448 setUnderbar(INHERIT);
449 if (noun() == tmplt.noun())
451 if (color() == tmplt.color())
452 setColor(Color_inherit);
456 /// Realize font from a template
457 Font & Font::realize(Font const & tmplt)
459 if (bits == inherit) {
464 if (bits.family == INHERIT_FAMILY)
465 bits.family = tmplt.bits.family;
467 if (bits.series == INHERIT_SERIES)
468 bits.series = tmplt.bits.series;
470 if (bits.shape == INHERIT_SHAPE)
471 bits.shape = tmplt.bits.shape;
473 if (bits.size == INHERIT_SIZE)
474 bits.size = tmplt.bits.size;
476 if (bits.emph == INHERIT)
477 bits.emph = tmplt.bits.emph;
479 if (bits.underbar == INHERIT)
480 bits.underbar = tmplt.bits.underbar;
482 if (bits.noun == INHERIT)
483 bits.noun = tmplt.bits.noun;
485 if (bits.color == Color_inherit)
486 bits.color = tmplt.bits.color;
492 /// Is font resolved?
493 bool Font::resolved() const
495 return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
496 shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
497 emph() != INHERIT && underbar() != INHERIT &&
499 color() != Color_inherit);
503 docstring const Font::stateText(BufferParams * params) const
506 if (family() != INHERIT_FAMILY)
507 os << _(GUIFamilyNames[family()]) << ", ";
508 if (series() != INHERIT_SERIES)
509 os << _(GUISeriesNames[series()]) << ", ";
510 if (shape() != INHERIT_SHAPE)
511 os << _(GUIShapeNames[shape()]) << ", ";
512 if (size() != INHERIT_SIZE)
513 os << _(GUISizeNames[size()]) << ", ";
514 if (color() != Color_inherit)
515 os << lcolor.getGUIName(color()) << ", ";
516 if (emph() != INHERIT)
517 os << bformat(_("Emphasis %1$s, "),
518 _(GUIMiscNames[emph()]));
519 if (underbar() != INHERIT)
520 os << bformat(_("Underline %1$s, "),
521 _(GUIMiscNames[underbar()]));
522 if (noun() != INHERIT)
523 os << bformat(_("Noun %1$s, "),
524 _(GUIMiscNames[noun()]));
526 os << _("Default") << ", ";
527 if (!params || (language() != params->language))
528 os << bformat(_("Language: %1$s, "),
529 _(language()->display()));
531 os << bformat(_(" Number %1$s"),
532 _(GUIMiscNames[number()]));
533 return rtrim(os.str(), ", ");
537 // Set family according to lyx format string
538 Font & Font::setLyXFamily(string const & fam)
540 string const s = ascii_lowercase(fam);
543 while (LyXFamilyNames[i] != s &&
544 LyXFamilyNames[i] != string("error"))
546 if (s == LyXFamilyNames[i])
547 setFamily(Font::FONT_FAMILY(i));
549 lyxerr << "Font::setLyXFamily: Unknown family `"
550 << s << '\'' << endl;
555 // Set series according to lyx format string
556 Font & Font::setLyXSeries(string const & ser)
558 string const s = ascii_lowercase(ser);
561 while (LyXSeriesNames[i] != s &&
562 LyXSeriesNames[i] != string("error")) ++i;
563 if (s == LyXSeriesNames[i]) {
564 setSeries(Font::FONT_SERIES(i));
566 lyxerr << "Font::setLyXSeries: Unknown series `"
567 << s << '\'' << endl;
572 // Set shape according to lyx format string
573 Font & Font::setLyXShape(string const & sha)
575 string const s = ascii_lowercase(sha);
578 while (LyXShapeNames[i] != s && LyXShapeNames[i] != string("error"))
580 if (s == LyXShapeNames[i])
581 setShape(Font::FONT_SHAPE(i));
583 lyxerr << "Font::setLyXShape: Unknown shape `"
584 << s << '\'' << endl;
589 // Set size according to lyx format string
590 Font & Font::setLyXSize(string const & siz)
592 string const s = ascii_lowercase(siz);
594 while (LyXSizeNames[i] != s && LyXSizeNames[i] != string("error"))
596 if (s == LyXSizeNames[i]) {
597 setSize(Font::FONT_SIZE(i));
599 lyxerr << "Font::setLyXSize: Unknown size `"
600 << s << '\'' << endl;
605 // Set size according to lyx format string
606 Font::FONT_MISC_STATE Font::setLyXMisc(string const & siz)
608 string const s = ascii_lowercase(siz);
610 while (LyXMiscNames[i] != s &&
611 LyXMiscNames[i] != string("error")) ++i;
612 if (s == LyXMiscNames[i])
613 return FONT_MISC_STATE(i);
614 lyxerr << "Font::setLyXMisc: Unknown misc flag `"
615 << s << '\'' << endl;
620 /// Sets color after LyX text format
621 Font & Font::setLyXColor(string const & col)
623 setColor(lcolor.getFromLyXName(col));
628 // Returns size in latex format
629 string const Font::latexSize() const
631 return LaTeXSizeNames[size()];
635 // Read a font definition from given file in lyx format
637 Font & Font::lyxRead(Lexer & lex)
640 bool finished = false;
641 while (!finished && lex.isOK() && !error) {
643 string const tok = ascii_lowercase(lex.getString());
647 } else if (tok == "endfont") {
649 } else if (tok == "family") {
651 string const ttok = lex.getString();
653 } else if (tok == "series") {
655 string const ttok = lex.getString();
657 } else if (tok == "shape") {
659 string const ttok = lex.getString();
661 } else if (tok == "size") {
663 string const ttok = lex.getString();
665 } else if (tok == "misc") {
667 string const ttok = ascii_lowercase(lex.getString());
669 if (ttok == "no_bar") {
671 } else if (ttok == "no_emph") {
673 } else if (ttok == "no_noun") {
675 } else if (ttok == "emph") {
677 } else if (ttok == "underbar") {
679 } else if (ttok == "noun") {
682 lex.printError("Illegal misc type `$$Token'");
684 } else if (tok == "color") {
686 string const ttok = lex.getString();
689 lex.printError("Unknown tag `$$Token'");
697 /// Writes the changes from this font to orgfont in .lyx format in file
698 void Font::lyxWriteChanges(Font const & orgfont,
702 if (orgfont.family() != family())
703 os << "\\family " << LyXFamilyNames[family()] << "\n";
704 if (orgfont.series() != series())
705 os << "\\series " << LyXSeriesNames[series()] << "\n";
706 if (orgfont.shape() != shape())
707 os << "\\shape " << LyXShapeNames[shape()] << "\n";
708 if (orgfont.size() != size())
709 os << "\\size " << LyXSizeNames[size()] << "\n";
710 if (orgfont.emph() != emph())
711 os << "\\emph " << LyXMiscNames[emph()] << "\n";
712 if (orgfont.number() != number())
713 os << "\\numeric " << LyXMiscNames[number()] << "\n";
714 if (orgfont.underbar() != underbar()) {
715 // This is only for backwards compatibility
716 switch (underbar()) {
717 case OFF: os << "\\bar no\n"; break;
718 case ON: os << "\\bar under\n"; break;
719 case TOGGLE: lyxerr << "Font::lyxWriteFontChanges: "
720 "TOGGLE should not appear here!"
723 case INHERIT: os << "\\bar default\n"; break;
724 case IGNORE: lyxerr << "Font::lyxWriteFontChanges: "
725 "IGNORE should not appear here!"
730 if (orgfont.noun() != noun()) {
731 os << "\\noun " << LyXMiscNames[noun()] << "\n";
733 if (orgfont.color() != color())
734 os << "\\color " << lcolor.getLyXName(color()) << '\n';
735 if (orgfont.language() != language() &&
736 language() != latex_language) {
738 os << "\\lang " << language()->lang() << "\n";
740 os << "\\lang unknown\n";
745 /// Writes the head of the LaTeX needed to impose this font
746 // Returns number of chars written.
747 int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
748 OutputParams const & runparams,
750 Font const & prev) const
755 if (language()->babel() != base.language()->babel() &&
756 language() != prev.language()) {
757 if (language()->lang() == "farsi") {
760 } else if (!isRightToLeft() &&
761 base.language()->lang() == "farsi") {
764 } else if (language()->lang() == "arabic_arabi") {
767 } else if (!isRightToLeft() &&
768 base.language()->lang() == "arabic_arabi") {
771 // currently the remaining RTL languages are arabic_arabtex and hebrew
772 } else if (isRightToLeft() != prev.isRightToLeft()) {
773 if (isRightToLeft()) {
780 } else if (!language()->babel().empty()) {
782 subst(lyxrc.language_command_local,
783 "$$lang", language()->babel());
784 os << from_ascii(tmp);
785 count += tmp.length();
792 if (language()->encoding()->package() == Encoding::CJK) {
793 pair<bool, int> const c = switchEncoding(os, bparams,
794 runparams.moving_arg, *(runparams.encoding),
795 *(language()->encoding()));
797 open_encoding_ = true;
799 runparams.encoding = language()->encoding();
803 // When the current language is Hebrew, Arabic, or Farsi
804 // the numbers are written Left-to-Right. ArabTeX package
805 // reorders the number automatically but the packages used
806 // for Hebrew and Farsi (Arabi) do not.
807 if (number() == ON && prev.number() != ON
808 && (language()->lang() == "hebrew"
809 || language()->lang() == "farsi"
810 || language()->lang() == "arabic_arabi")) {
818 if (f.family() != INHERIT_FAMILY) {
820 << LaTeXFamilyNames[f.family()]
822 count += strlen(LaTeXFamilyNames[f.family()]) + 2;
823 env = true; //We have opened a new environment
825 if (f.series() != INHERIT_SERIES) {
827 << LaTeXSeriesNames[f.series()]
829 count += strlen(LaTeXSeriesNames[f.series()]) + 2;
830 env = true; //We have opened a new environment
832 if (f.shape() != INHERIT_SHAPE) {
834 << LaTeXShapeNames[f.shape()]
836 count += strlen(LaTeXShapeNames[f.shape()]) + 2;
837 env = true; //We have opened a new environment
839 if (f.color() != Color_inherit && f.color() != Color_ignore) {
841 << from_ascii(lcolor.getLaTeXName(f.color()))
843 count += lcolor.getLaTeXName(f.color()).length() + 13;
844 env = true; //We have opened a new environment
846 if (f.emph() == ON) {
849 env = true; //We have opened a new environment
851 if (f.underbar() == ON) {
854 env = true; //We have opened a new environment
856 // \noun{} is a LyX special macro
857 if (f.noun() == ON) {
860 env = true; //We have opened a new environment
862 if (f.size() != INHERIT_SIZE) {
863 // If we didn't open an environment above, we open one here
869 << LaTeXSizeNames[f.size()]
871 count += strlen(LaTeXSizeNames[f.size()]) + 2;
877 /// Writes ending block of LaTeX needed to close use of this font
878 // Returns number of chars written
879 // This one corresponds to latexWriteStartChanges(). (Asger)
880 int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
881 OutputParams const & runparams,
884 bool const & closeLanguage) const
889 // reduce the current font to changes against the base
890 // font (of the layout). We use a temporary for this to
891 // avoid changing this font instance, as that would break
895 if (f.family() != INHERIT_FAMILY) {
898 env = true; // Size change need not bother about closing env.
900 if (f.series() != INHERIT_SERIES) {
903 env = true; // Size change need not bother about closing env.
905 if (f.shape() != INHERIT_SHAPE) {
908 env = true; // Size change need not bother about closing env.
910 if (f.color() != Color_inherit && f.color() != Color_ignore) {
913 env = true; // Size change need not bother about closing env.
915 if (f.emph() == ON) {
918 env = true; // Size change need not bother about closing env.
920 if (f.underbar() == ON) {
923 env = true; // Size change need not bother about closing env.
925 if (f.noun() == ON) {
928 env = true; // Size change need not bother about closing env.
930 if (f.size() != INHERIT_SIZE) {
931 // We only have to close if only size changed
938 // When the current language is Hebrew, Arabic, or Farsi
939 // the numbers are written Left-to-Right. ArabTeX package
940 // reorders the number automatically but the packages used
941 // for Hebrew and Farsi (Arabi) do not.
942 if (number() == ON && next.number() != ON
943 && (language()->lang() == "hebrew"
944 || language()->lang() == "farsi"
945 || language()->lang() == "arabic_arabi")) {
950 if (open_encoding_) {
951 // We need to close the encoding even if it does not change
952 // to do correct environment nesting
953 Encoding const * const ascii = encodings.getFromLyXName("ascii");
954 pair<bool, int> const c = switchEncoding(os, bparams,
955 runparams.moving_arg, *(runparams.encoding),
957 BOOST_ASSERT(c.first);
959 runparams.encoding = ascii;
960 open_encoding_ = false;
964 language() != base.language() && language() != next.language()) {
973 ColorCode Font::realColor() const
975 if (color() == Color_none)
976 return Color_foreground;
981 std::string Font::toString(bool const toggle) const
983 string lang = "ignore";
985 lang = language()->lang();
988 os << "family " << family() << '\n'
989 << "series " << series() << '\n'
990 << "shape " << shape() << '\n'
991 << "size " << size() << '\n'
992 << "emph " << emph() << '\n'
993 << "underbar " << underbar() << '\n'
994 << "noun " << noun() << '\n'
995 << "number " << number() << '\n'
996 << "color " << color() << '\n'
997 << "language " << lang << '\n'
998 << "toggleall " << convert<string>(toggle);
1003 bool Font::fromString(string const & data, bool & toggle)
1005 istringstream is(data);
1010 while (lex.isOK()) {
1013 token = lex.getString();
1015 if (token.empty() || !lex.next())
1018 if (token == "family") {
1019 int const next = lex.getInteger();
1020 setFamily(FONT_FAMILY(next));
1022 } else if (token == "series") {
1023 int const next = lex.getInteger();
1024 setSeries(FONT_SERIES(next));
1026 } else if (token == "shape") {
1027 int const next = lex.getInteger();
1028 setShape(FONT_SHAPE(next));
1030 } else if (token == "size") {
1031 int const next = lex.getInteger();
1032 setSize(FONT_SIZE(next));
1034 } else if (token == "emph" || token == "underbar" ||
1035 token == "noun" || token == "number") {
1037 int const next = lex.getInteger();
1038 FONT_MISC_STATE const misc = FONT_MISC_STATE(next);
1040 if (token == "emph")
1042 else if (token == "underbar")
1044 else if (token == "noun")
1046 else if (token == "number")
1049 } else if (token == "color") {
1050 int const next = lex.getInteger();
1051 setColor(ColorCode(next));
1053 } else if (token == "language") {
1054 string const next = lex.getString();
1055 if (next == "ignore")
1056 setLanguage(ignore_language);
1058 setLanguage(languages.getLanguage(next));
1060 } else if (token == "toggleall") {
1061 toggle = lex.getBool();
1064 // Unrecognised token
1074 void Font::validate(LaTeXFeatures & features) const
1076 BufferParams const & bparams = features.bufferParams();
1077 Language const * doc_language = bparams.language;
1079 if (noun() == Font::ON) {
1080 LYXERR(Debug::LATEX) << "font.noun: "
1083 features.require("noun");
1084 LYXERR(Debug::LATEX) << "Noun enabled. Font: "
1085 << to_utf8(stateText(0))
1092 // probably we should put here all interface colors used for
1093 // font displaying! For now I just add this ones I know of (Jug)
1098 features.require("color");
1099 LYXERR(Debug::LATEX) << "Color enabled. Font: "
1100 << to_utf8(stateText(0))
1104 if (lang->babel() != doc_language->babel() &&
1105 lang != ignore_language &&
1106 lang != latex_language)
1108 features.useLanguage(lang);
1109 LYXERR(Debug::LATEX) << "Found language "
1110 << lang->lang() << endl;
1115 ostream & operator<<(ostream & os, Font::FONT_MISC_STATE fms)
1117 return os << int(fms);
1121 std::ostream & operator<<(std::ostream & os, Font const & font)
1123 return os << "font:"
1124 << " family " << font.bits.family
1125 << " series " << font.bits.series
1126 << " shape " << font.bits.shape
1127 << " size " << font.bits.size
1128 << " color " << font.bits.color
1129 << " emph " << font.bits.emph
1130 << " underbar " << font.bits.underbar
1131 << " noun " << font.bits.noun
1132 << " number " << font.bits.number
1133 << " lang: " << (font.lang ? font.lang->lang() : 0);