]> git.lyx.org Git - lyx.git/blob - src/FontInfo.cpp
Revert some recent test changes
[lyx.git] / src / FontInfo.cpp
1 /**
2  * \file src/FontInfo.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 "ColorSet.h"
18 #include "FontInfo.h"
19 #include "Lexer.h"
20
21 #include "support/debug.h"
22 #include "support/docstring.h"
23 #include "support/lstrings.h"
24
25 #include <ostream>
26 #include <sstream>
27
28 using namespace std;
29 using namespace lyx::support;
30
31 namespace lyx {
32
33 //
34 // Strings used to read and write .lyx format files
35 //
36 char const * LyXFamilyNames[NUM_FAMILIES + 2 /* default & error */] =
37 { "roman", "sans", "typewriter", "symbol",
38   "cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "rsfs", "stmry",
39   "wasy", "esint", "default", "error" };
40
41 char const * LyXSeriesNames[NUM_SERIES + 2 /* default & error */] =
42 { "medium", "bold", "default", "error" };
43
44 char const * LyXShapeNames[NUM_SHAPE + 2 /* default & error */] =
45 { "up", "italic", "slanted", "smallcaps", "default", "error" };
46
47 char const * LyXSizeNames[NUM_SIZE + 4 /* increase, decrease, default & error */] =
48 { "tiny", "scriptsize", "footnotesize", "small", "normal", "large",
49   "larger", "largest", "huge", "giant",
50   "increase", "decrease", "default", "error" };
51
52 char const * LyXMiscNames[5] =
53 { "off", "on", "toggle", "default", "error" };
54
55
56 FontInfo const sane_font(
57         ROMAN_FAMILY,
58         MEDIUM_SERIES,
59         UP_SHAPE,
60         FONT_SIZE_NORMAL,
61         Color_none,
62         Color_background,
63         FONT_OFF,
64         FONT_OFF,
65         FONT_OFF,
66         FONT_OFF,
67         FONT_OFF,
68         FONT_OFF,
69         FONT_OFF);
70
71 FontInfo const inherit_font(
72         INHERIT_FAMILY,
73         INHERIT_SERIES,
74         INHERIT_SHAPE,
75         FONT_SIZE_INHERIT,
76         Color_inherit,
77         Color_inherit,
78         FONT_INHERIT,
79         FONT_INHERIT,
80         FONT_INHERIT,
81         FONT_INHERIT,
82         FONT_INHERIT,
83         FONT_INHERIT,
84         FONT_OFF);
85
86 FontInfo const ignore_font(
87         IGNORE_FAMILY,
88         IGNORE_SERIES,
89         IGNORE_SHAPE,
90         FONT_SIZE_IGNORE,
91         Color_ignore,
92         Color_ignore,
93         FONT_IGNORE,
94         FONT_IGNORE,
95         FONT_IGNORE,
96         FONT_IGNORE,
97         FONT_IGNORE,
98         FONT_IGNORE,
99         FONT_IGNORE);
100
101
102 FontInfo::FontInfo()
103 {
104         *this = sane_font;
105 }
106
107
108 /// Decreases font size_ by one
109 FontInfo & FontInfo::decSize()
110 {
111         switch (size_) {
112         case FONT_SIZE_HUGER:        size_ = FONT_SIZE_HUGE;     break;
113         case FONT_SIZE_HUGE:         size_ = FONT_SIZE_LARGEST;  break;
114         case FONT_SIZE_LARGEST:      size_ = FONT_SIZE_LARGER;   break;
115         case FONT_SIZE_LARGER:       size_ = FONT_SIZE_LARGE;    break;
116         case FONT_SIZE_LARGE:        size_ = FONT_SIZE_NORMAL;   break;
117         case FONT_SIZE_NORMAL:       size_ = FONT_SIZE_SMALL;    break;
118         case FONT_SIZE_SMALL:        size_ = FONT_SIZE_FOOTNOTE; break;
119         case FONT_SIZE_FOOTNOTE:     size_ = FONT_SIZE_SCRIPT;   break;
120         case FONT_SIZE_SCRIPT:       size_ = FONT_SIZE_TINY;     break;
121         case FONT_SIZE_TINY:         break;
122         case FONT_SIZE_INCREASE:
123                 LYXERR0("Can't FontInfo::decSize on FONT_SIZE_INCREASE");
124                 break;
125         case FONT_SIZE_DECREASE:
126                 LYXERR0("Can't FontInfo::decSize on FONT_SIZE_DECREASE");
127                 break;
128         case FONT_SIZE_INHERIT:
129                 LYXERR0("Can't FontInfo::decSize on FONT_SIZE_INHERIT");
130                 break;
131         case FONT_SIZE_IGNORE:
132                 LYXERR0("Can't FontInfo::decSize on FONT_SIZE_IGNORE");
133                 break;
134         }
135         return *this;
136 }
137
138
139 /// Increases font size_ by one
140 FontInfo & FontInfo::incSize()
141 {
142         switch (size_) {
143         case FONT_SIZE_HUGER:   break;
144         case FONT_SIZE_HUGE:         size_ = FONT_SIZE_HUGER;    break;
145         case FONT_SIZE_LARGEST:      size_ = FONT_SIZE_HUGE;     break;
146         case FONT_SIZE_LARGER:       size_ = FONT_SIZE_LARGEST;  break;
147         case FONT_SIZE_LARGE:        size_ = FONT_SIZE_LARGER;   break;
148         case FONT_SIZE_NORMAL:       size_ = FONT_SIZE_LARGE;    break;
149         case FONT_SIZE_SMALL:        size_ = FONT_SIZE_NORMAL;   break;
150         case FONT_SIZE_FOOTNOTE:     size_ = FONT_SIZE_SMALL;    break;
151         case FONT_SIZE_SCRIPT:       size_ = FONT_SIZE_FOOTNOTE; break;
152         case FONT_SIZE_TINY:         size_ = FONT_SIZE_SCRIPT;   break;
153         case FONT_SIZE_INCREASE:
154                 LYXERR0("Can't FontInfo::incSize on FONT_SIZE_INCREASE");
155                 break;
156         case FONT_SIZE_DECREASE:
157                 LYXERR0("Can't FontInfo::incSize on FONT_SIZE_DECREASE");
158                 break;
159         case FONT_SIZE_INHERIT:
160                 LYXERR0("Can't FontInfo::incSize on FONT_SIZE_INHERIT");
161                 break;
162         case FONT_SIZE_IGNORE:
163                 LYXERR0("Can't FontInfo::incSize on FONT_SIZE_IGNORE");
164                 break;
165         }
166         return *this;
167 }
168
169
170 /// Reduce font to fall back to template where possible
171 void FontInfo::reduce(FontInfo const & tmplt)
172 {
173         if (family_ == tmplt.family_)
174                 family_ = INHERIT_FAMILY;
175         if (series_ == tmplt.series_)
176                 series_ = INHERIT_SERIES;
177         if (shape_ == tmplt.shape_)
178                 shape_ = INHERIT_SHAPE;
179         if (size_ == tmplt.size_)
180                 size_ = FONT_SIZE_INHERIT;
181         if (emph_ == tmplt.emph_)
182                 emph_ = FONT_INHERIT;
183         if (underbar_ == tmplt.underbar_)
184                 underbar_ = FONT_INHERIT;
185         if (strikeout_ == tmplt.strikeout_)
186                 strikeout_ = FONT_INHERIT;
187         if (uuline_ == tmplt.uuline_)
188                 uuline_ = FONT_INHERIT;
189         if (uwave_ == tmplt.uwave_)
190                 uwave_ = FONT_INHERIT;
191         if (noun_ == tmplt.noun_)
192                 noun_ = FONT_INHERIT;
193         if (color_ == tmplt.color_)
194                 color_ = Color_inherit;
195         if (background_ == tmplt.background_)
196                 background_ = Color_inherit;
197 }
198
199
200 /// Realize font from a template
201 FontInfo & FontInfo::realize(FontInfo const & tmplt)
202 {
203         if ((*this) == inherit_font) {
204                 operator=(tmplt);
205                 return *this;
206         }
207
208         if (family_ == INHERIT_FAMILY)
209                 family_ = tmplt.family_;
210
211         if (series_ == INHERIT_SERIES)
212                 series_ = tmplt.series_;
213
214         if (shape_ == INHERIT_SHAPE)
215                 shape_ = tmplt.shape_;
216
217         if (size_ == FONT_SIZE_INHERIT)
218                 size_ = tmplt.size_;
219
220         if (emph_ == FONT_INHERIT)
221                 emph_ = tmplt.emph_;
222
223         if (underbar_ == FONT_INHERIT)
224                 underbar_ = tmplt.underbar_;
225
226         if (strikeout_ == FONT_INHERIT)
227                 strikeout_ = tmplt.strikeout_;
228
229         if (uuline_ == FONT_INHERIT)
230                 uuline_ = tmplt.uuline_;
231
232         if (uwave_ == FONT_INHERIT)
233                 uwave_ = tmplt.uwave_;
234
235         if (noun_ == FONT_INHERIT)
236                 noun_ = tmplt.noun_;
237
238         if (color_ == Color_inherit)
239                 color_ = tmplt.color_;
240
241         if (background_ == Color_inherit)
242                 background_ = tmplt.background_;
243
244         return *this;
245 }
246
247
248 /// Updates a misc setting according to request
249 static FontState setMisc(FontState newfont,
250         FontState org)
251 {
252         if (newfont == FONT_TOGGLE) {
253                 if (org == FONT_ON)
254                         return FONT_OFF;
255                 else if (org == FONT_OFF)
256                         return FONT_ON;
257                 else {
258                         LYXERR0("Font::setMisc: Need state"
259                                 " FONT_ON or FONT_OFF to toggle. Setting to FONT_ON");
260                         return FONT_ON;
261                 }
262         } else if (newfont == FONT_IGNORE)
263                 return org;
264         else
265                 return newfont;
266 }
267
268 /// Updates font settings according to request
269 void FontInfo::update(FontInfo const & newfont, bool toggleall)
270 {
271         if (newfont.family_ == family_ && toggleall)
272                 setFamily(INHERIT_FAMILY); // toggle 'back'
273         else if (newfont.family_ != IGNORE_FAMILY)
274                 setFamily(newfont.family_);
275         // else it's IGNORE_SHAPE
276
277         // "Old" behaviour: "Setting" bold will toggle bold on/off.
278         switch (newfont.series_) {
279         case BOLD_SERIES:
280                 // We toggle...
281                 if (series_ == BOLD_SERIES && toggleall)
282                         setSeries(MEDIUM_SERIES);
283                 else
284                         setSeries(BOLD_SERIES);
285                 break;
286         case MEDIUM_SERIES:
287         case INHERIT_SERIES:
288                 setSeries(newfont.series_);
289                 break;
290         case IGNORE_SERIES:
291                 break;
292         }
293
294         if (newfont.shape_ == shape_ && toggleall)
295                 shape_ = INHERIT_SHAPE; // toggle 'back'
296         else if (newfont.shape_ != IGNORE_SHAPE)
297                 shape_ = newfont.shape_;
298         // else it's IGNORE_SHAPE
299
300         if (newfont.size_ != FONT_SIZE_IGNORE) {
301                 if (newfont.size_ == FONT_SIZE_INCREASE)
302                         incSize();
303                 else if (newfont.size_ == FONT_SIZE_DECREASE)
304                         decSize();
305                 else
306                         size_ = newfont.size_;
307         }
308
309         setEmph(setMisc(newfont.emph_, emph_));
310         setUnderbar(setMisc(newfont.underbar_, underbar_));
311         setStrikeout(setMisc(newfont.strikeout_, strikeout_));
312         setUuline(setMisc(newfont.uuline_, uuline_));
313         setUwave(setMisc(newfont.uwave_, uwave_));
314         setNoun(setMisc(newfont.noun_, noun_));
315         setNumber(setMisc(newfont.number_, number_));
316
317         if (newfont.color_ == color_ && toggleall)
318                 setColor(Color_inherit); // toggle 'back'
319         else if (newfont.color_ != Color_ignore)
320                 setColor(newfont.color_);
321
322         if (newfont.background_ == background_ && toggleall)
323                 setBackground(Color_inherit); // toggle 'back'
324         else if (newfont.background_ != Color_ignore)
325                 setBackground(newfont.background_);
326 }
327
328 /// Is font resolved?
329 bool FontInfo::resolved() const
330 {
331         return (family_ != INHERIT_FAMILY && series_ != INHERIT_SERIES
332                 && shape_ != INHERIT_SHAPE && size_ != FONT_SIZE_INHERIT
333                 && emph_ != FONT_INHERIT && underbar_ != FONT_INHERIT
334                 && uuline_ != FONT_INHERIT && uwave_ != FONT_INHERIT
335                 && strikeout_ != FONT_INHERIT && noun_ != FONT_INHERIT
336                 && color_ != Color_inherit
337                 && background_ != Color_inherit);
338 }
339
340
341 Color FontInfo::realColor() const
342 {
343         if (paint_color_ != Color_none)
344                 return paint_color_;
345         if (color_ == Color_none)
346                 return Color_foreground;
347         return color_;
348 }
349
350
351 namespace {
352
353 void appendSep(string & s1, string const & s2)
354 {
355         if (s2.empty())
356                 return;
357         s1 += s1.empty() ? "" : "\n";
358         s1 += s2;
359 }
360
361
362 string makeCSSTag(string const & key, string const & val)
363 {
364         return key + ": " + val + ";";
365 }
366
367
368 string getFamilyCSS(FontFamily const & f)
369 {
370         switch (f) {
371         case ROMAN_FAMILY:
372                 return "serif";
373         case SANS_FAMILY:
374                 return "sans-serif";
375         case TYPEWRITER_FAMILY:
376                 return "monospace";
377         case SYMBOL_FAMILY:
378         case CMR_FAMILY:
379         case CMSY_FAMILY:
380         case CMM_FAMILY:
381         case CMEX_FAMILY:
382         case MSA_FAMILY:
383         case MSB_FAMILY:
384         case EUFRAK_FAMILY:
385         case RSFS_FAMILY:
386         case STMARY_FAMILY:
387         case WASY_FAMILY:
388         case ESINT_FAMILY:
389         case INHERIT_FAMILY:
390         case IGNORE_FAMILY:
391                 break;
392         }
393         return "";
394 }
395
396
397 string getSeriesCSS(FontSeries const & s)
398 {
399         switch (s) {
400         case MEDIUM_SERIES:
401                 return "normal";
402         case BOLD_SERIES:
403                 return "bold";
404         case INHERIT_SERIES:
405         case IGNORE_SERIES:
406                 break;
407         }
408         return "";
409 }
410
411
412 string getShapeCSS(FontShape const & s)
413 {
414         string fs = "normal";
415         string fv = "normal";
416         switch (s) {
417         case UP_SHAPE: break;
418         case ITALIC_SHAPE: fs = "italic"; break;
419         case SLANTED_SHAPE: fs = "oblique"; break;
420         case SMALLCAPS_SHAPE: fv = "small-caps"; break;
421         case IGNORE_SHAPE:
422         case INHERIT_SHAPE:
423                 fs = ""; fv = ""; break;
424         }
425         string retval;
426         if (!fs.empty())
427                 appendSep(retval, makeCSSTag("font-style", fs));
428         if (!fv.empty())
429                 appendSep(retval, makeCSSTag("font-variant", fv));
430         return retval;
431 }
432
433
434 string getSizeCSS(FontSize const & s)
435 {
436         switch (s) {
437         case FONT_SIZE_TINY:
438                 return "xx-small";
439         case FONT_SIZE_SCRIPT:
440                 return "x-small";
441         case FONT_SIZE_FOOTNOTE:
442         case FONT_SIZE_SMALL:
443                 return "small";
444         case FONT_SIZE_NORMAL:
445                 return "medium";
446         case FONT_SIZE_LARGE:
447                 return "large";
448         case FONT_SIZE_LARGER:
449         case FONT_SIZE_LARGEST:
450                 return "x-large";
451         case FONT_SIZE_HUGE:
452         case FONT_SIZE_HUGER:
453                 return "xx-large";
454         case FONT_SIZE_INCREASE:
455                 return "larger";
456         case FONT_SIZE_DECREASE:
457                 return "smaller";
458         case FONT_SIZE_IGNORE:
459         case FONT_SIZE_INHERIT:
460                 break;
461         }
462         return "";
463 }
464         
465 } // namespace anonymous
466
467
468 // FIXME This does not yet handle color
469 docstring FontInfo::asCSS() const 
470 {
471         string retval;
472         string tmp = getFamilyCSS(family_);
473         if (!tmp.empty())
474                 appendSep(retval, makeCSSTag("font-family", tmp));
475         tmp = getSeriesCSS(series_);
476         if (!tmp.empty())
477                 appendSep(retval, makeCSSTag("font-weight", tmp));
478         appendSep(retval, getShapeCSS(shape_));
479         tmp = getSizeCSS(size_);
480         if (!tmp.empty())
481                 appendSep(retval, makeCSSTag("font-size", tmp));
482         return from_ascii(retval);      
483 }
484
485
486 // Set family according to lyx format string
487 void setLyXFamily(string const & fam, FontInfo & f)
488 {
489         string const s = ascii_lowercase(fam);
490
491         int i = 0;
492         while (LyXFamilyNames[i] != s &&
493                LyXFamilyNames[i] != string("error"))
494                 ++i;
495         if (s == LyXFamilyNames[i])
496                 f.setFamily(FontFamily(i));
497         else
498                 LYXERR0("Unknown family `" << s << '\'');
499 }
500
501
502 // Set series according to lyx format string
503 void setLyXSeries(string const & ser, FontInfo & f)
504 {
505         string const s = ascii_lowercase(ser);
506
507         int i = 0;
508         while (LyXSeriesNames[i] != s &&
509                LyXSeriesNames[i] != string("error")) ++i;
510         if (s == LyXSeriesNames[i]) {
511                 f.setSeries(FontSeries(i));
512         } else
513                 LYXERR0("Unknown series `" << s << '\'');
514 }
515
516
517 // Set shape according to lyx format string
518 void setLyXShape(string const & sha, FontInfo & f)
519 {
520         string const s = ascii_lowercase(sha);
521
522         int i = 0;
523         while (LyXShapeNames[i] != s && LyXShapeNames[i] != string("error"))
524                         ++i;
525         if (s == LyXShapeNames[i])
526                 f.setShape(FontShape(i));
527         else
528                 LYXERR0("Unknown shape `" << s << '\'');
529 }
530
531
532 // Set size according to lyx format string
533 void setLyXSize(string const & siz, FontInfo & f)
534 {
535         string const s = ascii_lowercase(siz);
536         int i = 0;
537         while (LyXSizeNames[i] != s && LyXSizeNames[i] != string("error"))
538                 ++i;
539         if (s == LyXSizeNames[i]) {
540                 f.setSize(FontSize(i));
541         } else
542                 LYXERR0("Unknown size `" << s << '\'');
543 }
544
545
546 // Set size according to lyx format string
547 FontState setLyXMisc(string const & siz)
548 {
549         string const s = ascii_lowercase(siz);
550         int i = 0;
551         while (LyXMiscNames[i] != s &&
552                LyXMiscNames[i] != string("error")) ++i;
553         if (s == LyXMiscNames[i])
554                 return FontState(i);
555         LYXERR0("Unknown misc flag `" << s << '\'');
556         return FONT_OFF;
557 }
558
559
560 /// Sets color after LyX text format
561 void setLyXColor(string const & col, FontInfo & f)
562 {
563         f.setColor(lcolor.getFromLyXName(col));
564 }
565
566
567 // Read a font definition from given file in lyx format
568 // Used for layouts
569 FontInfo lyxRead(Lexer & lex, FontInfo const & fi)
570 {
571         FontInfo f = fi;
572         bool error = false;
573         bool finished = false;
574         while (!finished && lex.isOK() && !error) {
575                 lex.next();
576                 string const tok = ascii_lowercase(lex.getString());
577
578                 if (tok.empty()) {
579                         continue;
580                 } else if (tok == "endfont") {
581                         finished = true;
582                 } else if (tok == "family") {
583                         lex.next();
584                         string const ttok = lex.getString();
585                         setLyXFamily(ttok, f);
586                 } else if (tok == "series") {
587                         lex.next();
588                         string const ttok = lex.getString();
589                         setLyXSeries(ttok, f);
590                 } else if (tok == "shape") {
591                         lex.next();
592                         string const ttok = lex.getString();
593                         setLyXShape(ttok, f);
594                 } else if (tok == "size") {
595                         lex.next();
596                         string const ttok = lex.getString();
597                         setLyXSize(ttok, f);
598                 } else if (tok == "misc") {
599                         lex.next();
600                         string const ttok = ascii_lowercase(lex.getString());
601
602                         if (ttok == "no_bar") {
603                                 f.setUnderbar(FONT_OFF);
604                         } else if (ttok == "no_strikeout") {
605                                 f.setStrikeout(FONT_OFF);
606                         } else if (ttok == "no_uuline") {
607                                 f.setUuline(FONT_OFF);
608                         } else if (ttok == "no_uwave") {
609                                 f.setUwave(FONT_OFF);
610                         } else if (ttok == "no_emph") {
611                                 f.setEmph(FONT_OFF);
612                         } else if (ttok == "no_noun") {
613                                 f.setNoun(FONT_OFF);
614                         } else if (ttok == "emph") {
615                                 f.setEmph(FONT_ON);
616                         } else if (ttok == "underbar") {
617                                 f.setUnderbar(FONT_ON);
618                         } else if (ttok == "strikeout") {
619                                 f.setStrikeout(FONT_ON);
620                         } else if (ttok == "uuline") {
621                                 f.setUuline(FONT_ON);
622                         } else if (ttok == "uwave") {
623                                 f.setUwave(FONT_ON);
624                         } else if (ttok == "noun") {
625                                 f.setNoun(FONT_ON);
626                         } else {
627                                 lex.printError("Illegal misc type");
628                         }
629                 } else if (tok == "color") {
630                         lex.next();
631                         string const ttok = lex.getString();
632                         setLyXColor(ttok, f);
633                 } else {
634                         lex.printError("Unknown tag");
635                         error = true;
636                 }
637         }
638         return f;
639 }
640
641
642 void lyxWrite(ostream & os, FontInfo const & f, string const & start, int level)
643 {
644         string indent;
645         for (int i = 0; i < level; ++i)
646                 indent += '\t';
647         ostringstream oss;
648         if (f.family() != INHERIT_FAMILY)
649                 oss << indent << "\tFamily " << LyXFamilyNames[f.family()]
650                     << '\n';
651         if (f.series() != INHERIT_SERIES)
652                 oss << indent << "\tSeries " << LyXSeriesNames[f.series()]
653                     << '\n';
654         if (f.shape() != INHERIT_SHAPE)
655                 oss << indent << "\tShape " << LyXShapeNames[f.shape()]
656                     << '\n';
657         if (f.size() != FONT_SIZE_INHERIT)
658                 oss << indent << "\tSize " << LyXSizeNames[f.size()]
659                     << '\n';
660         if (f.underbar() == FONT_ON)
661                 oss << indent << "\tMisc Underbar\n";
662         else if (f.underbar() == FONT_OFF)
663                 oss << indent << "\tMisc No_Bar\n";
664         if (f.strikeout() == FONT_ON)
665                 oss << indent << "\tMisc Strikeout\n";
666         else if (f.strikeout() == FONT_OFF)
667                 oss << indent << "\tMisc No_Strikeout\n";
668         if (f.uuline() == FONT_ON)
669                 oss << indent << "\tMisc Uuline\n";
670         else if (f.uuline() == FONT_OFF)
671                 oss << indent << "\tMisc No_Uuline\n";
672         if (f.uwave() == FONT_ON)
673                 oss << indent << "\tMisc Uwave\n";
674         else if (f.uwave() == FONT_OFF)
675                 oss << indent << "\tMisc No_Uwave\n";
676         if (f.emph() == FONT_ON)
677                 oss << indent << "\tMisc Emph\n";
678         else if (f.emph() == FONT_OFF)
679                 oss << indent << "\tMisc No_Emph\n";
680         if (f.noun() == FONT_ON)
681                 oss << indent << "\tMisc Noun\n";
682         else if (f.noun() == FONT_OFF)
683                 oss << indent << "\tMisc No_Noun\n";
684         if (f.color() != Color_inherit && f.color() != Color_none)
685                 oss << indent << "\tColor " << lcolor.getLyXName(f.color())
686                     << '\n';
687         if (!oss.str().empty()) {
688                 os << indent << start << '\n'
689                    << oss.str()
690                    << indent << "EndFont\n";
691         }
692 }
693
694
695 } // namespace lyx