1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7
8 #include "smfontfeatures.h"
9 #include "util.h"
10
11 #include "fonts/fontfeatures.h"
12
13 #include <QAction>
14 #include <QListWidget>
15 #include <QListWidgetItem>
16 #include <QSignalBlocker>
17
SMFontFeatures(QWidget * parent)18 SMFontFeatures::SMFontFeatures(QWidget *parent)
19 : QWidget(parent)
20 {
21 setupUi(this);
22 styleSetsMenu = new StylisticSetsMenu(this);
23 for (int i = 1; i <= 20 ; i++)
24 {
25 QAction *action = new QAction("set " + QString::number(i), styleSetsMenu);
26 action->setCheckable(true);
27 styleSetsMenu->addAction(action);
28 }
29 stylisticSetsButton->setMenu(styleSetsMenu);
30
31 //capture changed signal
32 connect(this->CommonCheck, SIGNAL(toggled(bool)), this, SLOT(slotChange()));
33 connect(this->ContextualCheck, SIGNAL(toggled(bool)), this, SLOT(slotChange()));
34 connect(this->DiscretionaryCheck, SIGNAL(toggled(bool)), this, SLOT(slotChange()));
35 connect(this->HistoricalCheck, SIGNAL(toggled(bool)), this, SLOT(slotChange()));
36 connect(this->SlashedZeroCheck, SIGNAL(toggled(bool)), this, SLOT(slotChange()));
37 connect(this->capitalsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
38 connect(this->positionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
39 connect(this->numeralComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
40 connect(this->widthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
41 connect(this->fractionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChange()));
42 connect(this->styleSetsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotChange()));
43 }
44
changeEvent(QEvent * e)45 void SMFontFeatures::changeEvent(QEvent *e)
46 {
47 if (e->type() == QEvent::LanguageChange)
48 languageChange();
49 else
50 QWidget::changeEvent(e);
51 }
52
languageChange()53 void SMFontFeatures::languageChange()
54 {
55 QSignalBlocker blocker01(this->CommonCheck);
56 QSignalBlocker blocker02(this->ContextualCheck);
57 QSignalBlocker blocker03(this->DiscretionaryCheck);
58 QSignalBlocker blocker04(this->HistoricalCheck);
59 QSignalBlocker blocker05(this->SlashedZeroCheck);
60 QSignalBlocker blocker06(this->capitalsComboBox);
61 QSignalBlocker blocker07(this->positionComboBox);
62 QSignalBlocker blocker08(this->numeralComboBox);
63 QSignalBlocker blocker09(this->widthComboBox);
64 QSignalBlocker blocker10(this->fractionComboBox);
65 QSignalBlocker blocker11(this->styleSetsMenu);
66
67 QStringList capitalFeatures = comboboxFeatures(capitalsComboBox);
68 QStringList positionFeatures = comboboxFeatures(positionComboBox);
69 QStringList numeralFeatures = comboboxFeatures(numeralComboBox);
70 QStringList widthFeatures = comboboxFeatures(widthComboBox);
71 QStringList fractionFeatures = comboboxFeatures(fractionComboBox);
72
73 int oldCapitalIndex = capitalsComboBox->currentIndex();
74 int oldPositionIndex = positionComboBox->currentIndex();
75 int oldNumeralIndex = numeralComboBox->currentIndex();
76 int oldWidthIndex = widthComboBox->currentIndex();
77 int oldFractionIndex = fractionComboBox->currentIndex();
78
79 retranslateUi(this);
80
81 setupCapitalCombo(FontFeatures::textFlagsFromList(capitalFeatures));
82 setupPositionCombo(FontFeatures::textFlagsFromList(positionFeatures));
83 setupNumeralStyleCombo(FontFeatures::textFlagsFromList(numeralFeatures));
84 setupNumeralWidthCombo(FontFeatures::textFlagsFromList(widthFeatures));
85 setupNumeralFractionCombo(FontFeatures::textFlagsFromList(fractionFeatures));
86
87 capitalsComboBox->setCurrentIndex(oldCapitalIndex);
88 positionComboBox->setCurrentIndex(oldPositionIndex);
89 numeralComboBox->setCurrentIndex(oldNumeralIndex);
90 widthComboBox->setCurrentIndex(oldWidthIndex);
91 fractionComboBox->setCurrentIndex(oldFractionIndex);
92 }
93
comboboxFeatures(QComboBox * combo)94 QStringList SMFontFeatures::comboboxFeatures(QComboBox* combo)
95 {
96 QStringList features;
97 for (int i = 0; i < combo->count(); ++i)
98 {
99 QVariant varVal = combo->itemData(i);
100 QString value = varVal.toString();
101 if (value.length() > 0)
102 features.append(value);
103 }
104 return features;
105 }
106
setFontFeatures(const QString & s,QStringList fontFeaturesList)107 void SMFontFeatures::setFontFeatures(const QString& s, QStringList fontFeaturesList)
108 {
109 disconnectSignals();
110 m_hasParent = false;
111 m_pValue.clear();
112
113 resetFontFeatures();
114 enableFontFeatures(fontFeaturesList);
115 SlashedZeroCheck->setEnabled(true);
116
117 QStringList fontFeatures = s.split(',');
118 for (int i = 0; i < fontFeatures.count(); i++)
119 {
120 // Ligatures
121 if (fontFeatures[i] == "-clig")
122 ContextualCheck->setChecked(false);
123 else if (fontFeatures[i] == "-liga")
124 CommonCheck->setChecked(false);
125 else if (fontFeatures[i] == "+dlig")
126 DiscretionaryCheck->setChecked(true);
127 else if (fontFeatures[i] == "+hlig")
128 HistoricalCheck->setChecked(true);
129 // position comboBox
130 else if (fontFeatures[i] == "+subs" ||
131 fontFeatures[i] == "+sups" ||
132 fontFeatures[i] == "+ordn")
133 {
134 setCurrentComboItemFromData(positionComboBox, fontFeatures[i]);
135 }
136 // Capitals ComboBox
137 else if (fontFeatures[i] == "+smcp" ||
138 fontFeatures[i] == "+c2sc" ||
139 fontFeatures[i] == "+pcap" ||
140 fontFeatures[i] == "+c2pc" ||
141 fontFeatures[i] == "+unic" ||
142 fontFeatures[i] == "+titl")
143 {
144 setCurrentComboItemFromData(capitalsComboBox, fontFeatures[i]);
145 }
146 // Numerals style
147 else if (fontFeatures[i] == "+lnum" ||
148 fontFeatures[i] == "+onum")
149 {
150 setCurrentComboItemFromData(numeralComboBox, fontFeatures[i]);
151 }
152 // Numerals width
153 else if (fontFeatures[i] == "+pnum" ||
154 fontFeatures[i] == "+tnum")
155 {
156 setCurrentComboItemFromData(widthComboBox, fontFeatures[i]);
157 }
158 // Numerals Fraction
159 else if (fontFeatures[i] == "+frac" ||
160 fontFeatures[i] == "+afrc")
161 {
162 setCurrentComboItemFromData(fractionComboBox, fontFeatures[i]);
163 }
164 // Numerals Zero
165 else if (fontFeatures[i] == "+zero")
166 SlashedZeroCheck->setChecked(true);
167 // Style Sets
168 else if (fontFeatures[i] == "+ss01")
169 styleSetsMenu->actions().at(0)->setChecked(true);
170 else if (fontFeatures[i] == "+ss02")
171 styleSetsMenu->actions().at(1)->setChecked(true);
172 else if (fontFeatures[i] == "+ss03")
173 styleSetsMenu->actions().at(2)->setChecked(true);
174 else if (fontFeatures[i] == "+ss04")
175 styleSetsMenu->actions().at(3)->setChecked(true);
176 else if (fontFeatures[i] == "+ss05")
177 styleSetsMenu->actions().at(4)->setChecked(true);
178 else if (fontFeatures[i] == "+ss06")
179 styleSetsMenu->actions().at(5)->setChecked(true);
180 else if (fontFeatures[i] == "+ss07")
181 styleSetsMenu->actions().at(6)->setChecked(true);
182 else if (fontFeatures[i] == "+ss08")
183 styleSetsMenu->actions().at(7)->setChecked(true);
184 else if (fontFeatures[i] == "+ss09")
185 styleSetsMenu->actions().at(8)->setChecked(true);
186 else if (fontFeatures[i] == "+ss10")
187 styleSetsMenu->actions().at(9)->setChecked(true);
188 else if (fontFeatures[i] == "+ss11")
189 styleSetsMenu->actions().at(10)->setChecked(true);
190 else if (fontFeatures[i] == "+ss12")
191 styleSetsMenu->actions().at(11)->setChecked(true);
192 else if (fontFeatures[i] == "+ss13")
193 styleSetsMenu->actions().at(12)->setChecked(true);
194 else if (fontFeatures[i] == "+ss14")
195 styleSetsMenu->actions().at(13)->setChecked(true);
196 else if (fontFeatures[i] == "+ss15")
197 styleSetsMenu->actions().at(14)->setChecked(true);
198 else if (fontFeatures[i] == "+ss16")
199 styleSetsMenu->actions().at(15)->setChecked(true);
200 else if (fontFeatures[i] == "+ss17")
201 styleSetsMenu->actions().at(16)->setChecked(true);
202 else if (fontFeatures[i] == "+ss18")
203 styleSetsMenu->actions().at(17)->setChecked(true);
204 else if (fontFeatures[i] == "+ss19")
205 styleSetsMenu->actions().at(18)->setChecked(true);
206 else if (fontFeatures[i] == "+ss20")
207 styleSetsMenu->actions().at(19)->setChecked(true);
208 }
209
210 if (numeralComboBox->currentData().toString() == "+onum")
211 {
212 SlashedZeroCheck->setChecked(false);
213 SlashedZeroCheck->setEnabled(false);
214 }
215 }
216
setFontFeatures(const QString & val,QStringList fontFeatures,bool isParentVal)217 void SMFontFeatures::setFontFeatures(const QString& val, QStringList fontFeatures, bool isParentVal)
218 {
219 disconnectSignals();
220 m_hasParent = true;
221 m_pValue = val;
222
223 if (isParentVal)
224 setFontFeatures(val, fontFeatures);
225 connectSignals();
226 }
227
fontFeatures()228 QString SMFontFeatures::fontFeatures()
229 {
230 QStringList font_feature ;
231 if (!ContextualCheck->isChecked())
232 font_feature << "-clig";
233 if (!CommonCheck->isChecked())
234 font_feature << "-liga";
235 if (DiscretionaryCheck->isChecked())
236 font_feature << "+dlig";
237 if (HistoricalCheck->isChecked())
238 font_feature << "+hlig";
239 //Position
240 QVariant varVal = positionComboBox->currentData();
241 QString value = varVal.toString();
242 if (value.length() > 0)
243 font_feature << value;
244 //Capitals
245 varVal = capitalsComboBox->currentData();
246 value = varVal.toString();
247 if (value.length() > 0)
248 font_feature << value;
249 //Numerals style
250 varVal = numeralComboBox->currentData();
251 value = varVal.toString();
252 if (value.length() > 0)
253 font_feature << value;
254 //Numerals width
255 varVal = widthComboBox->currentData();
256 value = varVal.toString();
257 if (value.length() > 0)
258 font_feature << value;
259 //Numerals Fraction
260 varVal = fractionComboBox->currentData();
261 value = varVal.toString();
262 if (value.length() > 0)
263 font_feature << value;
264 // Numerals Zero
265 if (SlashedZeroCheck->isChecked())
266 font_feature << "+zero";
267
268 // Stylistic sets
269 if (styleSetsMenu->actions().at(0)->isChecked())
270 font_feature << "+ss01";
271 if (styleSetsMenu->actions().at(1)->isChecked())
272 font_feature << "+ss02";
273 if (styleSetsMenu->actions().at(2)->isChecked())
274 font_feature << "+ss03";
275 if (styleSetsMenu->actions().at(3)->isChecked())
276 font_feature << "+ss04";
277 if (styleSetsMenu->actions().at(4)->isChecked())
278 font_feature << "+ss05";
279 if (styleSetsMenu->actions().at(5)->isChecked())
280 font_feature << "+ss06";
281 if (styleSetsMenu->actions().at(6)->isChecked())
282 font_feature << "+ss07";
283 if (styleSetsMenu->actions().at(7)->isChecked())
284 font_feature << "+ss08";
285 if (styleSetsMenu->actions().at(8)->isChecked())
286 font_feature << "+ss09";
287 if (styleSetsMenu->actions().at(9)->isChecked())
288 font_feature << "+ss10";
289 if (styleSetsMenu->actions().at(10)->isChecked())
290 font_feature << "+ss11";
291 if (styleSetsMenu->actions().at(11)->isChecked())
292 font_feature << "+ss12";
293 if (styleSetsMenu->actions().at(12)->isChecked())
294 font_feature << "+ss13";
295 if (styleSetsMenu->actions().at(13)->isChecked())
296 font_feature << "+ss14";
297 if (styleSetsMenu->actions().at(14)->isChecked())
298 font_feature << "+ss15";
299 if (styleSetsMenu->actions().at(15)->isChecked())
300 font_feature << "+ss16";
301 if (styleSetsMenu->actions().at(16)->isChecked())
302 font_feature << "+ss17";
303 if (styleSetsMenu->actions().at(17)->isChecked())
304 font_feature << "+ss18";
305 if (styleSetsMenu->actions().at(18)->isChecked())
306 font_feature << "+ss19";
307 if (styleSetsMenu->actions().at(19)->isChecked())
308 font_feature << "+ss20";
309 return font_feature.join(",");
310 }
311
setParentValue(const QString & val)312 void SMFontFeatures::setParentValue(const QString& val)
313 {
314 m_hasParent = true;
315 m_pValue = val;
316 }
317
useParentValue()318 bool SMFontFeatures::useParentValue()
319 {
320 bool ret = m_useParentValue;
321 m_useParentValue = false;
322 return ret;
323 }
324
connectSignals()325 void SMFontFeatures::connectSignals()
326 {
327 connect(ContextualCheck, SIGNAL(clicked()), this, SLOT(slotContextualCheck()));
328 connect(CommonCheck, SIGNAL(clicked()), this, SLOT(slotCommonCheck()));
329 connect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(slotDiscretionaryCheck()));
330 connect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(slotHistoricalCheck()));
331 connect(capitalsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCapitalsComboBox()));
332 connect(positionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPositionComboBox()));
333 connect(numeralComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotNumeralComboBox()));
334 connect(widthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotWidthComboBox()));
335 connect(fractionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotFractionComboBox()));
336 connect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(slotSlashedZeroCheck()));
337 connect(styleSetsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotSetMenu()));
338 }
339
disconnectSignals()340 void SMFontFeatures::disconnectSignals()
341 {
342 disconnect(ContextualCheck, SIGNAL(clicked()), this, SLOT(slotContextualCheck()));
343 disconnect(CommonCheck, SIGNAL(clicked()), this, SLOT(slotCommonCheck()));
344 disconnect(DiscretionaryCheck, SIGNAL(clicked()), this, SLOT(slotDiscretionaryCheck()));
345 disconnect(HistoricalCheck, SIGNAL(clicked()), this, SLOT(slotHistoricalCheck()));
346 disconnect(capitalsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCapitalsComboBox()));
347 disconnect(positionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPositionComboBox()));
348 disconnect(numeralComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotNumeralComboBox()));
349 disconnect(widthComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotWidthComboBox()));
350 disconnect(fractionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotFractionComboBox()));
351 disconnect(SlashedZeroCheck, SIGNAL(clicked()), this, SLOT(slotSlashedZeroCheck()));
352 disconnect(styleSetsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotSetMenu()));
353 }
354
hideAllFontFeatures()355 void SMFontFeatures::hideAllFontFeatures()
356 {
357 statusLabel->hide();
358 ligaturesGroupBox->hide();
359 CommonCheck->setChecked(false);
360 CommonCheck->setDisabled(true);
361 DiscretionaryCheck->setChecked(false);
362 DiscretionaryCheck->setDisabled(true);
363 ContextualCheck->setDisabled(true);
364 HistoricalCheck->setDisabled(true);
365
366 capitalsLabel->hide();
367 capitalsComboBox->hide();
368 setupCapitalCombo(FontFeatures::NoFeatures);
369
370 positionLabel->hide();
371 positionComboBox->hide();
372 setupPositionCombo(FontFeatures::NoFeatures);
373 capitalsGroupBox->hide();
374
375 numeralsGroupBox->hide();
376 styleLabel->hide();
377 numeralComboBox->hide();
378 setupNumeralStyleCombo(FontFeatures::NoFeatures);
379
380 widthLabel->hide();
381 widthComboBox->hide();
382 setupNumeralWidthCombo(FontFeatures::NoFeatures);
383
384 fractionLabel->hide();
385 fractionComboBox->hide();
386 setupNumeralFractionCombo(FontFeatures::NoFeatures);
387
388 SlashedZeroCheck->hide();
389
390 stylisticSetsLabel->hide();
391 stylisticSetsButton->hide();
392 for (int i = 0; i < styleSetsMenu->actions().count(); i++)
393 {
394 styleSetsMenu->actions().at(i)->setVisible(false);
395 }
396 }
397
enableFontFeatures(const QStringList & fontFeatures)398 void SMFontFeatures::enableFontFeatures(const QStringList& fontFeatures)
399 {
400 int featureFlags = FontFeatures::fontFlagsFromList(fontFeatures);
401
402 hideAllFontFeatures();
403
404 // Capitals
405 setupCapitalCombo(featureFlags);
406 capitalsComboBox->setVisible(capitalsComboBox->count() > 1);
407 capitalsLabel->setVisible(capitalsComboBox->count() > 1);
408
409 // Positions
410 setupPositionCombo(featureFlags);
411 positionComboBox->setVisible(positionComboBox->count() > 1);
412 positionLabel->setVisible(positionComboBox->count() > 1);
413
414 // Numeral Style
415 setupNumeralStyleCombo(featureFlags);
416 numeralComboBox->setVisible(numeralComboBox->count() > 1);
417 styleLabel->setVisible(numeralComboBox->count() > 1);
418
419 // Numeral Width
420 setupNumeralWidthCombo(featureFlags);
421 widthComboBox->setVisible(widthComboBox->count() > 1);
422 widthLabel->setVisible(widthComboBox->count() > 1);
423
424 // Numeral Fractions
425 setupNumeralFractionCombo(featureFlags);
426 fractionComboBox->setVisible(fractionComboBox->count() > 1);
427 fractionLabel->setVisible(fractionComboBox->count() > 1);
428
429 // Ligatures
430 CommonCheck->setEnabled(featureFlags & FontFeatures::CommonLigatures);
431 CommonCheck->setChecked(featureFlags & FontFeatures::CommonLigatures);
432
433 ContextualCheck->setEnabled(featureFlags & FontFeatures::ContextualLigatures);
434 ContextualCheck->setChecked(featureFlags & FontFeatures::ContextualLigatures);
435
436 DiscretionaryCheck->setEnabled(featureFlags & FontFeatures::DiscretionaryLigatures);
437 HistoricalCheck->setEnabled(featureFlags & FontFeatures::HistoricalLigatures);
438
439 // Numerals Zero
440 SlashedZeroCheck->setVisible(featureFlags & FontFeatures::SlashedZero);
441
442 // Style Sets
443 styleSetsMenu->actions().at(0)->setVisible(featureFlags & FontFeatures::StyleSet01);
444 styleSetsMenu->actions().at(1)->setVisible(featureFlags & FontFeatures::StyleSet02);
445 styleSetsMenu->actions().at(2)->setVisible(featureFlags & FontFeatures::StyleSet03);
446 styleSetsMenu->actions().at(3)->setVisible(featureFlags & FontFeatures::StyleSet04);
447 styleSetsMenu->actions().at(4)->setVisible(featureFlags & FontFeatures::StyleSet05);
448 styleSetsMenu->actions().at(5)->setVisible(featureFlags & FontFeatures::StyleSet06);
449 styleSetsMenu->actions().at(6)->setVisible(featureFlags & FontFeatures::StyleSet07);
450 styleSetsMenu->actions().at(7)->setVisible(featureFlags & FontFeatures::StyleSet08);
451 styleSetsMenu->actions().at(8)->setVisible(featureFlags & FontFeatures::StyleSet09);
452 styleSetsMenu->actions().at(9)->setVisible(featureFlags & FontFeatures::StyleSet10);
453 styleSetsMenu->actions().at(10)->setVisible(featureFlags & FontFeatures::StyleSet11);
454 styleSetsMenu->actions().at(11)->setVisible(featureFlags & FontFeatures::StyleSet12);
455 styleSetsMenu->actions().at(12)->setVisible(featureFlags & FontFeatures::StyleSet13);
456 styleSetsMenu->actions().at(13)->setVisible(featureFlags & FontFeatures::StyleSet14);
457 styleSetsMenu->actions().at(14)->setVisible(featureFlags & FontFeatures::StyleSet15);
458 styleSetsMenu->actions().at(15)->setVisible(featureFlags & FontFeatures::StyleSet16);
459 styleSetsMenu->actions().at(16)->setVisible(featureFlags & FontFeatures::StyleSet17);
460 styleSetsMenu->actions().at(17)->setVisible(featureFlags & FontFeatures::StyleSet18);
461 styleSetsMenu->actions().at(18)->setVisible(featureFlags & FontFeatures::StyleSet19);
462 styleSetsMenu->actions().at(19)->setVisible(featureFlags & FontFeatures::StyleSet20);
463
464 ligaturesGroupBox->setVisible(featureFlags & FontFeatures::LigaturesMask);
465 capitalsGroupBox->setVisible(featureFlags & (FontFeatures::CapsMask | FontFeatures::GlyphPositionMask));
466
467 quint64 numeralsMask = FontFeatures::NumeralStyleMask | FontFeatures::NumeralWidthMask | FontFeatures::NumeralFractionsMask;
468 numeralsMask |= FontFeatures::SlashedZero;
469 numeralsGroupBox->setVisible(featureFlags & numeralsMask);
470
471 stylisticSetsLabel->setVisible(featureFlags & FontFeatures::StyleSetsMask);
472 stylisticSetsButton->setVisible(featureFlags & FontFeatures::StyleSetsMask);
473
474 if (ligaturesGroupBox->isHidden() && capitalsGroupBox->isHidden()
475 && numeralsGroupBox->isHidden() && stylisticSetsButton->isHidden())
476 {
477 statusLabel->show();
478 }
479 }
480
setupCapitalCombo(quint64 featureFlags)481 void SMFontFeatures::setupCapitalCombo(quint64 featureFlags)
482 {
483 QSignalBlocker blocker(capitalsComboBox);
484
485 capitalsComboBox->clear();
486 capitalsComboBox->addItem( tr("Default Capitals"));
487
488 if (featureFlags & FontFeatures::SmallCaps)
489 capitalsComboBox->addItem(tr("Small Capitals"), QVariant("+smcp"));
490 if (featureFlags & FontFeatures::SmallCapsFromCaps)
491 capitalsComboBox->addItem(tr("Small Capitals from Capitals"), QVariant("+c2sc"));
492 if (featureFlags & FontFeatures::PetiteCaps)
493 capitalsComboBox->addItem(tr("Petite Capitals"), QVariant("+pcap"));
494 if (featureFlags & FontFeatures::PetiteCapsFromCaps)
495 capitalsComboBox->addItem(tr("Petite Capitals from Capitals"), QVariant("+c2pc"));
496 if (featureFlags & FontFeatures::UnicaseCaps)
497 capitalsComboBox->addItem(tr("Unicase"), QVariant("+unic"));
498 if (featureFlags & FontFeatures::TiltingCaps)
499 capitalsComboBox->addItem(tr("Titling"), QVariant("+titl"));
500 }
501
setupPositionCombo(quint64 featureFlags)502 void SMFontFeatures::setupPositionCombo(quint64 featureFlags)
503 {
504 QSignalBlocker blocker(positionComboBox);
505
506 positionComboBox->clear();
507 positionComboBox->addItem( tr("Default Position"));
508
509 if (featureFlags & FontFeatures::Subscript)
510 positionComboBox->addItem(tr("Subscript"), QVariant("+subs"));
511 if (featureFlags & FontFeatures::Superscript)
512 positionComboBox->addItem(tr("Superscript"), QVariant("+sups"));
513 if (featureFlags & FontFeatures::Ordinals)
514 positionComboBox->addItem(tr("Ordinals"), QVariant("+ordn"));
515 }
516
setupNumeralStyleCombo(quint64 featureFlags)517 void SMFontFeatures::setupNumeralStyleCombo(quint64 featureFlags)
518 {
519 QSignalBlocker blocker(numeralComboBox);
520
521 numeralComboBox->clear();
522 numeralComboBox->addItem( tr("Default Numerals"));
523
524 if (featureFlags & FontFeatures::LiningNumerals)
525 numeralComboBox->addItem(tr("Lining"), QVariant("+lnum"));
526 if (featureFlags & FontFeatures::OldStyleNumerals)
527 numeralComboBox->addItem(tr("Old Style"), QVariant("+onum"));
528 }
529
setupNumeralWidthCombo(quint64 featureFlags)530 void SMFontFeatures::setupNumeralWidthCombo(quint64 featureFlags)
531 {
532 QSignalBlocker blocker(widthComboBox);
533
534 widthComboBox->clear();
535 widthComboBox->addItem( tr("Default Numeral Width"));
536
537 if (featureFlags & FontFeatures::ProportionalNumeralWidth)
538 widthComboBox->addItem(tr("Proportional"), QVariant("+pnum"));
539 if (featureFlags & FontFeatures::TabularNumeralWidth)
540 widthComboBox->addItem(tr("Tabular"), QVariant("+tnum"));
541 }
542
setupNumeralFractionCombo(quint64 featureFlags)543 void SMFontFeatures::setupNumeralFractionCombo(quint64 featureFlags)
544 {
545 QSignalBlocker blocker(fractionComboBox);
546
547 fractionComboBox->clear();
548 fractionComboBox->addItem( tr("No Fractions"));
549
550 if (featureFlags & FontFeatures::DiagonalFractions)
551 fractionComboBox->addItem(tr("Diagonal Fractions"), QVariant("+frac"));
552 if (featureFlags & FontFeatures::StackedFractions)
553 fractionComboBox->addItem(tr("Stacked Fractions"), QVariant("+afrc"));
554 }
555
slotChange()556 void SMFontFeatures::slotChange()
557 {
558 emit changed();
559 }
560
slotContextualCheck()561 void SMFontFeatures::slotContextualCheck()
562 {
563 if (m_hasParent)
564 {
565 QFont f(font());
566 f.setBold(true);
567 ContextualCheck->setFont(f);
568 }
569 }
570
slotCommonCheck()571 void SMFontFeatures::slotCommonCheck()
572 {
573 if (m_hasParent)
574 {
575 QFont f(font());
576 f.setBold(true);
577 CommonCheck->setFont(f);
578 }
579 }
580
slotDiscretionaryCheck()581 void SMFontFeatures::slotDiscretionaryCheck()
582 {
583 if (m_hasParent)
584 {
585 QFont f(font());
586 f.setBold(true);
587 DiscretionaryCheck->setFont(f);
588 }
589 }
590
slotHistoricalCheck()591 void SMFontFeatures::slotHistoricalCheck()
592 {
593 if (m_hasParent)
594 {
595 QFont f(font());
596 f.setBold(true);
597 HistoricalCheck->setFont(f);
598 }
599 }
600
slotCapitalsComboBox()601 void SMFontFeatures::slotCapitalsComboBox()
602 {
603 if (m_hasParent)
604 {
605 QFont f(font());
606 f.setBold(true);
607 capitalsComboBox->setFont(f);
608 }
609 }
610
slotPositionComboBox()611 void SMFontFeatures::slotPositionComboBox()
612 {
613 if (m_hasParent)
614 {
615 QFont f(font());
616 f.setBold(true);
617 positionComboBox->setFont(f);
618 }
619 }
620
slotNumeralComboBox()621 void SMFontFeatures::slotNumeralComboBox()
622 {
623 if (m_hasParent)
624 {
625 QFont f(font());
626 f.setBold(true);
627 numeralComboBox->setFont(f);
628 }
629
630 // Old Style numerals do not support slashed zero
631 bool oldStyleNumeral = (numeralComboBox->currentData().toString() == "+onum");
632 if (oldStyleNumeral)
633 SlashedZeroCheck->setChecked(false);
634 SlashedZeroCheck->setEnabled(!oldStyleNumeral);
635 }
636
slotWidthComboBox()637 void SMFontFeatures::slotWidthComboBox()
638 {
639 if (m_hasParent)
640 {
641 QFont f(font());
642 f.setBold(true);
643 widthComboBox->setFont(f);
644 }
645 }
646
slotFractionComboBox()647 void SMFontFeatures::slotFractionComboBox()
648 {
649 if (m_hasParent)
650 {
651 QFont f(font());
652 f.setBold(true);
653 fractionComboBox->setFont(f);
654 }
655 }
656
slotSlashedZeroCheck()657 void SMFontFeatures::slotSlashedZeroCheck()
658 {
659 if (m_hasParent)
660 {
661 QFont f(font());
662 f.setBold(true);
663 SlashedZeroCheck->setFont(f);
664 }
665 }
666
slotSetMenu()667 void SMFontFeatures::slotSetMenu()
668 {
669 if (m_hasParent)
670 {
671 QFont f(font());
672 f.setBold(true);
673 for (int i = 0; i < styleSetsMenu->actions().count(); i++)
674 {
675 if (styleSetsMenu->actions().at(i)->isChecked())
676 styleSetsMenu->actions().at(i)->setFont(f);
677 }
678 }
679 }
680
resetFontFeatures()681 void SMFontFeatures::resetFontFeatures()
682 {
683 disconnectSignals();
684 ContextualCheck->setChecked(false);
685 CommonCheck->setChecked(false);
686 DiscretionaryCheck->setChecked(false);
687 HistoricalCheck->setChecked(false);
688 capitalsComboBox->setCurrentIndex(0);
689 positionComboBox->setCurrentIndex(0);
690 numeralComboBox->setCurrentIndex(0);
691 widthComboBox->setCurrentIndex(0);
692 fractionComboBox->setCurrentIndex(0);
693 SlashedZeroCheck->setChecked(false);
694
695 for (int i=0; i < styleSetsMenu->actions().count(); i++)
696 styleSetsMenu->actions().at(i)->setChecked(false);
697 connectSignals();
698 }
699