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
27 #include "output_latex.h"
28 #include "OutputParams.h"
30 #include "support/convert.h"
31 #include "support/lstrings.h"
36 using std::ostringstream;
37 using std::istringstream;
40 #ifndef CXX_GLOBAL_CSTD
47 using support::ascii_lowercase;
48 using support::bformat;
58 char const * GUIFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
59 { N_("Roman"), N_("Sans Serif"), N_("Typewriter"), N_("Symbol"),
60 "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
61 N_("Inherit"), N_("Ignore") };
63 char const * GUISeriesNames[4] =
64 { N_("Medium"), N_("Bold"), N_("Inherit"), N_("Ignore") };
66 char const * GUIShapeNames[6] =
67 { N_("Upright"), N_("Italic"), N_("Slanted"), N_("Smallcaps"), N_("Inherit"),
70 char const * GUISizeNames[14] =
71 { N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"), N_("Large"),
72 N_("Larger"), N_("Largest"), N_("Huge"), N_("Huger"), N_("Increase"), N_("Decrease"),
73 N_("Inherit"), N_("Ignore") };
75 char const * GUIMiscNames[5] =
76 { N_("Off"), N_("On"), N_("Toggle"), N_("Inherit"), N_("Ignore") };
80 // Strings used to read and write .lyx format files
82 char const * LyXFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
83 { "roman", "sans", "typewriter", "symbol",
84 "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
87 char const * LyXSeriesNames[4] =
88 { "medium", "bold", "default", "error" };
90 char const * LyXShapeNames[6] =
91 { "up", "italic", "slanted", "smallcaps", "default", "error" };
93 char const * LyXSizeNames[14] =
94 { "tiny", "scriptsize", "footnotesize", "small", "normal", "large",
95 "larger", "largest", "huge", "giant",
96 "increase", "decrease", "default", "error" };
98 char const * LyXMiscNames[5] =
99 { "off", "on", "toggle", "default", "error" };
102 // Strings used to write LaTeX files
104 char const * LaTeXFamilyNames[6] =
105 { "textrm", "textsf", "texttt", "error1", "error2", "error3" };
107 char const * LaTeXSeriesNames[4] =
108 { "textmd", "textbf", "error4", "error5" };
110 char const * LaTeXShapeNames[6] =
111 { "textup", "textit", "textsl", "textsc", "error6", "error7" };
113 char const * LaTeXSizeNames[14] =
114 { "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
115 "Large", "LARGE", "huge", "Huge", "error8", "error9", "error10", "error11" };
120 // Initialize static member
121 Font::FontBits Font::sane = {
132 // Initialize static member
133 Font::FontBits Font::inherit = {
144 // Initialize static member
145 Font::FontBits Font::ignore = {
157 bool operator==(Font::FontBits const & lhs,
158 Font::FontBits const & rhs)
160 return lhs.family == rhs.family &&
161 lhs.series == rhs.series &&
162 lhs.shape == rhs.shape &&
163 lhs.size == rhs.size &&
164 lhs.color == rhs.color &&
165 lhs.emph == rhs.emph &&
166 lhs.underbar == rhs.underbar &&
167 lhs.noun == rhs.noun &&
168 lhs.number == rhs.number;
173 : bits(sane), lang(default_language), open_encoding_(false)
177 Font::Font(Font::FONT_INIT1)
178 : bits(inherit), lang(default_language), open_encoding_(false)
182 Font::Font(Font::FONT_INIT2)
183 : bits(ignore), lang(ignore_language), open_encoding_(false)
187 Font::Font(Font::FONT_INIT3)
188 : bits(sane), lang(default_language), open_encoding_(false)
192 Font::Font(Font::FONT_INIT1, Language const * l)
193 : bits(inherit), lang(l), open_encoding_(false)
197 Font::Font(Font::FONT_INIT2, Language const * l)
198 : bits(ignore), lang(l), open_encoding_(false)
202 Font::Font(Font::FONT_INIT3, Language const * l)
203 : bits(sane), lang(l), open_encoding_(false)
208 Color_color Font::color() const
210 return Color::color(bits.color);
214 bool Font::isRightToLeft() const
216 return lang->rightToLeft();
220 bool Font::isVisibleRightToLeft() const
222 return (lang->rightToLeft() &&
227 void Font::setFamily(Font::FONT_FAMILY f)
233 void Font::setSeries(Font::FONT_SERIES s)
239 void Font::setShape(Font::FONT_SHAPE s)
245 void Font::setSize(Font::FONT_SIZE s)
251 void Font::setEmph(Font::FONT_MISC_STATE e)
257 void Font::setUnderbar(Font::FONT_MISC_STATE u)
263 void Font::setNoun(Font::FONT_MISC_STATE n)
269 void Font::setColor(Color_color c)
275 void Font::setLanguage(Language const * l)
281 void Font::setNumber(Font::FONT_MISC_STATE n)
287 /// Decreases font size by one
288 Font & Font::decSize()
291 case SIZE_HUGER: setSize(SIZE_HUGE); break;
292 case SIZE_HUGE: setSize(SIZE_LARGEST); break;
293 case SIZE_LARGEST: setSize(SIZE_LARGER); break;
294 case SIZE_LARGER: setSize(SIZE_LARGE); break;
295 case SIZE_LARGE: setSize(SIZE_NORMAL); break;
296 case SIZE_NORMAL: setSize(SIZE_SMALL); break;
297 case SIZE_SMALL: setSize(SIZE_FOOTNOTE); break;
298 case SIZE_FOOTNOTE: setSize(SIZE_SCRIPT); break;
299 case SIZE_SCRIPT: setSize(SIZE_TINY); break;
300 case SIZE_TINY: break;
302 lyxerr << "Can't Font::decSize on INCREASE_SIZE" << endl;
305 lyxerr <<"Can't Font::decSize on DECREASE_SIZE" << endl;
308 lyxerr <<"Can't Font::decSize on INHERIT_SIZE" << endl;
311 lyxerr <<"Can't Font::decSize on IGNORE_SIZE" << endl;
318 /// Increases font size by one
319 Font & Font::incSize()
322 case SIZE_HUGER: break;
323 case SIZE_HUGE: setSize(SIZE_HUGER); break;
324 case SIZE_LARGEST: setSize(SIZE_HUGE); break;
325 case SIZE_LARGER: setSize(SIZE_LARGEST); break;
326 case SIZE_LARGE: setSize(SIZE_LARGER); break;
327 case SIZE_NORMAL: setSize(SIZE_LARGE); break;
328 case SIZE_SMALL: setSize(SIZE_NORMAL); break;
329 case SIZE_FOOTNOTE: setSize(SIZE_SMALL); break;
330 case SIZE_SCRIPT: setSize(SIZE_FOOTNOTE); break;
331 case SIZE_TINY: setSize(SIZE_SCRIPT); break;
333 lyxerr <<"Can't Font::incSize on INCREASE_SIZE" << endl;
336 lyxerr <<"Can't Font::incSize on DECREASE_SIZE" << endl;
339 lyxerr <<"Can't Font::incSize on INHERIT_SIZE" << endl;
342 lyxerr <<"Can't Font::incSize on IGNORE_SIZE" << endl;
349 /// Updates a misc setting according to request
350 Font::FONT_MISC_STATE Font::setMisc(FONT_MISC_STATE newfont,
353 if (newfont == TOGGLE) {
359 lyxerr <<"Font::setMisc: Need state"
360 " ON or OFF to toggle. Setting to ON" << endl;
363 } else if (newfont == IGNORE)
370 /// Updates font settings according to request
371 void Font::update(Font const & newfont,
372 Language const * document_language,
375 if (newfont.family() == family() && toggleall)
376 setFamily(INHERIT_FAMILY); // toggle 'back'
377 else if (newfont.family() != IGNORE_FAMILY)
378 setFamily(newfont.family());
379 // else it's IGNORE_SHAPE
381 // "Old" behaviour: "Setting" bold will toggle bold on/off.
382 switch (newfont.series()) {
385 if (series() == BOLD_SERIES && toggleall)
386 setSeries(MEDIUM_SERIES);
388 setSeries(BOLD_SERIES);
392 setSeries(newfont.series());
398 if (newfont.shape() == shape() && toggleall)
399 setShape(INHERIT_SHAPE); // toggle 'back'
400 else if (newfont.shape() != IGNORE_SHAPE)
401 setShape(newfont.shape());
402 // else it's IGNORE_SHAPE
404 if (newfont.size() != IGNORE_SIZE) {
405 if (newfont.size() == INCREASE_SIZE)
407 else if (newfont.size() == DECREASE_SIZE)
410 setSize(newfont.size());
413 setEmph(setMisc(newfont.emph(), emph()));
414 setUnderbar(setMisc(newfont.underbar(), underbar()));
415 setNoun(setMisc(newfont.noun(), noun()));
417 setNumber(setMisc(newfont.number(), number()));
418 if (newfont.language() == language() && toggleall)
419 if (language() == document_language)
420 setLanguage(default_language);
422 setLanguage(document_language);
423 else if (newfont.language() != ignore_language)
424 setLanguage(newfont.language());
426 if (newfont.color() == color() && toggleall)
427 setColor(Color::inherit); // toggle 'back'
428 else if (newfont.color() != Color::ignore)
429 setColor(newfont.color());
433 /// Reduce font to fall back to template where possible
434 void Font::reduce(Font const & tmplt)
436 if (family() == tmplt.family())
437 setFamily(INHERIT_FAMILY);
438 if (series() == tmplt.series())
439 setSeries(INHERIT_SERIES);
440 if (shape() == tmplt.shape())
441 setShape(INHERIT_SHAPE);
442 if (size() == tmplt.size())
443 setSize(INHERIT_SIZE);
444 if (emph() == tmplt.emph())
446 if (underbar() == tmplt.underbar())
447 setUnderbar(INHERIT);
448 if (noun() == tmplt.noun())
450 if (color() == tmplt.color())
451 setColor(Color::inherit);
455 /// Realize font from a template
456 Font & Font::realize(Font const & tmplt)
458 if (bits == inherit) {
463 if (bits.family == INHERIT_FAMILY)
464 bits.family = tmplt.bits.family;
466 if (bits.series == INHERIT_SERIES)
467 bits.series = tmplt.bits.series;
469 if (bits.shape == INHERIT_SHAPE)
470 bits.shape = tmplt.bits.shape;
472 if (bits.size == INHERIT_SIZE)
473 bits.size = tmplt.bits.size;
475 if (bits.emph == INHERIT)
476 bits.emph = tmplt.bits.emph;
478 if (bits.underbar == INHERIT)
479 bits.underbar = tmplt.bits.underbar;
481 if (bits.noun == INHERIT)
482 bits.noun = tmplt.bits.noun;
484 if (bits.color == Color::inherit)
485 bits.color = tmplt.bits.color;
491 /// Is font resolved?
492 bool Font::resolved() const
494 return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
495 shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
496 emph() != INHERIT && underbar() != INHERIT &&
498 color() != Color::inherit);
502 docstring const Font::stateText(BufferParams * params) const
505 if (family() != INHERIT_FAMILY)
506 os << _(GUIFamilyNames[family()]) << ", ";
507 if (series() != INHERIT_SERIES)
508 os << _(GUISeriesNames[series()]) << ", ";
509 if (shape() != INHERIT_SHAPE)
510 os << _(GUIShapeNames[shape()]) << ", ";
511 if (size() != INHERIT_SIZE)
512 os << _(GUISizeNames[size()]) << ", ";
513 if (color() != Color::inherit)
514 os << lcolor.getGUIName(color()) << ", ";
515 if (emph() != INHERIT)
516 os << bformat(_("Emphasis %1$s, "),
517 _(GUIMiscNames[emph()]));
518 if (underbar() != INHERIT)
519 os << bformat(_("Underline %1$s, "),
520 _(GUIMiscNames[underbar()]));
521 if (noun() != INHERIT)
522 os << bformat(_("Noun %1$s, "),
523 _(GUIMiscNames[noun()]));
525 os << _("Default") << ", ";
526 if (!params || (language() != params->language))
527 os << bformat(_("Language: %1$s, "),
528 _(language()->display()));
530 os << bformat(_(" Number %1$s"),
531 _(GUIMiscNames[number()]));
532 return rtrim(os.str(), ", ");
536 // Set family according to lyx format string
537 Font & Font::setLyXFamily(string const & fam)
539 string const s = ascii_lowercase(fam);
542 while (LyXFamilyNames[i] != s &&
543 LyXFamilyNames[i] != string("error"))
545 if (s == LyXFamilyNames[i])
546 setFamily(Font::FONT_FAMILY(i));
548 lyxerr << "Font::setLyXFamily: Unknown family `"
549 << s << '\'' << endl;
554 // Set series according to lyx format string
555 Font & Font::setLyXSeries(string const & ser)
557 string const s = ascii_lowercase(ser);
560 while (LyXSeriesNames[i] != s &&
561 LyXSeriesNames[i] != string("error")) ++i;
562 if (s == LyXSeriesNames[i]) {
563 setSeries(Font::FONT_SERIES(i));
565 lyxerr << "Font::setLyXSeries: Unknown series `"
566 << s << '\'' << endl;
571 // Set shape according to lyx format string
572 Font & Font::setLyXShape(string const & sha)
574 string const s = ascii_lowercase(sha);
577 while (LyXShapeNames[i] != s && LyXShapeNames[i] != string("error"))
579 if (s == LyXShapeNames[i])
580 setShape(Font::FONT_SHAPE(i));
582 lyxerr << "Font::setLyXShape: Unknown shape `"
583 << s << '\'' << endl;
588 // Set size according to lyx format string
589 Font & Font::setLyXSize(string const & siz)
591 string const s = ascii_lowercase(siz);
593 while (LyXSizeNames[i] != s && LyXSizeNames[i] != string("error"))
595 if (s == LyXSizeNames[i]) {
596 setSize(Font::FONT_SIZE(i));
598 lyxerr << "Font::setLyXSize: Unknown size `"
599 << s << '\'' << endl;
604 // Set size according to lyx format string
605 Font::FONT_MISC_STATE Font::setLyXMisc(string const & siz)
607 string const s = ascii_lowercase(siz);
609 while (LyXMiscNames[i] != s &&
610 LyXMiscNames[i] != string("error")) ++i;
611 if (s == LyXMiscNames[i])
612 return FONT_MISC_STATE(i);
613 lyxerr << "Font::setLyXMisc: Unknown misc flag `"
614 << s << '\'' << endl;
619 /// Sets color after LyX text format
620 Font & Font::setLyXColor(string const & col)
622 setColor(lcolor.getFromLyXName(col));
627 // Returns size in latex format
628 string const Font::latexSize() const
630 return LaTeXSizeNames[size()];
634 // Read a font definition from given file in lyx format
636 Font & Font::lyxRead(Lexer & lex)
639 bool finished = false;
640 while (!finished && lex.isOK() && !error) {
642 string const tok = ascii_lowercase(lex.getString());
646 } else if (tok == "endfont") {
648 } else if (tok == "family") {
650 string const ttok = lex.getString();
652 } else if (tok == "series") {
654 string const ttok = lex.getString();
656 } else if (tok == "shape") {
658 string const ttok = lex.getString();
660 } else if (tok == "size") {
662 string const ttok = lex.getString();
664 } else if (tok == "misc") {
666 string const ttok = ascii_lowercase(lex.getString());
668 if (ttok == "no_bar") {
670 } else if (ttok == "no_emph") {
672 } else if (ttok == "no_noun") {
674 } else if (ttok == "emph") {
676 } else if (ttok == "underbar") {
678 } else if (ttok == "noun") {
681 lex.printError("Illegal misc type `$$Token'");
683 } else if (tok == "color") {
685 string const ttok = lex.getString();
688 lex.printError("Unknown tag `$$Token'");
696 /// Writes the changes from this font to orgfont in .lyx format in file
697 void Font::lyxWriteChanges(Font const & orgfont,
701 if (orgfont.family() != family())
702 os << "\\family " << LyXFamilyNames[family()] << "\n";
703 if (orgfont.series() != series())
704 os << "\\series " << LyXSeriesNames[series()] << "\n";
705 if (orgfont.shape() != shape())
706 os << "\\shape " << LyXShapeNames[shape()] << "\n";
707 if (orgfont.size() != size())
708 os << "\\size " << LyXSizeNames[size()] << "\n";
709 if (orgfont.emph() != emph())
710 os << "\\emph " << LyXMiscNames[emph()] << "\n";
711 if (orgfont.number() != number())
712 os << "\\numeric " << LyXMiscNames[number()] << "\n";
713 if (orgfont.underbar() != underbar()) {
714 // This is only for backwards compatibility
715 switch (underbar()) {
716 case OFF: os << "\\bar no\n"; break;
717 case ON: os << "\\bar under\n"; break;
718 case TOGGLE: lyxerr << "Font::lyxWriteFontChanges: "
719 "TOGGLE should not appear here!"
722 case INHERIT: os << "\\bar default\n"; break;
723 case IGNORE: lyxerr << "Font::lyxWriteFontChanges: "
724 "IGNORE should not appear here!"
729 if (orgfont.noun() != noun()) {
730 os << "\\noun " << LyXMiscNames[noun()] << "\n";
732 if (orgfont.color() != color())
733 os << "\\color " << lcolor.getLyXName(color()) << '\n';
734 if (orgfont.language() != language() &&
735 language() != latex_language) {
737 os << "\\lang " << language()->lang() << "\n";
739 os << "\\lang unknown\n";
744 /// Writes the head of the LaTeX needed to impose this font
745 // Returns number of chars written.
746 int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
747 OutputParams const & runparams,
749 Font const & prev) const
754 if (language()->babel() != base.language()->babel() &&
755 language() != prev.language()) {
756 if (language()->lang() == "farsi") {
759 } else if (!isRightToLeft() &&
760 base.language()->lang() == "farsi") {
763 } else if (language()->lang() == "arabic_arabi") {
766 } else if (!isRightToLeft() &&
767 base.language()->lang() == "arabic_arabi") {
770 // currently the remaining RTL languages are arabic_arabtex and hebrew
771 } else if (isRightToLeft() != prev.isRightToLeft()) {
772 if (isRightToLeft()) {
779 } else if (!language()->babel().empty()) {
781 subst(lyxrc.language_command_local,
782 "$$lang", language()->babel());
783 os << from_ascii(tmp);
784 count += tmp.length();
791 if (language()->encoding()->package() == Encoding::CJK) {
792 pair<bool, int> const c = switchEncoding(os, bparams,
793 runparams.moving_arg, *(runparams.encoding),
794 *(language()->encoding()));
796 open_encoding_ = true;
798 runparams.encoding = language()->encoding();
802 // When the current language is Hebrew, Arabic, or Farsi
803 // the numbers are written Left-to-Right. ArabTeX package
804 // reorders the number automatically but the packages used
805 // for Hebrew and Farsi (Arabi) do not.
806 if (number() == ON && prev.number() != ON
807 && (language()->lang() == "hebrew"
808 || language()->lang() == "farsi"
809 || language()->lang() == "arabic_arabi")) {
817 if (f.family() != INHERIT_FAMILY) {
819 << LaTeXFamilyNames[f.family()]
821 count += strlen(LaTeXFamilyNames[f.family()]) + 2;
822 env = true; //We have opened a new environment
824 if (f.series() != INHERIT_SERIES) {
826 << LaTeXSeriesNames[f.series()]
828 count += strlen(LaTeXSeriesNames[f.series()]) + 2;
829 env = true; //We have opened a new environment
831 if (f.shape() != INHERIT_SHAPE) {
833 << LaTeXShapeNames[f.shape()]
835 count += strlen(LaTeXShapeNames[f.shape()]) + 2;
836 env = true; //We have opened a new environment
838 if (f.color() != Color::inherit && f.color() != Color::ignore) {
840 << from_ascii(lcolor.getLaTeXName(f.color()))
842 count += lcolor.getLaTeXName(f.color()).length() + 13;
843 env = true; //We have opened a new environment
845 if (f.emph() == ON) {
848 env = true; //We have opened a new environment
850 if (f.underbar() == ON) {
853 env = true; //We have opened a new environment
855 // \noun{} is a LyX special macro
856 if (f.noun() == ON) {
859 env = true; //We have opened a new environment
861 if (f.size() != INHERIT_SIZE) {
862 // If we didn't open an environment above, we open one here
868 << LaTeXSizeNames[f.size()]
870 count += strlen(LaTeXSizeNames[f.size()]) + 2;
876 /// Writes ending block of LaTeX needed to close use of this font
877 // Returns number of chars written
878 // This one corresponds to latexWriteStartChanges(). (Asger)
879 int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
880 OutputParams const & runparams,
883 bool const & closeLanguage) const
888 // reduce the current font to changes against the base
889 // font (of the layout). We use a temporary for this to
890 // avoid changing this font instance, as that would break
894 if (f.family() != INHERIT_FAMILY) {
897 env = true; // Size change need not bother about closing env.
899 if (f.series() != INHERIT_SERIES) {
902 env = true; // Size change need not bother about closing env.
904 if (f.shape() != INHERIT_SHAPE) {
907 env = true; // Size change need not bother about closing env.
909 if (f.color() != Color::inherit && f.color() != Color::ignore) {
912 env = true; // Size change need not bother about closing env.
914 if (f.emph() == ON) {
917 env = true; // Size change need not bother about closing env.
919 if (f.underbar() == ON) {
922 env = true; // Size change need not bother about closing env.
924 if (f.noun() == ON) {
927 env = true; // Size change need not bother about closing env.
929 if (f.size() != INHERIT_SIZE) {
930 // We only have to close if only size changed
937 // When the current language is Hebrew, Arabic, or Farsi
938 // the numbers are written Left-to-Right. ArabTeX package
939 // reorders the number automatically but the packages used
940 // for Hebrew and Farsi (Arabi) do not.
941 if (number() == ON && next.number() != ON
942 && (language()->lang() == "hebrew"
943 || language()->lang() == "farsi"
944 || language()->lang() == "arabic_arabi")) {
949 if (open_encoding_) {
950 // We need to close the encoding even if it does not change
951 // to do correct environment nesting
952 Encoding const * const ascii = encodings.getFromLyXName("ascii");
953 pair<bool, int> const c = switchEncoding(os, bparams,
954 runparams.moving_arg, *(runparams.encoding),
956 BOOST_ASSERT(c.first);
958 runparams.encoding = ascii;
959 open_encoding_ = false;
963 language() != base.language() && language() != next.language()) {
972 Color_color Font::realColor() const
974 if (color() == Color::none)
975 return Color::foreground;
980 std::string Font::toString(bool const toggle) const
982 string lang = "ignore";
984 lang = language()->lang();
987 os << "family " << family() << '\n'
988 << "series " << series() << '\n'
989 << "shape " << shape() << '\n'
990 << "size " << size() << '\n'
991 << "emph " << emph() << '\n'
992 << "underbar " << underbar() << '\n'
993 << "noun " << noun() << '\n'
994 << "number " << number() << '\n'
995 << "color " << color() << '\n'
996 << "language " << lang << '\n'
997 << "toggleall " << convert<string>(toggle);
1002 bool Font::fromString(string const & data, bool & toggle)
1004 istringstream is(data);
1009 while (lex.isOK()) {
1012 token = lex.getString();
1014 if (token.empty() || !lex.next())
1017 if (token == "family") {
1018 int const next = lex.getInteger();
1019 setFamily(FONT_FAMILY(next));
1021 } else if (token == "series") {
1022 int const next = lex.getInteger();
1023 setSeries(FONT_SERIES(next));
1025 } else if (token == "shape") {
1026 int const next = lex.getInteger();
1027 setShape(FONT_SHAPE(next));
1029 } else if (token == "size") {
1030 int const next = lex.getInteger();
1031 setSize(FONT_SIZE(next));
1033 } else if (token == "emph" || token == "underbar" ||
1034 token == "noun" || token == "number") {
1036 int const next = lex.getInteger();
1037 FONT_MISC_STATE const misc = FONT_MISC_STATE(next);
1039 if (token == "emph")
1041 else if (token == "underbar")
1043 else if (token == "noun")
1045 else if (token == "number")
1048 } else if (token == "color") {
1049 int const next = lex.getInteger();
1050 setColor(Color::color(next));
1052 } else if (token == "language") {
1053 string const next = lex.getString();
1054 if (next == "ignore")
1055 setLanguage(ignore_language);
1057 setLanguage(languages.getLanguage(next));
1059 } else if (token == "toggleall") {
1060 toggle = lex.getBool();
1063 // Unrecognised token
1073 ostream & operator<<(ostream & os, Font::FONT_MISC_STATE fms)
1075 return os << int(fms);
1079 std::ostream & operator<<(std::ostream & os, Font const & font)
1081 return os << "font:"
1082 << " family " << font.bits.family
1083 << " series " << font.bits.series
1084 << " shape " << font.bits.shape
1085 << " size " << font.bits.size
1086 << " color " << font.bits.color
1087 << " emph " << font.bits.emph
1088 << " underbar " << font.bits.underbar
1089 << " noun " << font.bits.noun
1090 << " number " << font.bits.number
1091 << " lang: " << (font.lang ? font.lang->lang() : 0);