82344040ce10dd3f8ce899b0ddc6bd42e85390de
[quassel.git] / src / uisupport / qssparser.cpp
1 /***************************************************************************
2 *   Copyright (C) 2005-09 by the Quassel Project                          *
3 *   devel@quassel-irc.org                                                 *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) version 3.                                           *
9 *                                                                         *
10 *   This program is distributed in the hope that it will be useful,       *
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13 *   GNU General Public License for more details.                          *
14 *                                                                         *
15 *   You should have received a copy of the GNU General Public License     *
16 *   along with this program; if not, write to the                         *
17 *   Free Software Foundation, Inc.,                                       *
18 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19 ***************************************************************************/
20
21 #include <QApplication>
22
23 #include "qssparser.h"
24
25 QssParser::QssParser()
26 : _maxSenderHash(0)
27 {
28   _palette = QApplication::palette();
29
30   // Init palette color roles
31   _paletteColorRoles["alternate-base"] = QPalette::AlternateBase;
32   _paletteColorRoles["background"] = QPalette::Background;
33   _paletteColorRoles["base"] = QPalette::Base;
34   _paletteColorRoles["bright-text"] = QPalette::BrightText;
35   _paletteColorRoles["button"] = QPalette::Button;
36   _paletteColorRoles["button-text"] = QPalette::ButtonText;
37   _paletteColorRoles["dark"] = QPalette::Dark;
38   _paletteColorRoles["foreground"] = QPalette::Foreground;
39   _paletteColorRoles["highlight"] = QPalette::Highlight;
40   _paletteColorRoles["highlighted-text"] = QPalette::HighlightedText;
41   _paletteColorRoles["light"] = QPalette::Light;
42   _paletteColorRoles["link"] = QPalette::Link;
43   _paletteColorRoles["link-visited"] = QPalette::LinkVisited;
44   _paletteColorRoles["mid"] = QPalette::Mid;
45   _paletteColorRoles["midlight"] = QPalette::Midlight;
46   _paletteColorRoles["shadow"] = QPalette::Shadow;
47   _paletteColorRoles["text"] = QPalette::Text;
48   _paletteColorRoles["tooltip-base"] = QPalette::ToolTipBase;
49   _paletteColorRoles["tooltip-text"] = QPalette::ToolTipText;
50   _paletteColorRoles["window"] = QPalette::Window;
51   _paletteColorRoles["window-text"] = QPalette::WindowText;
52 }
53
54 void QssParser::processStyleSheet(QString &ss) {
55   if(ss.isEmpty())
56     return;
57
58   // Remove C-style comments /* */ or //
59   QRegExp commentRx("(//.*(\\n|$)|/\\*.*\\*/)");
60   commentRx.setMinimal(true);
61   ss.remove(commentRx);
62
63   // Palette definitions first, so we can apply roles later on
64   QRegExp paletterx("(Palette[^{]*)\\{([^}]+)\\}");
65   int pos = 0;
66   while((pos = paletterx.indexIn(ss, pos)) >= 0) {
67     parsePaletteData(paletterx.cap(1).trimmed(), paletterx.cap(2).trimmed());
68     ss.remove(pos, paletterx.matchedLength());
69   }
70
71   // Now we can parse the rest of our custom blocks
72   QRegExp blockrx("((?:ChatLine|BufferList|NickList|TreeView)[^{]*)\\{([^}]+)\\}");
73   pos = 0;
74   while((pos = blockrx.indexIn(ss, pos)) >= 0) {
75     //qDebug() << blockrx.cap(1) << blockrx.cap(2);
76
77     if(blockrx.cap(1).startsWith("ChatLine"))
78       parseChatLineData(blockrx.cap(1).trimmed(), blockrx.cap(2).trimmed());
79     //else
80     // TODO: add moar here
81
82     ss.remove(pos, blockrx.matchedLength());
83   }
84 }
85
86 void QssParser::parseChatLineData(const QString &decl, const QString &contents) {
87   quint64 fmtType = parseFormatType(decl);
88   if(fmtType == UiStyle::Invalid)
89     return;
90
91   QTextCharFormat format;
92
93   foreach(QString line, contents.split(';', QString::SkipEmptyParts)) {
94     int idx = line.indexOf(':');
95     if(idx <= 0) {
96       qWarning() << Q_FUNC_INFO << tr("Invalid property declaration: %1").arg(line.trimmed());
97       continue;
98     }
99     QString property = line.left(idx).trimmed();
100     QString value = line.mid(idx + 1).simplified();
101
102     if(property == "background" || property == "background-color")
103       format.setBackground(parseBrush(value));
104     else if(property == "foreground" || property == "color")
105       format.setForeground(parseBrush(value));
106
107     // font-related properties
108     else if(property.startsWith("font")) {
109       if(property == "font")
110         parseFont(value, &format);
111       else if(property == "font-style")
112         parseFontStyle(value, &format);
113       else if(property == "font-weight")
114         parseFontWeight(value, &format);
115       else if(property == "font-size")
116         parseFontSize(value, &format);
117       else if(property == "font-family")
118         parseFontFamily(value, &format);
119       else {
120         qWarning() << Q_FUNC_INFO << tr("Invalid font property: %1").arg(line);
121         continue;
122       }
123     }
124
125     else {
126       qWarning() << Q_FUNC_INFO << tr("Unknown ChatLine property: %1").arg(property);
127     }
128   }
129
130   _formats[fmtType].merge(format);
131 }
132
133 quint64 QssParser::parseFormatType(const QString &decl) {
134   QRegExp rx("ChatLine(?:::(\\w+))?(?:#(\\w+))?(?:\\[([=-,\\\"\\w\\s]+)\\])?\\s*");
135   // $1: subelement; $2: msgtype; $3: conditionals
136   if(!rx.exactMatch(decl)) {
137     qWarning() << Q_FUNC_INFO << tr("Invalid block declaration: %1").arg(decl);
138     return UiStyle::Invalid;
139   }
140   QString subElement = rx.cap(1);
141   QString msgType = rx.cap(2);
142   QString conditions = rx.cap(3);
143
144   quint64 fmtType = 0;
145
146   // First determine the subelement
147   if(!subElement.isEmpty()) {
148     if(subElement == "timestamp")
149       fmtType |= UiStyle::Timestamp;
150     else if(subElement == "sender")
151       fmtType |= UiStyle::Sender;
152     else if(subElement == "nick")
153       fmtType |= UiStyle::Nick;
154     else if(subElement == "contents")
155       fmtType |= UiStyle::Contents;
156     else if(subElement == "hostmask")
157       fmtType |= UiStyle::Hostmask;
158     else if(subElement == "modeflags")
159       fmtType |= UiStyle::ModeFlags;
160     else {
161       qWarning() << Q_FUNC_INFO << tr("Invalid subelement name in %1").arg(decl);
162       return UiStyle::Invalid;
163     }
164   }
165
166   // Now, figure out the message type
167   if(!msgType.isEmpty()) {
168     if(msgType == "plain")
169       fmtType |= UiStyle::PlainMsg;
170     else if(msgType == "notice")
171       fmtType |= UiStyle::NoticeMsg;
172     else if(msgType == "action")
173       fmtType |= UiStyle::ActionMsg;
174     else if(msgType == "nick")
175       fmtType |= UiStyle::NickMsg;
176     else if(msgType == "mode")
177       fmtType |= UiStyle::ModeMsg;
178     else if(msgType == "join")
179       fmtType |= UiStyle::JoinMsg;
180     else if(msgType == "part")
181       fmtType |= UiStyle::PartMsg;
182     else if(msgType == "quit")
183       fmtType |= UiStyle::QuitMsg;
184     else if(msgType == "kick")
185       fmtType |= UiStyle::KickMsg;
186     else if(msgType == "kill")
187       fmtType |= UiStyle::KillMsg;
188     else if(msgType == "server")
189       fmtType |= UiStyle::ServerMsg;
190     else if(msgType == "info")
191       fmtType |= UiStyle::InfoMsg;
192     else if(msgType == "error")
193       fmtType |= UiStyle::ErrorMsg;
194     else if(msgType == "daychange")
195       fmtType |= UiStyle::DayChangeMsg;
196     else {
197       qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
198     }
199   }
200
201   // Next up: conditional (formats, labels, nickhash)
202   QRegExp condRx("\\s*([\\w\\-]+)\\s*=\\s*\"(\\w+)\"\\s*");
203   if(!conditions.isEmpty()) {
204     foreach(const QString &cond, conditions.split(',', QString::SkipEmptyParts)) {
205       if(!condRx.exactMatch(cond)) {
206         qWarning() << Q_FUNC_INFO << tr("Invalid condition %1").arg(cond);
207         return UiStyle::Invalid;
208       }
209       QString condName = condRx.cap(1);
210       QString condValue = condRx.cap(2);
211       if(condName == "label") {
212         quint64 labeltype = 0;
213         if(condValue == "highlight")
214           labeltype = UiStyle::Highlight;
215         else if(condValue == "selected")
216           labeltype = UiStyle::Selected;
217         else {
218           qWarning() << Q_FUNC_INFO << tr("Invalid message label: %1").arg(condValue);
219           return UiStyle::Invalid;
220         }
221         fmtType |= (labeltype << 32);
222       } else if(condName == "sender") {
223         if(condValue == "self")
224           fmtType |= (quint64)UiStyle::OwnMsg << 32; // sender="self" is actually treated as a label
225           else {
226             bool ok = true;
227             quint64 val = condValue.toUInt(&ok, 16);
228             if(!ok) {
229               qWarning() << Q_FUNC_INFO << tr("Invalid senderhash specification: %1").arg(condValue);
230               return UiStyle::Invalid;
231             }
232             if(val >= 16) {
233               qWarning() << Q_FUNC_INFO << tr("Senderhash can be at most \"0x0f\"!");
234               return UiStyle::Invalid;
235             }
236             fmtType |= val << 48;
237           }
238       } else if(condName == "format") {
239         if(condValue == "bold")
240           fmtType |= UiStyle::Bold;
241         else if(condValue == "italic")
242           fmtType |= UiStyle::Italic;
243         else if(condValue == "underline")
244           fmtType |= UiStyle::Underline;
245         else if(condValue == "reverse")
246           fmtType |= UiStyle::Reverse;
247         else {
248           qWarning() << Q_FUNC_INFO << tr("Invalid format name: %1").arg(condValue);
249           return UiStyle::Invalid;
250         }
251       } else if(condName == "fg-color" || condName == "bg-color") {
252         bool ok;
253         quint8 col = condValue.toUInt(&ok, 16);
254         if(!ok || col > 0x0f) {
255           qWarning() << Q_FUNC_INFO << tr("Illegal IRC color specification (must be between 00 and 0f): %1").arg(condValue);
256           return UiStyle::Invalid;
257         }
258         if(condName == "fg-color")
259           fmtType |= 0x00400000 | (col << 24);
260         else
261           fmtType |= 0x00800000 | (col << 28);
262       } else {
263         qWarning() << Q_FUNC_INFO << tr("Unhandled condition: %1").arg(condName);
264         return UiStyle::Invalid;
265       }
266     }
267   }
268
269   return fmtType;
270 }
271
272 // Palette { ... } specifies the application palette
273 // ColorGroups can be specified like pseudo states, chaining is OR (contrary to normal CSS handling):
274 //   Palette:inactive:disabled { ... } applies to both the Inactive and the Disabled state
275 void QssParser::parsePaletteData(const QString &decl, const QString &contents) {
276   QList<QPalette::ColorGroup> colorGroups;
277
278   // Check if we want to apply this palette definition for particular ColorGroups
279   QRegExp rx("Palette((:(normal|active|inactive|disabled))*)");
280   if(!rx.exactMatch(decl)) {
281     qWarning() << Q_FUNC_INFO << tr("Invalid block declaration: %1").arg(decl);
282     return;
283   }
284   if(!rx.cap(1).isEmpty()) {
285     QStringList groups = rx.cap(1).split(':', QString::SkipEmptyParts);
286     foreach(QString g, groups) {
287       if((g == "normal" || g == "active") && !colorGroups.contains(QPalette::Active))
288         colorGroups.append(QPalette::Active);
289       else if(g == "inactive" && !colorGroups.contains(QPalette::Inactive))
290         colorGroups.append(QPalette::Inactive);
291       else if(g == "disabled" && !colorGroups.contains(QPalette::Disabled))
292         colorGroups.append(QPalette::Disabled);
293     }
294   }
295
296   // Now let's go through the roles
297   foreach(QString line, contents.split(';', QString::SkipEmptyParts)) {
298     int idx = line.indexOf(':');
299     if(idx <= 0) {
300       qWarning() << Q_FUNC_INFO << tr("Invalid palette role assignment: %1").arg(line.trimmed());
301       continue;
302     }
303     QString rolestr = line.left(idx).trimmed();
304     QString brushstr = line.mid(idx + 1).trimmed();
305
306     // We treat the marker line color as a palette role even though it isn't -> special casing
307     if(rolestr == "marker-line") {
308       _markerLineBrush = parseBrush(brushstr);
309       continue;
310     }
311
312     if(!_paletteColorRoles.contains(rolestr)) {
313       qWarning() << Q_FUNC_INFO << tr("Unknown palette role name: %1").arg(rolestr);
314       continue;
315     }
316     QBrush brush = parseBrush(brushstr);
317     if(colorGroups.count()) {
318       foreach(QPalette::ColorGroup group, colorGroups)
319         _palette.setBrush(group, _paletteColorRoles.value(rolestr), brush);
320     } else
321       _palette.setBrush(_paletteColorRoles.value(rolestr), brush);
322   }
323 }
324
325 QBrush QssParser::parseBrush(const QString &str, bool *ok) {
326   if(ok)
327     *ok = false;
328   QColor c = parseColor(str);
329   if(c.isValid()) {
330     if(ok)
331       *ok = true;
332     return QBrush(c);
333   }
334
335   if(str.startsWith("palette")) { // Palette color role
336     QRegExp rx("palette\\s*\\(\\s*([a-z-]+)\\s*\\)");
337     if(!rx.exactMatch(str)) {
338       qWarning() << Q_FUNC_INFO << tr("Invalid palette color role specification: %1").arg(str);
339       return QBrush();
340     }
341     if(!_paletteColorRoles.contains(rx.cap(1))) {
342       qWarning() << Q_FUNC_INFO << tr("Unknown palette color role: %1").arg(rx.cap(1));
343       return QBrush();
344     }
345     return QBrush(_palette.brush(_paletteColorRoles.value(rx.cap(1))));
346
347   } else if(str.startsWith("qlineargradient")) {
348     static QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
349     QRegExp rx(QString("qlineargradient\\s*\\(\\s*x1:%1,\\s*y1:%1,\\s*x2:%1,\\s*y2:%1,(.+)\\)").arg(rxFloat));
350     if(!rx.exactMatch(str)) {
351       qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
352       return QBrush();
353     }
354     qreal x1 = rx.cap(1).toDouble();
355     qreal y1 = rx.cap(2).toDouble();
356     qreal x2 = rx.cap(3).toDouble();
357     qreal y2 = rx.cap(4).toDouble();
358     QGradientStops stops = parseGradientStops(rx.cap(5).trimmed());
359     if(!stops.count()) {
360       qWarning() << Q_FUNC_INFO << tr("Invalid gradient stops list: %1").arg(str);
361       return QBrush();
362     }
363     QLinearGradient gradient(x1, y1, x2, y2);
364     gradient.setStops(stops);
365     if(ok)
366       *ok = true;
367     return QBrush(gradient);
368
369   } else if(str.startsWith("qconicalgradient")) {
370     static QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
371     QRegExp rx(QString("qconicalgradient\\s*\\(\\s*cx:%1,\\s*cy:%1,\\s*angle:%1,(.+)\\)").arg(rxFloat));
372     if(!rx.exactMatch(str)) {
373       qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
374       return QBrush();
375     }
376     qreal cx = rx.cap(1).toDouble();
377     qreal cy = rx.cap(2).toDouble();
378     qreal angle = rx.cap(3).toDouble();
379     QGradientStops stops = parseGradientStops(rx.cap(4).trimmed());
380     if(!stops.count()) {
381       qWarning() << Q_FUNC_INFO << tr("Invalid gradient stops list: %1").arg(str);
382       return QBrush();
383     }
384     QConicalGradient gradient(cx, cy, angle);
385     gradient.setStops(stops);
386     if(ok)
387       *ok = true;
388     return QBrush(gradient);
389
390   } else if(str.startsWith("qradialgradient")) {
391     static QString rxFloat("\\s*(-?\\s*[0-9]*\\.?[0-9]+)\\s*");
392     QRegExp rx(QString("qradialgradient\\s*\\(\\s*cx:%1,\\s*cy:%1,\\s*radius:%1,\\s*fx:%1,\\s*fy:%1,(.+)\\)").arg(rxFloat));
393     if(!rx.exactMatch(str)) {
394       qWarning() << Q_FUNC_INFO << tr("Invalid gradient declaration: %1").arg(str);
395       return QBrush();
396     }
397     qreal cx = rx.cap(1).toDouble();
398     qreal cy = rx.cap(2).toDouble();
399     qreal radius = rx.cap(3).toDouble();
400     qreal fx = rx.cap(4).toDouble();
401     qreal fy = rx.cap(5).toDouble();
402     QGradientStops stops = parseGradientStops(rx.cap(6).trimmed());
403     if(!stops.count()) {
404       qWarning() << Q_FUNC_INFO << tr("Invalid gradient stops list: %1").arg(str);
405       return QBrush();
406     }
407     QRadialGradient gradient(cx, cy, radius, fx, fy);
408     gradient.setStops(stops);
409     if(ok)
410       *ok = true;
411     return QBrush(gradient);
412   }
413
414   return QBrush();
415 }
416
417 QColor QssParser::parseColor(const QString &str) {
418   if(str.startsWith("rgba")) {
419     ColorTuple tuple = parseColorTuple(str.mid(4));
420     if(tuple.count() == 4)
421       return QColor(tuple.at(0), tuple.at(1), tuple.at(2), tuple.at(3));
422   } else if(str.startsWith("rgb")) {
423     ColorTuple tuple = parseColorTuple(str.mid(3));
424     if(tuple.count() == 3)
425       return QColor(tuple.at(0), tuple.at(1), tuple.at(2));
426   } else if(str.startsWith("hsva")) {
427     ColorTuple tuple = parseColorTuple(str.mid(4));
428     if(tuple.count() == 4) {
429       QColor c;
430       c.setHsvF(tuple.at(0), tuple.at(1), tuple.at(2), tuple.at(3));
431       return c;
432     }
433   } else if(str.startsWith("hsv")) {
434     ColorTuple tuple = parseColorTuple(str.mid(3));
435     if(tuple.count() == 3) {
436       QColor c;
437       c.setHsvF(tuple.at(0), tuple.at(1), tuple.at(2));
438       return c;
439     }
440   } else {
441     QRegExp rx("#?[0-9A-Fa-z]+");
442     if(rx.exactMatch(str))
443       return QColor(str);
444   }
445   return QColor();
446 }
447
448 // get a list of comma-separated int values or percentages (rel to 0-255)
449 QssParser::ColorTuple QssParser::parseColorTuple(const QString &str) {
450   ColorTuple result;
451   QRegExp rx("\\(((\\s*[0-9]{1,3}%?\\s*)(,\\s*[0-9]{1,3}%?\\s*)*)\\)");
452   if(!rx.exactMatch(str.trimmed())) {
453     return ColorTuple();
454   }
455   QStringList values = rx.cap(1).split(',');
456   foreach(QString v, values) {
457     qreal val;
458     bool perc = false;
459     bool ok;
460     v = v.trimmed();
461     if(v.endsWith('%')) {
462       perc = true;
463       v.chop(1);
464     }
465     val = (qreal)v.toUInt(&ok);
466     if(!ok)
467       return ColorTuple();
468     if(perc)
469       val = 255 * val/100;
470     result.append(val);
471   }
472   return result;
473 }
474
475 QGradientStops QssParser::parseGradientStops(const QString &str_) {
476   QString str = str_;
477   QGradientStops result;
478   static QString rxFloat("(0?\\.[0-9]+|[01])"); // values between 0 and 1
479   QRegExp rx(QString("\\s*,?\\s*stop:\\s*(%1)\\s+([^:]+)(,\\s*stop:|$)").arg(rxFloat));
480   int idx;
481   while((idx = rx.indexIn(str)) == 0) {
482     qreal x = rx.cap(1).toDouble();
483     QColor c = parseColor(rx.cap(3));
484     if(!c.isValid())
485       return QGradientStops();
486     result << QGradientStop(x, c);
487     str.remove(0, rx.matchedLength() - rx.cap(4).length());
488   }
489   if(!str.trimmed().isEmpty())
490     return QGradientStops();
491
492   return result;
493 }
494
495 /******** Font Properties ********/
496
497 void QssParser::parseFont(const QString& value, QTextCharFormat* format) {
498   QRegExp rx("((?:(?:normal|italic|oblique|underline|bold|100|200|300|400|500|600|700|800|900) ){0,2}) ?(\\d+)(pt|px)? \"(.*)\"");
499   if(!rx.exactMatch(value)) {
500     qWarning() << Q_FUNC_INFO << tr("Invalid font specification: %1").arg(value);
501     return;
502   }
503   format->setFontItalic(false);
504   format->setFontWeight(QFont::Normal);
505   QStringList proplist = rx.cap(1).split(' ', QString::SkipEmptyParts);
506   foreach(QString prop, proplist) {
507     if(prop == "italic")
508       format->setFontItalic(true);
509     else if(prop == "underline")
510       format->setFontUnderline(true);
511     //else if(prop == "oblique")
512     //  format->setStyle(QFont::StyleOblique);
513     else if(prop == "bold")
514       format->setFontWeight(QFont::Bold);
515     else { // number
516       int w = prop.toInt();
517       format->setFontWeight(qMin(w / 8, 99)); // taken from Qt's qss parser
518     }
519   }
520
521   if(rx.cap(3) == "px")
522     format->setProperty(QTextFormat::FontPixelSize, rx.cap(2).toInt());
523   else
524     format->setFontPointSize(rx.cap(2).toInt());
525
526   format->setFontFamily(rx.cap(4));
527 }
528
529 void QssParser::parseFontStyle(const QString& value, QTextCharFormat* format) {
530   if(value == "normal")
531     format->setFontItalic(false);
532   else if(value == "italic")
533     format->setFontItalic(true);
534   else if(value == "underline")
535     format->setFontUnderline(true);
536   //else if(value == "oblique")
537   //  format->setStyle(QFont::StyleOblique);
538   else {
539     qWarning() << Q_FUNC_INFO << tr("Invalid font style specification: %1").arg(value);
540   }
541 }
542
543 void QssParser::parseFontWeight(const QString& value, QTextCharFormat* format) {
544   if(value == "normal")
545     format->setFontWeight(QFont::Normal);
546   else if(value == "bold")
547     format->setFontWeight(QFont::Bold);
548   else {
549     bool ok;
550     int w = value.toInt(&ok);
551     if(!ok) {
552       qWarning() << Q_FUNC_INFO << tr("Invalid font weight specification: %1").arg(value);
553       return;
554     }
555     format->setFontWeight(qMin(w / 8, 99)); // taken from Qt's qss parser
556   }
557 }
558
559 void QssParser::parseFontSize(const QString& value, QTextCharFormat* format) {
560   QRegExp rx("\\(d+)(pt|px)");
561   if(!rx.exactMatch(value)) {
562     qWarning() << Q_FUNC_INFO << tr("Invalid font size specification: %1").arg(value);
563     return;
564   }
565   if(rx.cap(2) == "px")
566     format->setProperty(QTextFormat::FontPixelSize, rx.cap(1).toInt());
567   else
568     format->setFontPointSize(rx.cap(1).toInt());
569 }
570
571 void QssParser::parseFontFamily(const QString& value, QTextCharFormat* format) {
572   QString family = value;
573   if(family.startsWith('"') && family.endsWith('"')) {
574     family = family.mid(1, family.length() - 2);
575   }
576   format->setFontFamily(family);
577 }