]> git.lyx.org Git - lyx.git/blob - src/Font.cpp
listerrors.lyx : Update a link.
[lyx.git] / src / Font.cpp
1 /**
2  * \file src/Font.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  * \author André Pönitz
10  * \author Dekel Tsur
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #include <config.h>
16
17 #include "Font.h"
18
19 #include "BufferParams.h" // stateText
20 #include "ColorSet.h"
21 #include "Encoding.h"
22 #include "Language.h"
23 #include "LaTeXFeatures.h"
24 #include "Lexer.h"
25 #include "LyXRC.h"
26 #include "output_latex.h"
27 #include "OutputParams.h"
28
29 #include "support/lassert.h"
30 #include "support/convert.h"
31 #include "support/debug.h"
32 #include "support/gettext.h"
33 #include "support/lstrings.h"
34
35 #include <cstring>
36
37 using namespace std;
38 using namespace lyx::support;
39
40 namespace lyx {
41
42 //
43 // Strings used to read and write .lyx format files
44 //
45 // These are defined in FontInfo.cpp
46 extern char const * LyXFamilyNames[NUM_FAMILIES + 2];
47 extern char const * LyXSeriesNames[4];
48 extern char const * LyXShapeNames[6];
49 extern char const * LyXSizeNames[14];
50 extern char const * LyXMiscNames[5];
51
52 //
53 // Names for the GUI
54 //
55
56 namespace {
57
58 char const * GUIFamilyNames[NUM_FAMILIES + 2 /* default & error */] =
59 { N_("Roman"), N_("Sans Serif"), N_("Typewriter"), N_("Symbol"),
60   "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "rsfs", "wasy", "esint",
61   N_("Inherit"), N_("Ignore") };
62
63 char const * GUISeriesNames[4] =
64 { N_("Medium"), N_("Bold"), N_("Inherit"), N_("Ignore") };
65
66 char const * GUIShapeNames[6] =
67 { N_("Upright"), N_("Italic"), N_("Slanted"), N_("Smallcaps"), N_("Inherit"),
68   N_("Ignore") };
69
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") };
74
75 char const * GUIMiscNames[5] =
76 { N_("Off"), N_("On"), N_("Toggle"), N_("Inherit"), N_("Ignore") };
77
78 //
79 // Strings used to write LaTeX files
80 //
81 char const * LaTeXFamilyNames[6] =
82 { "textrm", "textsf", "texttt", "error1", "error2", "error3" };
83
84 char const * LaTeXSeriesNames[4] =
85 { "textmd", "textbf", "error4", "error5" };
86
87 char const * LaTeXShapeNames[6] =
88 { "textup", "textit", "textsl", "textsc", "error6", "error7" };
89
90 char const * LaTeXSizeNames[14] =
91 { "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
92   "Large", "LARGE", "huge", "Huge", "error8", "error9", "error10", "error11" };
93
94 } // namespace anon
95
96
97 Font::Font(FontInfo bits, Language const * l)
98         : bits_(bits), lang_(l), open_encoding_(false)
99 {
100         if (!lang_)
101                 lang_ = default_language;
102 }
103
104
105 bool Font::isRightToLeft() const
106 {
107         return lang_->rightToLeft();
108 }
109
110
111 bool Font::isVisibleRightToLeft() const
112 {
113         return (lang_->rightToLeft() &&
114                 bits_.number() != FONT_ON);
115 }
116
117
118 void Font::setLanguage(Language const * l)
119 {
120         lang_ = l;
121 }
122
123
124 /// Updates font settings according to request
125 void Font::update(Font const & newfont,
126                      Language const * document_language,
127                      bool toggleall)
128 {
129         bits_.update(newfont.fontInfo(), toggleall);
130
131         if (newfont.language() == language() && toggleall)
132                 if (language() == document_language)
133                         setLanguage(default_language);
134                 else
135                         setLanguage(document_language);
136         else if (newfont.language() == reset_language)
137                 setLanguage(document_language);
138         else if (newfont.language() != ignore_language)
139                 setLanguage(newfont.language());
140 }
141
142
143 docstring const stateText(FontInfo const & f)
144 {
145         odocstringstream os;
146         if (f.family() != INHERIT_FAMILY)
147                 os << _(GUIFamilyNames[f.family()]) << ", ";
148         if (f.series() != INHERIT_SERIES)
149                 os << _(GUISeriesNames[f.series()]) << ", ";
150         if (f.shape() != INHERIT_SHAPE)
151                 os << _(GUIShapeNames[f.shape()]) << ", ";
152         if (f.size() != FONT_SIZE_INHERIT)
153                 os << _(GUISizeNames[f.size()]) << ", ";
154         if (f.color() != Color_inherit)
155                 os << lcolor.getGUIName(f.color()) << ", ";
156         // FIXME: uncomment this when we support background.
157         //if (f.background() != Color_inherit)
158         //      os << lcolor.getGUIName(f.background()) << ", ";
159         if (f.emph() != FONT_INHERIT)
160                 os << bformat(_("Emphasis %1$s, "),
161                               _(GUIMiscNames[f.emph()]));
162         if (f.underbar() != FONT_INHERIT)
163                 os << bformat(_("Underline %1$s, "),
164                               _(GUIMiscNames[f.underbar()]));
165         if (f.strikeout() != FONT_INHERIT)
166                 os << bformat(_("Strikeout %1$s, "),
167                               _(GUIMiscNames[f.strikeout()]));
168         if (f.uuline() != FONT_INHERIT)
169                 os << bformat(_("Double underline %1$s, "),
170                               _(GUIMiscNames[f.uuline()]));
171         if (f.uwave() != FONT_INHERIT)
172                 os << bformat(_("Wavy underline %1$s, "),
173                               _(GUIMiscNames[f.uwave()]));
174         if (f.noun() != FONT_INHERIT)
175                 os << bformat(_("Noun %1$s, "),
176                               _(GUIMiscNames[f.noun()]));
177         if (f == inherit_font)
178                 os << _("Default") << ", ";
179
180         return os.str();
181 }
182
183
184 docstring const Font::stateText(BufferParams * params) const
185 {
186         odocstringstream os;
187         os << lyx::stateText(bits_);
188         if (!params || (language() != params->language))
189                 os << bformat(_("Language: %1$s, "),
190                               _(language()->display()));
191         if (bits_.number() != FONT_OFF)
192                 os << "  " << bformat(_("Number %1$s"),
193                               _(GUIMiscNames[bits_.number()]));
194         return rtrim(os.str(), ", ");
195 }
196
197
198 // Returns size in latex format
199 string const Font::latexSize() const
200 {
201         return LaTeXSizeNames[bits_.size()];
202 }
203
204
205 /// Writes the changes from this font to orgfont in .lyx format in file
206 void Font::lyxWriteChanges(Font const & orgfont,
207                               ostream & os) const
208 {
209         os << "\n";
210         if (orgfont.fontInfo().family() != bits_.family())
211                 os << "\\family " << LyXFamilyNames[bits_.family()] << "\n";
212         if (orgfont.fontInfo().series() != bits_.series())
213                 os << "\\series " << LyXSeriesNames[bits_.series()] << "\n";
214         if (orgfont.fontInfo().shape() != bits_.shape())
215                 os << "\\shape " << LyXShapeNames[bits_.shape()] << "\n";
216         if (orgfont.fontInfo().size() != bits_.size())
217                 os << "\\size " << LyXSizeNames[bits_.size()] << "\n";
218         if (orgfont.fontInfo().emph() != bits_.emph())
219                 os << "\\emph " << LyXMiscNames[bits_.emph()] << "\n";
220         if (orgfont.fontInfo().number() != bits_.number())
221                 os << "\\numeric " << LyXMiscNames[bits_.number()] << "\n";
222         if (orgfont.fontInfo().underbar() != bits_.underbar()) {
223                 // This is only for backwards compatibility
224                 switch (bits_.underbar()) {
225                 case FONT_OFF:  os << "\\bar no\n"; break;
226                 case FONT_ON:        os << "\\bar under\n"; break;
227                 case FONT_TOGGLE:       lyxerr << "Font::lyxWriteFontChanges: "
228                                         "FONT_TOGGLE should not appear here!"
229                                        << endl;
230                 break;
231                 case FONT_INHERIT:   os << "\\bar default\n"; break;
232                 case FONT_IGNORE:    lyxerr << "Font::lyxWriteFontChanges: "
233                                         "IGNORE should not appear here!"
234                                        << endl;
235                 break;
236                 }
237         }
238         if (orgfont.fontInfo().strikeout() != bits_.strikeout()) {
239                 os << "\\strikeout " << LyXMiscNames[bits_.strikeout()] << "\n";
240         }
241         if (orgfont.fontInfo().uuline() != bits_.uuline()) {
242                 os << "\\uuline " << LyXMiscNames[bits_.uuline()] << "\n";
243         }
244         if (orgfont.fontInfo().uwave() != bits_.uwave()) {
245                 os << "\\uwave " << LyXMiscNames[bits_.uwave()] << "\n";
246         }
247         if (orgfont.fontInfo().noun() != bits_.noun()) {
248                 os << "\\noun " << LyXMiscNames[bits_.noun()] << "\n";
249         }
250         if (orgfont.fontInfo().color() != bits_.color())
251                 os << "\\color " << lcolor.getLyXName(bits_.color()) << '\n';
252         // FIXME: uncomment this when we support background.
253         //if (orgfont.fontInfo().background() != bits_.background())
254         //      os << "\\color " << lcolor.getLyXName(bits_.background()) << '\n';
255         if (orgfont.language() != language() &&
256             language() != latex_language) {
257                 if (language())
258                         os << "\\lang " << language()->lang() << "\n";
259                 else
260                         os << "\\lang unknown\n";
261         }
262 }
263
264
265 /// Writes the head of the LaTeX needed to impose this font
266 // Returns number of chars written.
267 int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
268                                     OutputParams const & runparams,
269                                     Font const & base,
270                                     Font const & prev) const
271 {
272         bool env = false;
273
274         int count = 0;
275
276         // polyglossia or babel?
277         if (runparams.use_polyglossia
278             && language()->lang() != base.language()->lang()
279             && language() != prev.language()) {
280                 if (!language()->polyglossia().empty()) {
281                         string tmp = "\\text" + language()->polyglossia();
282                         if (!language()->polyglossiaOpts().empty())
283                                 tmp += "[" + language()->polyglossiaOpts() + "]";
284                         tmp += "{";
285                         os << from_ascii(tmp);
286                         count += tmp.length();
287                 }
288         } else if (language()->babel() != base.language()->babel() &&
289             language() != prev.language()) {
290                 if (language()->lang() == "farsi") {
291                         os << "\\textFR{";
292                         count += 8;
293                 } else if (!isRightToLeft() &&
294                             base.language()->lang() == "farsi") {
295                         os << "\\textLR{";
296                         count += 8;
297                 } else if (language()->lang() == "arabic_arabi") {
298                         os << "\\textAR{";
299                         count += 8;
300                 } else if (!isRightToLeft() &&
301                                 base.language()->lang() == "arabic_arabi") {
302                         os << "\\textLR{";
303                         count += 8;
304                 // currently the remaining RTL languages are arabic_arabtex and hebrew
305                 } else if (isRightToLeft() != prev.isRightToLeft()) {
306                         if (isRightToLeft()) {
307                                 os << "\\R{";
308                                 count += 3;
309                         } else {
310                                 os << "\\L{";
311                                 count += 3;
312                         }
313                 } else if (!language()->babel().empty()) {
314                         string const tmp =
315                                 subst(lyxrc.language_command_local,
316                                       "$$lang", language()->babel());
317                         os << from_ascii(tmp);
318                         count += tmp.length();
319                 } else {
320                         os << '{';
321                         count += 1;
322                 }
323         }
324
325         if (language()->encoding()->package() == Encoding::CJK) {
326                 pair<bool, int> const c = switchEncoding(os, bparams,
327                                 runparams, *(language()->encoding()));
328                 if (c.first) {
329                         open_encoding_ = true;
330                         count += c.second;
331                         runparams.encoding = language()->encoding();
332                 }
333         }
334
335         // When the current language is Hebrew, Arabic, or Farsi
336         // the numbers are written Left-to-Right. ArabTeX package
337         // reorders the number automatically but the packages used
338         // for Hebrew and Farsi (Arabi) do not.
339         if (bits_.number() == FONT_ON && prev.fontInfo().number() != FONT_ON
340                 && (language()->lang() == "hebrew"
341                         || language()->lang() == "farsi" 
342                         || language()->lang() == "arabic_arabi")) {
343                 os << "{\\beginL ";
344                 count += 9;
345         }
346
347         FontInfo f = bits_;
348         f.reduce(base.bits_);
349
350         if (f.family() != INHERIT_FAMILY) {
351                 os << '\\'
352                    << LaTeXFamilyNames[f.family()]
353                    << '{';
354                 count += strlen(LaTeXFamilyNames[f.family()]) + 2;
355                 env = true; //We have opened a new environment
356         }
357         if (f.series() != INHERIT_SERIES) {
358                 os << '\\'
359                    << LaTeXSeriesNames[f.series()]
360                    << '{';
361                 count += strlen(LaTeXSeriesNames[f.series()]) + 2;
362                 env = true; //We have opened a new environment
363         }
364         if (f.shape() != INHERIT_SHAPE) {
365                 os << '\\'
366                    << LaTeXShapeNames[f.shape()]
367                    << '{';
368                 count += strlen(LaTeXShapeNames[f.shape()]) + 2;
369                 env = true; //We have opened a new environment
370         }
371         if (f.color() != Color_inherit && f.color() != Color_ignore) {
372                 os << "\\textcolor{"
373                    << from_ascii(lcolor.getLaTeXName(f.color()))
374                    << "}{";
375                 count += lcolor.getLaTeXName(f.color()).length() + 13;
376                 env = true; //We have opened a new environment
377         }
378         // FIXME: uncomment this when we support background.
379         /*
380         if (f.background() != Color_inherit && f.background() != Color_ignore) {
381                 os << "\\textcolor{"
382                    << from_ascii(lcolor.getLaTeXName(f.background()))
383                    << "}{";
384                 count += lcolor.getLaTeXName(f.background()).length() + 13;
385                 env = true; //We have opened a new environment
386         }
387         */
388         if (f.emph() == FONT_ON) {
389                 os << "\\emph{";
390                 count += 6;
391                 env = true; //We have opened a new environment
392         }
393         if (f.underbar() == FONT_ON) {
394                 os << "\\uline{";
395                 count += 10;
396                 runparams.inulemcmd = true;
397                 env = true; //We have opened a new environment
398         }
399         if (f.strikeout() == FONT_ON) {
400                 os << "\\sout{";
401                 count += 9;
402                 runparams.inulemcmd = true;
403                 env = true; //We have opened a new environment
404         }
405         if (f.uuline() == FONT_ON) {
406                 os << "\\uuline{";
407                 count += 11;
408                 runparams.inulemcmd = true;
409                 env = true; //We have opened a new environment
410         }
411         if (f.uwave() == FONT_ON) {
412                 os << "\\uwave{";
413                 count += 10;
414                 runparams.inulemcmd = true;
415                 env = true; //We have opened a new environment
416         }
417         // \noun{} is a LyX special macro
418         if (f.noun() == FONT_ON) {
419                 os << "\\noun{";
420                 count += 6;
421                 env = true; //We have opened a new environment
422         }
423         if (f.size() != FONT_SIZE_INHERIT) {
424                 // If we didn't open an environment above, we open one here
425                 if (!env) {
426                         os << '{';
427                         ++count;
428                 }
429                 os << '\\'
430                    << LaTeXSizeNames[f.size()]
431                    << ' ';
432                 count += strlen(LaTeXSizeNames[f.size()]) + 2;
433         }
434         return count;
435 }
436
437
438 /// Writes ending block of LaTeX needed to close use of this font
439 // Returns number of chars written
440 // This one corresponds to latexWriteStartChanges(). (Asger)
441 int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
442                                   OutputParams const & runparams,
443                                   Font const & base,
444                                   Font const & next,
445                                   bool const & closeLanguage) const
446 {
447         int count = 0;
448         bool env = false;
449
450         // reduce the current font to changes against the base
451         // font (of the layout). We use a temporary for this to
452         // avoid changing this font instance, as that would break
453         FontInfo f = bits_;
454         f.reduce(base.bits_);
455
456         if (f.family() != INHERIT_FAMILY) {
457                 os << '}';
458                 ++count;
459                 env = true; // Size change need not bother about closing env.
460         }
461         if (f.series() != INHERIT_SERIES) {
462                 os << '}';
463                 ++count;
464                 env = true; // Size change need not bother about closing env.
465         }
466         if (f.shape() != INHERIT_SHAPE) {
467                 os << '}';
468                 ++count;
469                 env = true; // Size change need not bother about closing env.
470         }
471         if (f.color() != Color_inherit && f.color() != Color_ignore) {
472                 os << '}';
473                 ++count;
474                 env = true; // Size change need not bother about closing env.
475         }
476         if (f.emph() == FONT_ON) {
477                 os << '}';
478                 ++count;
479                 env = true; // Size change need not bother about closing env.
480         }
481         if (f.underbar() == FONT_ON) {
482                 os << '}';
483                 ++count;
484                 runparams.inulemcmd = false;
485                 env = true; // Size change need not bother about closing env.
486         }
487         if (f.strikeout() == FONT_ON) {
488                 os << '}';
489                 ++count;
490                 runparams.inulemcmd = false;
491                 env = true; // Size change need not bother about closing env.
492         }
493         if (f.uuline() == FONT_ON) {
494                 os << '}';
495                 ++count;
496                 runparams.inulemcmd = false;
497                 env = true; // Size change need not bother about closing env.
498         }
499         if (f.uwave() == FONT_ON) {
500                 os << '}';
501                 ++count;
502                 runparams.inulemcmd = false;
503                 env = true; // Size change need not bother about closing env.
504         }
505         if (f.noun() == FONT_ON) {
506                 os << '}';
507                 ++count;
508                 env = true; // Size change need not bother about closing env.
509         }
510         if (f.size() != FONT_SIZE_INHERIT) {
511                 // We only have to close if only size changed
512                 if (!env) {
513                         os << '}';
514                         ++count;
515                 }
516         }
517
518         // When the current language is Hebrew, Arabic, or Farsi
519         // the numbers are written Left-to-Right. ArabTeX package
520         // reorders the number automatically but the packages used
521         // for Hebrew and Farsi (Arabi) do not.
522         if (bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON
523                 && (language()->lang() == "hebrew"
524                         || language()->lang() == "farsi"
525                         || language()->lang() == "arabic_arabi")) {
526                 os << "\\endL}";
527                 count += 6;
528         }
529
530         if (open_encoding_) {
531                 // We need to close the encoding even if it does not change
532                 // to do correct environment nesting
533                 Encoding const * const ascii = encodings.fromLyXName("ascii");
534                 pair<bool, int> const c = switchEncoding(os.os(), bparams,
535                                 runparams, *ascii);
536                 LASSERT(c.first, /**/);
537                 count += c.second;
538                 runparams.encoding = ascii;
539                 open_encoding_ = false;
540         }
541
542         if (closeLanguage &&
543                         language() != base.language() && language() != next.language()) {
544                 os << '}';
545                 ++count;
546         }
547
548         return count;
549 }
550
551
552 string Font::toString(bool const toggle) const
553 {
554         string const lang = (language() == reset_language)
555                 ? "reset" : language()->lang();
556
557         ostringstream os;
558         os << "family " << bits_.family() << '\n'
559            << "series " << bits_.series() << '\n'
560            << "shape " << bits_.shape() << '\n'
561            << "size " << bits_.size() << '\n'
562            << "emph " << bits_.emph() << '\n'
563            << "underbar " << bits_.underbar() << '\n'
564            << "strikeout " << bits_.strikeout() << '\n'
565            << "uuline " << bits_.uuline() << '\n'
566            << "uwave " << bits_.uwave() << '\n'
567            << "noun " << bits_.noun() << '\n'
568            << "number " << bits_.number() << '\n'
569            << "color " << bits_.color() << '\n'
570            << "language " << lang << '\n'
571            << "toggleall " << convert<string>(toggle);
572         return os.str();
573 }
574
575
576 bool Font::fromString(string const & data, bool & toggle)
577 {
578         istringstream is(data);
579         Lexer lex;
580         lex.setStream(is);
581
582         int nset = 0;
583         while (lex.isOK()) {
584                 string token;
585                 if (lex.next())
586                         token = lex.getString();
587
588                 if (token.empty() || !lex.next())
589                         break;
590
591                 if (token == "family") {
592                         int const next = lex.getInteger();
593                         bits_.setFamily(FontFamily(next));
594
595                 } else if (token == "series") {
596                         int const next = lex.getInteger();
597                         bits_.setSeries(FontSeries(next));
598
599                 } else if (token == "shape") {
600                         int const next = lex.getInteger();
601                         bits_.setShape(FontShape(next));
602
603                 } else if (token == "size") {
604                         int const next = lex.getInteger();
605                         bits_.setSize(FontSize(next));
606
607                 } else if (token == "emph" || token == "underbar" ||
608                            token == "noun" || token == "number" ||
609                            token == "uuline" || token == "uwave" ||
610                            token == "strikeout") {
611
612                         int const next = lex.getInteger();
613                         FontState const misc = FontState(next);
614
615                         if (token == "emph")
616                                 bits_.setEmph(misc);
617                         else if (token == "underbar")
618                                 bits_.setUnderbar(misc);
619                         else if (token == "strikeout")
620                                 bits_.setStrikeout(misc);
621                         else if (token == "uuline")
622                                 bits_.setUuline(misc);
623                         else if (token == "uwave")
624                                 bits_.setUwave(misc);
625                         else if (token == "noun")
626                                 bits_.setNoun(misc);
627                         else if (token == "number")
628                                 bits_.setNumber(misc);
629
630                 } else if (token == "color") {
631                         int const next = lex.getInteger();
632                         bits_.setColor(ColorCode(next));
633
634                 /**
635                 } else if (token == "background") {
636                         int const next = lex.getInteger();
637                         bits_.setBackground(ColorCode(next));
638                 */
639
640                 } else if (token == "language") {
641                         string const next = lex.getString();
642                         setLanguage(languages.getLanguage(next));
643
644                 } else if (token == "toggleall") {
645                         toggle = lex.getBool();
646
647                 } else {
648                         // Unrecognised token
649                         break;
650                 }
651
652                 ++nset;
653         }
654         return (nset > 0);
655 }
656
657
658 void Font::validate(LaTeXFeatures & features) const
659 {
660         BufferParams const & bparams = features.bufferParams();
661         Language const * doc_language = bparams.language;
662
663         if (bits_.noun() == FONT_ON) {
664                 LYXERR(Debug::LATEX, "font.noun: " << bits_.noun());
665                 features.require("noun");
666                 LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0)));
667         }
668         if (bits_.underbar() == FONT_ON) {
669                 LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
670                 features.require("ulem");
671                 LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0)));
672         }
673         if (bits_.strikeout() == FONT_ON) {
674                 LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
675                 features.require("ulem");
676                 LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0)));
677         }
678         if (bits_.uuline() == FONT_ON) {
679                 LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
680                 features.require("ulem");
681                 LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0)));
682         }
683         if (bits_.uwave() == FONT_ON) {
684                 LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
685                 features.require("ulem");
686                 LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0)));
687         }
688         switch (bits_.color()) {
689                 case Color_none:
690                 case Color_inherit:
691                 case Color_ignore:
692                         // probably we should put here all interface colors used for
693                         // font displaying! For now I just add this ones I know of (Jug)
694                 case Color_latex:
695                 case Color_notelabel:
696                         break;
697                 default:
698                         features.require("color");
699                         LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText(0)));
700         }
701
702         // FIXME: Do something for background and soul package?
703
704         if (lang_->babel() != doc_language->babel() &&
705                 lang_ != ignore_language &&
706                 lang_ != latex_language)
707         {
708                 features.useLanguage(lang_);
709                 LYXERR(Debug::LATEX, "Found language " << lang_->lang());
710         }
711 }
712
713
714 ostream & operator<<(ostream & os, FontState fms)
715 {
716         return os << int(fms);
717 }
718
719
720 ostream & operator<<(ostream & os, FontInfo const & f)
721 {
722         return os << "font:"
723                 << " family " << f.family()
724                 << " series " << f.series()
725                 << " shape " << f.shape()
726                 << " size " << f.size()
727                 << " color " << f.color()
728                 // FIXME: uncomment this when we support background.
729                 //<< " background " << f.background()
730                 << " emph " << f.emph()
731                 << " underbar " << f.underbar()
732                 << " strikeout " << f.strikeout()
733                 << " uuline " << f.uuline()
734                 << " uwave " << f.uwave()
735                 << " noun " << f.noun()
736                 << " number " << f.number();
737 }
738
739
740 ostream & operator<<(ostream & os, Font const & font)
741 {
742         return os << font.bits_
743                 << " lang: " << (font.lang_ ? font.lang_->lang() : 0);
744 }
745
746
747 } // namespace lyx