Charlie Jiang pushed to branch reorg-maingui at FreeType / FreeType Demo Programs
Commits:
-
5f380ae9
by Charlie Jiang at 2022-07-01T14:18:58+08:00
8 changed files:
- src/ftinspect/CMakeLists.txt
- src/ftinspect/engine/engine.cpp
- src/ftinspect/engine/engine.hpp
- src/ftinspect/maingui.cpp
- src/ftinspect/maingui.hpp
- src/ftinspect/meson.build
- + src/ftinspect/models/ttsettingscomboboxmodel.cpp
- + src/ftinspect/models/ttsettingscomboboxmodel.hpp
Changes:
... | ... | @@ -32,6 +32,8 @@ add_executable(ftinspect |
32 | 32 | "widgets/qgraphicsviewx.cpp"
|
33 | 33 | "widgets/qpushbuttonx.cpp"
|
34 | 34 | "widgets/qspinboxx.cpp"
|
35 | + |
|
36 | + "models/ttsettingscomboboxmodel.cpp"
|
|
35 | 37 | )
|
36 | 38 | target_link_libraries(ftinspect
|
37 | 39 | Qt5::Core Qt5::Widgets
|
... | ... | @@ -464,40 +464,15 @@ Engine::update() |
464 | 464 | |
465 | 465 | if (doHinting_)
|
466 | 466 | {
|
467 | - unsigned long target;
|
|
468 | - |
|
469 | - if (antiAliasingMode_ == AntiAliasing_None)
|
|
470 | - target = FT_LOAD_TARGET_MONO;
|
|
471 | - else
|
|
472 | - {
|
|
473 | - switch (antiAliasingMode_)
|
|
474 | - {
|
|
475 | - case AntiAliasing_Light:
|
|
476 | - target = FT_LOAD_TARGET_LIGHT;
|
|
477 | - break;
|
|
478 | - |
|
479 | - case AntiAliasing_LCD:
|
|
480 | - case AntiAliasing_LCD_BGR: // TODO Differenate RGB/BGR here?
|
|
481 | - target = FT_LOAD_TARGET_LCD;
|
|
482 | - break;
|
|
483 | - |
|
484 | - case AntiAliasing_LCD_Vertical:
|
|
485 | - case AntiAliasing_LCD_Vertical_BGR:
|
|
486 | - target = FT_LOAD_TARGET_LCD_V;
|
|
487 | - break;
|
|
488 | - |
|
489 | - default:
|
|
490 | - target = FT_LOAD_TARGET_NORMAL;
|
|
491 | - }
|
|
492 | - }
|
|
493 | - |
|
467 | + // TODO Differentiate RGB/BGR here?
|
|
468 | + unsigned long target = antiAliasingTarget_;
|
|
494 | 469 | loadFlags_ |= target;
|
495 | 470 | }
|
496 | 471 | else
|
497 | 472 | {
|
498 | 473 | loadFlags_ |= FT_LOAD_NO_HINTING;
|
499 | 474 | |
500 | - if (antiAliasingMode_ == AntiAliasing_None)
|
|
475 | + if (antiAliasingTarget_ | FT_LOAD_TARGET_MONO) // XXX does this hold?
|
|
501 | 476 | loadFlags_ |= FT_LOAD_MONOCHROME;
|
502 | 477 | }
|
503 | 478 |
... | ... | @@ -42,9 +42,6 @@ class Engine |
42 | 42 | {
|
43 | 43 | public:
|
44 | 44 | //////// Nested definitions (forward decl)
|
45 | - |
|
46 | - // TODO these would be dropped with custom QAbstractItemModel
|
|
47 | - enum AntiAliasing : int;
|
|
48 | 45 | enum FontType : int;
|
49 | 46 | |
50 | 47 | struct EngineDefaultValues
|
... | ... | @@ -117,7 +114,7 @@ public: |
117 | 114 | }
|
118 | 115 | void setShowSegments(bool showSegments) { showSegments_ = showSegments; }
|
119 | 116 | void setGamma(double gamma) { gamma_ = gamma; }
|
120 | - void setAntiAliasingMode(AntiAliasing mode) { antiAliasingMode_ = mode; }
|
|
117 | + void setAntiAliasingTarget(int target) { antiAliasingTarget_ = target; }
|
|
121 | 118 | |
122 | 119 | // Note: These 3 functions now takes actual mode/version from FreeType,
|
123 | 120 | // instead of values from enum in MainGUI!
|
... | ... | @@ -165,7 +162,7 @@ private: |
165 | 162 | bool doVerticalHinting_;
|
166 | 163 | bool doBlueZoneHinting_;
|
167 | 164 | bool showSegments_;
|
168 | - AntiAliasing antiAliasingMode_;
|
|
165 | + int antiAliasingTarget_;
|
|
169 | 166 | |
170 | 167 | double gamma_;
|
171 | 168 | |
... | ... | @@ -176,17 +173,6 @@ private: |
176 | 173 | public:
|
177 | 174 | |
178 | 175 | /// Actual definition
|
179 | -
|
|
180 | - enum AntiAliasing
|
|
181 | - {
|
|
182 | - AntiAliasing_None,
|
|
183 | - AntiAliasing_Normal,
|
|
184 | - AntiAliasing_Light,
|
|
185 | - AntiAliasing_LCD,
|
|
186 | - AntiAliasing_LCD_BGR,
|
|
187 | - AntiAliasing_LCD_Vertical,
|
|
188 | - AntiAliasing_LCD_Vertical_BGR
|
|
189 | - };
|
|
190 | 176 | |
191 | 177 | // XXX cover all available modules
|
192 | 178 | enum FontType
|
... | ... | @@ -230,8 +230,8 @@ MainGUI::syncSettings() |
230 | 230 | |
231 | 231 | engine_->setGamma(gammaSlider_->value());
|
232 | 232 | |
233 | - engine_->setAntiAliasingMode(static_cast<Engine::AntiAliasing>(
|
|
234 | - antiAliasingComboBoxx_->currentIndex()));
|
|
233 | + engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
|
|
234 | + antiAliasingComboBox_->currentIndex()));
|
|
235 | 235 | }
|
236 | 236 | |
237 | 237 | |
... | ... | @@ -250,45 +250,29 @@ MainGUI::checkHinting() |
250 | 250 | {
|
251 | 251 | if (engine_->currentFontType() == Engine::FontType_CFF)
|
252 | 252 | {
|
253 | - for (int i = 0; i < hintingModeComboBoxx_->count(); i++)
|
|
254 | - {
|
|
255 | - if (hintingModesCFFHash_.key(i, -1) != -1)
|
|
256 | - hintingModeComboBoxx_->setItemEnabled(i, true);
|
|
257 | - else
|
|
258 | - hintingModeComboBoxx_->setItemEnabled(i, false);
|
|
259 | - }
|
|
260 | - |
|
261 | - hintingModeComboBoxx_->setCurrentIndex(currentCFFHintingMode_);
|
|
253 | + hintingModeComboBoxModel_->setCurrentEngineType(
|
|
254 | + HintingModeComboBoxModel::HintingEngineType_CFF);
|
|
255 | + hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
|
|
262 | 256 | }
|
263 | 257 | else if (engine_->currentFontType() == Engine::FontType_TrueType)
|
264 | 258 | {
|
265 | - for (int i = 0; i < hintingModeComboBoxx_->count(); i++)
|
|
266 | - {
|
|
267 | - if (hintingModesTrueTypeHash_.key(i, -1) != -1)
|
|
268 | - hintingModeComboBoxx_->setItemEnabled(i, true);
|
|
269 | - else
|
|
270 | - hintingModeComboBoxx_->setItemEnabled(i, false);
|
|
271 | - }
|
|
272 | - |
|
273 | - hintingModeComboBoxx_->setCurrentIndex(currentTTInterpreterVersion_);
|
|
259 | + hintingModeComboBoxModel_->setCurrentEngineType(
|
|
260 | + HintingModeComboBoxModel::HintingEngineType_TrueType);
|
|
261 | + hintingModeComboBox_->setCurrentIndex(currentTTInterpreterVersion_);
|
|
274 | 262 | }
|
275 | 263 | else
|
276 | 264 | {
|
277 | 265 | hintingModeLabel_->setEnabled(false);
|
278 | - hintingModeComboBoxx_->setEnabled(false);
|
|
266 | + hintingModeComboBox_->setEnabled(false);
|
|
279 | 267 | }
|
280 | 268 | |
281 | - for (int i = 0; i < hintingModesAlwaysDisabled_.size(); i++)
|
|
282 | - hintingModeComboBoxx_->setItemEnabled(hintingModesAlwaysDisabled_[i],
|
|
283 | - false);
|
|
284 | - |
|
285 | 269 | autoHintingCheckBox_->setEnabled(true);
|
286 | 270 | checkAutoHinting();
|
287 | 271 | }
|
288 | 272 | else
|
289 | 273 | {
|
290 | 274 | hintingModeLabel_->setEnabled(false);
|
291 | - hintingModeComboBoxx_->setEnabled(false);
|
|
275 | + hintingModeComboBox_->setEnabled(false);
|
|
292 | 276 | |
293 | 277 | autoHintingCheckBox_->setEnabled(false);
|
294 | 278 | horizontalHintingCheckBox_->setEnabled(false);
|
... | ... | @@ -296,7 +280,11 @@ MainGUI::checkHinting() |
296 | 280 | blueZoneHintingCheckBox_->setEnabled(false);
|
297 | 281 | segmentDrawingCheckBox_->setEnabled(false);
|
298 | 282 | |
299 | - antiAliasingComboBoxx_->setItemEnabled(Engine::AntiAliasing_Light, false);
|
|
283 | + antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
|
|
284 | + if (antiAliasingComboBox_->currentIndex()
|
|
285 | + == AntiAliasingComboBoxModel::AntiAliasing_Light)
|
|
286 | + antiAliasingComboBox_->setCurrentIndex(
|
|
287 | + AntiAliasingComboBoxModel::AntiAliasing_Normal);
|
|
300 | 288 | }
|
301 | 289 | |
302 | 290 | drawGlyph();
|
... | ... | @@ -306,16 +294,18 @@ MainGUI::checkHinting() |
306 | 294 | void
|
307 | 295 | MainGUI::checkHintingMode()
|
308 | 296 | {
|
309 | - int index = hintingModeComboBoxx_->currentIndex();
|
|
297 | + int index = hintingModeComboBox_->currentIndex();
|
|
310 | 298 | |
311 | 299 | if (engine_->currentFontType() == Engine::FontType_CFF)
|
312 | 300 | {
|
313 | - engine_->setCFFHintingMode(hintingModesCFFHash_.key(index));
|
|
301 | + engine_->setCFFHintingMode(
|
|
302 | + hintingModeComboBoxModel_->indexToCFFMode(index));
|
|
314 | 303 | currentCFFHintingMode_ = index;
|
315 | 304 | }
|
316 | 305 | else if (engine_->currentFontType() == Engine::FontType_TrueType)
|
317 | 306 | {
|
318 | - engine_->setTTInterpreterVersion(hintingModesTrueTypeHash_.key(index));
|
|
307 | + engine_->setTTInterpreterVersion(
|
|
308 | + hintingModeComboBoxModel_->indexToTTInterpreterVersion(index));
|
|
319 | 309 | currentTTInterpreterVersion_ = index;
|
320 | 310 | }
|
321 | 311 | |
... | ... | @@ -330,14 +320,14 @@ MainGUI::checkAutoHinting() |
330 | 320 | if (autoHintingCheckBox_->isChecked())
|
331 | 321 | {
|
332 | 322 | hintingModeLabel_->setEnabled(false);
|
333 | - hintingModeComboBoxx_->setEnabled(false);
|
|
323 | + hintingModeComboBox_->setEnabled(false);
|
|
334 | 324 | |
335 | 325 | horizontalHintingCheckBox_->setEnabled(true);
|
336 | 326 | verticalHintingCheckBox_->setEnabled(true);
|
337 | 327 | blueZoneHintingCheckBox_->setEnabled(true);
|
338 | 328 | segmentDrawingCheckBox_->setEnabled(true);
|
339 | 329 | |
340 | - antiAliasingComboBoxx_->setItemEnabled(Engine::AntiAliasing_Light, true);
|
|
330 | + antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
|
|
341 | 331 | }
|
342 | 332 | else
|
343 | 333 | {
|
... | ... | @@ -345,7 +335,7 @@ MainGUI::checkAutoHinting() |
345 | 335 | || engine_->currentFontType() == Engine::FontType_TrueType)
|
346 | 336 | {
|
347 | 337 | hintingModeLabel_->setEnabled(true);
|
348 | - hintingModeComboBoxx_->setEnabled(true);
|
|
338 | + hintingModeComboBox_->setEnabled(true);
|
|
349 | 339 | }
|
350 | 340 | |
351 | 341 | horizontalHintingCheckBox_->setEnabled(false);
|
... | ... | @@ -353,10 +343,12 @@ MainGUI::checkAutoHinting() |
353 | 343 | blueZoneHintingCheckBox_->setEnabled(false);
|
354 | 344 | segmentDrawingCheckBox_->setEnabled(false);
|
355 | 345 | |
356 | - antiAliasingComboBoxx_->setItemEnabled(Engine::AntiAliasing_Light, false);
|
|
346 | + antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
|
|
357 | 347 | |
358 | - if (antiAliasingComboBoxx_->currentIndex() == Engine::AntiAliasing_Light)
|
|
359 | - antiAliasingComboBoxx_->setCurrentIndex(Engine::AntiAliasing_Normal);
|
|
348 | + if (antiAliasingComboBox_->currentIndex()
|
|
349 | + == AntiAliasingComboBoxModel::AntiAliasing_Light)
|
|
350 | + antiAliasingComboBox_->setCurrentIndex(
|
|
351 | + AntiAliasingComboBoxModel::AntiAliasing_Normal);
|
|
360 | 352 | }
|
361 | 353 | |
362 | 354 | drawGlyph();
|
... | ... | @@ -366,11 +358,11 @@ MainGUI::checkAutoHinting() |
366 | 358 | void
|
367 | 359 | MainGUI::checkAntiAliasing()
|
368 | 360 | {
|
369 | - int index = antiAliasingComboBoxx_->currentIndex();
|
|
361 | + int index = antiAliasingComboBox_->currentIndex();
|
|
370 | 362 | |
371 | - if (index == Engine::AntiAliasing_None
|
|
372 | - || index == Engine::AntiAliasing::AntiAliasing_Normal
|
|
373 | - || index == Engine::AntiAliasing_Light)
|
|
363 | + if (index == AntiAliasingComboBoxModel::AntiAliasing_None
|
|
364 | + || index == AntiAliasingComboBoxModel::AntiAliasing::AntiAliasing_Normal
|
|
365 | + || index == AntiAliasingComboBoxModel::AntiAliasing_Light)
|
|
374 | 366 | {
|
375 | 367 | lcdFilterLabel_->setEnabled(false);
|
376 | 368 | lcdFilterComboBox_->setEnabled(false);
|
... | ... | @@ -389,7 +381,8 @@ void |
389 | 381 | MainGUI::checkLcdFilter()
|
390 | 382 | {
|
391 | 383 | int index = lcdFilterComboBox_->currentIndex();
|
392 | - engine_->setLcdFilter(lcdFilterHash_.key(index));
|
|
384 | + engine_->setLcdFilter(static_cast<FT_LcdFilter>(
|
|
385 | + lcdFilterComboboxModel_->indexToValue(index)));
|
|
393 | 386 | }
|
394 | 387 | |
395 | 388 | |
... | ... | @@ -696,7 +689,8 @@ MainGUI::drawGlyph() |
696 | 689 | {
|
697 | 690 | // XXX support LCD
|
698 | 691 | FT_Pixel_Mode pixelMode = FT_PIXEL_MODE_GRAY;
|
699 | - if (antiAliasingComboBoxx_->currentIndex() == Engine::AntiAliasing_None)
|
|
692 | + if (antiAliasingComboBox_->currentIndex()
|
|
693 | + == AntiAliasingComboBoxModel::AntiAliasing_None)
|
|
700 | 694 | pixelMode = FT_PIXEL_MODE_MONO;
|
701 | 695 | |
702 | 696 | currentGlyphBitmapItem_ = new GlyphBitmap(outline,
|
... | ... | @@ -744,18 +738,11 @@ MainGUI::createLayout() |
744 | 738 | |
745 | 739 | hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
|
746 | 740 | hintingModeLabel_->setAlignment(Qt::AlignRight);
|
747 | - hintingModeComboBoxx_ = new QComboBoxx;
|
|
748 | - hintingModeComboBoxx_->insertItem(HintingMode_TrueType_v35,
|
|
749 | - tr("TrueType v35"));
|
|
750 | - hintingModeComboBoxx_->insertItem(HintingMode_TrueType_v38,
|
|
751 | - tr("TrueType v38"));
|
|
752 | - hintingModeComboBoxx_->insertItem(HintingMode_TrueType_v40,
|
|
753 | - tr("TrueType v40"));
|
|
754 | - hintingModeComboBoxx_->insertItem(HintingMode_CFF_FreeType,
|
|
755 | - tr("CFF (FreeType)"));
|
|
756 | - hintingModeComboBoxx_->insertItem(HintingMode_CFF_Adobe,
|
|
757 | - tr("CFF (Adobe)"));
|
|
758 | - hintingModeLabel_->setBuddy(hintingModeComboBoxx_);
|
|
741 | + |
|
742 | + hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
|
|
743 | + hintingModeComboBox_ = new QComboBox;
|
|
744 | + hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
|
|
745 | + hintingModeLabel_->setBuddy(hintingModeComboBox_);
|
|
759 | 746 | |
760 | 747 | autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
|
761 | 748 | horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
|
... | ... | @@ -765,30 +752,18 @@ MainGUI::createLayout() |
765 | 752 | |
766 | 753 | antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
|
767 | 754 | antiAliasingLabel_->setAlignment(Qt::AlignRight);
|
768 | - antiAliasingComboBoxx_ = new QComboBoxx;
|
|
769 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_None,
|
|
770 | - tr("None"));
|
|
771 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_Normal,
|
|
772 | - tr("Normal"));
|
|
773 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_Light,
|
|
774 | - tr("Light"));
|
|
775 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_LCD,
|
|
776 | - tr("LCD (RGB)"));
|
|
777 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_LCD_BGR,
|
|
778 | - tr("LCD (BGR)"));
|
|
779 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_LCD_Vertical,
|
|
780 | - tr("LCD (vert. RGB)"));
|
|
781 | - antiAliasingComboBoxx_->insertItem(Engine::AntiAliasing_LCD_Vertical_BGR,
|
|
782 | - tr("LCD (vert. BGR)"));
|
|
783 | - antiAliasingLabel_->setBuddy(antiAliasingComboBoxx_);
|
|
755 | + |
|
756 | + antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
|
|
757 | + antiAliasingComboBox_ = new QComboBox;
|
|
758 | + antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
|
|
759 | + antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
|
|
784 | 760 | |
785 | 761 | lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
|
786 | 762 | lcdFilterLabel_->setAlignment(Qt::AlignRight);
|
763 | + |
|
764 | + lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
|
|
787 | 765 | lcdFilterComboBox_ = new QComboBox;
|
788 | - lcdFilterComboBox_->insertItem(LCDFilter_Default, tr("Default"));
|
|
789 | - lcdFilterComboBox_->insertItem(LCDFilter_Light, tr("Light"));
|
|
790 | - lcdFilterComboBox_->insertItem(LCDFilter_None, tr("None"));
|
|
791 | - lcdFilterComboBox_->insertItem(LCDFilter_Legacy, tr("Legacy"));
|
|
766 | + lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
|
|
792 | 767 | lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
|
793 | 768 | |
794 | 769 | int width;
|
... | ... | @@ -802,11 +777,11 @@ MainGUI::createLayout() |
802 | 777 | |
803 | 778 | // ensure that all items in combo boxes fit completely;
|
804 | 779 | // also make all combo boxes have the same width
|
805 | - width = hintingModeComboBoxx_->minimumSizeHint().width();
|
|
806 | - width = qMax(antiAliasingComboBoxx_->minimumSizeHint().width(), width);
|
|
780 | + width = hintingModeComboBox_->minimumSizeHint().width();
|
|
781 | + width = qMax(antiAliasingComboBox_->minimumSizeHint().width(), width);
|
|
807 | 782 | width = qMax(lcdFilterComboBox_->minimumSizeHint().width(), width);
|
808 | - hintingModeComboBoxx_->setMinimumWidth(width);
|
|
809 | - antiAliasingComboBoxx_->setMinimumWidth(width);
|
|
783 | + hintingModeComboBox_->setMinimumWidth(width);
|
|
784 | + antiAliasingComboBox_->setMinimumWidth(width);
|
|
810 | 785 | lcdFilterComboBox_->setMinimumWidth(width);
|
811 | 786 | |
812 | 787 | gammaLabel_ = new QLabel(tr("Gamma"));
|
... | ... | @@ -827,7 +802,7 @@ MainGUI::createLayout() |
827 | 802 | |
828 | 803 | hintingModeLayout_ = new QHBoxLayout;
|
829 | 804 | hintingModeLayout_->addWidget(hintingModeLabel_);
|
830 | - hintingModeLayout_->addWidget(hintingModeComboBoxx_);
|
|
805 | + hintingModeLayout_->addWidget(hintingModeComboBox_);
|
|
831 | 806 | |
832 | 807 | horizontalHintingLayout_ = new QHBoxLayout;
|
833 | 808 | horizontalHintingLayout_->addSpacing(20); // XXX px
|
... | ... | @@ -847,7 +822,7 @@ MainGUI::createLayout() |
847 | 822 | |
848 | 823 | antiAliasingLayout_ = new QHBoxLayout;
|
849 | 824 | antiAliasingLayout_->addWidget(antiAliasingLabel_);
|
850 | - antiAliasingLayout_->addWidget(antiAliasingComboBoxx_);
|
|
825 | + antiAliasingLayout_->addWidget(antiAliasingComboBox_);
|
|
851 | 826 | |
852 | 827 | lcdFilterLayout_ = new QHBoxLayout;
|
853 | 828 | lcdFilterLayout_->addWidget(lcdFilterLabel_);
|
... | ... | @@ -1051,9 +1026,9 @@ MainGUI::createConnections() |
1051 | 1026 | connect(hintingCheckBox_, SIGNAL(clicked()),
|
1052 | 1027 | SLOT(checkHinting()));
|
1053 | 1028 | |
1054 | - connect(hintingModeComboBoxx_, SIGNAL(currentIndexChanged(int)),
|
|
1029 | + connect(hintingModeComboBox_, SIGNAL(currentIndexChanged(int)),
|
|
1055 | 1030 | SLOT(checkHintingMode()));
|
1056 | - connect(antiAliasingComboBoxx_, SIGNAL(currentIndexChanged(int)),
|
|
1031 | + connect(antiAliasingComboBox_, SIGNAL(currentIndexChanged(int)),
|
|
1057 | 1032 | SLOT(checkAntiAliasing()));
|
1058 | 1033 | connect(lcdFilterComboBox_, SIGNAL(currentIndexChanged(int)),
|
1059 | 1034 | SLOT(checkLcdFilter()));
|
... | ... | @@ -1177,43 +1152,14 @@ MainGUI::createStatusBar() |
1177 | 1152 | void
|
1178 | 1153 | MainGUI::setDefaults()
|
1179 | 1154 | {
|
1180 | - // set up mappings between property values and combo box indices
|
|
1181 | - hintingModesTrueTypeHash_[TT_INTERPRETER_VERSION_35] = HintingMode_TrueType_v35;
|
|
1182 | - hintingModesTrueTypeHash_[TT_INTERPRETER_VERSION_38] = HintingMode_TrueType_v38;
|
|
1183 | - hintingModesTrueTypeHash_[TT_INTERPRETER_VERSION_40] = HintingMode_TrueType_v40;
|
|
1184 | - |
|
1185 | - hintingModesCFFHash_[FT_HINTING_FREETYPE] = HintingMode_CFF_FreeType;
|
|
1186 | - hintingModesCFFHash_[FT_HINTING_ADOBE] = HintingMode_CFF_Adobe;
|
|
1187 | - |
|
1188 | - lcdFilterHash_[FT_LCD_FILTER_DEFAULT] = LCDFilter_Default;
|
|
1189 | - lcdFilterHash_[FT_LCD_FILTER_LIGHT] = LCDFilter_Light;
|
|
1190 | - lcdFilterHash_[FT_LCD_FILTER_NONE] = LCDFilter_None;
|
|
1191 | - lcdFilterHash_[FT_LCD_FILTER_LEGACY] = LCDFilter_Legacy;
|
|
1192 | - |
|
1193 | 1155 | Engine::EngineDefaultValues& defaults = engine_->engineDefaults();
|
1194 | 1156 | |
1195 | - // make copies and remove existing elements...
|
|
1196 | - QHash<int, int> hmTTHash = hintingModesTrueTypeHash_;
|
|
1197 | - if (hmTTHash.contains(defaults.ttInterpreterVersionDefault))
|
|
1198 | - hmTTHash.remove(defaults.ttInterpreterVersionDefault);
|
|
1199 | - if (hmTTHash.contains(defaults.ttInterpreterVersionOther))
|
|
1200 | - hmTTHash.remove(defaults.ttInterpreterVersionOther);
|
|
1201 | - if (hmTTHash.contains(defaults.ttInterpreterVersionOther1))
|
|
1202 | - hmTTHash.remove(defaults.ttInterpreterVersionOther1);
|
|
1203 | - |
|
1204 | - QHash<int, int> hmCFFHash = hintingModesCFFHash_;
|
|
1205 | - if (hmCFFHash.contains(defaults.cffHintingEngineDefault))
|
|
1206 | - hmCFFHash.remove(defaults.cffHintingEngineDefault);
|
|
1207 | - if (hmCFFHash.contains(defaults.cffHintingEngineOther))
|
|
1208 | - hmCFFHash.remove(defaults.cffHintingEngineOther);
|
|
1209 | - |
|
1210 | - // ... to construct a list of always disabled hinting mode combo box items
|
|
1211 | - hintingModesAlwaysDisabled_ = hmTTHash.values();
|
|
1212 | - hintingModesAlwaysDisabled_ += hmCFFHash.values();
|
|
1213 | - |
|
1214 | - for (int i = 0; i < hintingModesAlwaysDisabled_.size(); i++)
|
|
1215 | - hintingModeComboBoxx_->setItemEnabled(hintingModesAlwaysDisabled_[i],
|
|
1216 | - false);
|
|
1157 | + hintingModeComboBoxModel_->setSupportedModes(
|
|
1158 | + { defaults.ttInterpreterVersionDefault,
|
|
1159 | + defaults.ttInterpreterVersionOther,
|
|
1160 | + defaults.ttInterpreterVersionOther1 },
|
|
1161 | + { defaults.cffHintingEngineDefault,
|
|
1162 | + defaults.cffHintingEngineOther });
|
|
1217 | 1163 | |
1218 | 1164 | // the next four values always non-negative
|
1219 | 1165 | currentFontIndex_ = 0;
|
... | ... | @@ -1222,14 +1168,18 @@ MainGUI::setDefaults() |
1222 | 1168 | currentGlyphIndex_ = 0;
|
1223 | 1169 | |
1224 | 1170 | currentCFFHintingMode_
|
1225 | - = hintingModesCFFHash_[defaults.cffHintingEngineDefault];
|
|
1171 | + = hintingModeComboBoxModel_->cffModeToIndex(
|
|
1172 | + defaults.cffHintingEngineDefault);
|
|
1226 | 1173 | currentTTInterpreterVersion_
|
1227 | - = hintingModesTrueTypeHash_[defaults.ttInterpreterVersionDefault];
|
|
1174 | + = hintingModeComboBoxModel_->ttInterpreterVersionToIndex(
|
|
1175 | + defaults.ttInterpreterVersionDefault);
|
|
1228 | 1176 | |
1229 | 1177 | hintingCheckBox_->setChecked(true);
|
1230 | 1178 | |
1231 | - antiAliasingComboBoxx_->setCurrentIndex(Engine::AntiAliasing_Normal);
|
|
1232 | - lcdFilterComboBox_->setCurrentIndex(LCDFilter_Light);
|
|
1179 | + antiAliasingComboBox_->setCurrentIndex(
|
|
1180 | + AntiAliasingComboBoxModel::AntiAliasing_Normal);
|
|
1181 | + lcdFilterComboBox_->setCurrentIndex(
|
|
1182 | + LCDFilterComboBoxModel::LCDFilter_Light);
|
|
1233 | 1183 | |
1234 | 1184 | horizontalHintingCheckBox_->setChecked(true);
|
1235 | 1185 | verticalHintingCheckBox_->setChecked(true);
|
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 | #include "widgets/qgraphicsviewx.hpp"
|
15 | 15 | #include "widgets/qpushbuttonx.hpp"
|
16 | 16 | #include "widgets/qspinboxx.hpp"
|
17 | +#include "models/ttsettingscomboboxmodel.hpp"
|
|
17 | 18 | |
18 | 19 | #include <QAction>
|
19 | 20 | #include <QCheckBox>
|
... | ... | @@ -133,8 +134,12 @@ private: |
133 | 134 | QCheckBox *showPointsCheckBox_;
|
134 | 135 | QCheckBox *verticalHintingCheckBox_;
|
135 | 136 | |
136 | - QComboBoxx *antiAliasingComboBoxx_;
|
|
137 | - QComboBoxx *hintingModeComboBoxx_;
|
|
137 | + AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
|
|
138 | + HintingModeComboBoxModel* hintingModeComboBoxModel_;
|
|
139 | + LCDFilterComboBoxModel* lcdFilterComboboxModel_;
|
|
140 | + |
|
141 | + QComboBox *antiAliasingComboBox_;
|
|
142 | + QComboBox *hintingModeComboBox_;
|
|
138 | 143 | QComboBox *lcdFilterComboBox_;
|
139 | 144 | QComboBox *unitsComboBox_;
|
140 | 145 | |
... | ... | @@ -146,10 +151,6 @@ private: |
146 | 151 | QGridLayout *fontLayout;
|
147 | 152 | QGridLayout *infoRightLayout;
|
148 | 153 | |
149 | - QHash<int, int> hintingModesTrueTypeHash_;
|
|
150 | - QHash<int, int> hintingModesCFFHash_;
|
|
151 | - QHash<FT_LcdFilter, int> lcdFilterHash_;
|
|
152 | - |
|
153 | 154 | QHBoxLayout *antiAliasingLayout_;
|
154 | 155 | QHBoxLayout *blueZoneHintingLayout_;
|
155 | 156 | QHBoxLayout *ftinspectLayout_;
|
... | ... | @@ -176,8 +177,6 @@ private: |
176 | 177 | QLabel *sizeLabel_;
|
177 | 178 | QLabel *zoomLabel_;
|
178 | 179 | |
179 | - QList<int> hintingModesAlwaysDisabled_;
|
|
180 | - |
|
181 | 180 | QLocale *locale_;
|
182 | 181 | |
183 | 182 | QMenu *menuFile_;
|
... | ... | @@ -230,22 +229,7 @@ private: |
230 | 229 | QWidget *leftWidget_;
|
231 | 230 | QWidget *rightWidget_;
|
232 | 231 | QWidget *mmgxTabWidget_;
|
233 | -
|
|
234 | - enum HintingMode
|
|
235 | - {
|
|
236 | - HintingMode_TrueType_v35,
|
|
237 | - HintingMode_TrueType_v38,
|
|
238 | - HintingMode_TrueType_v40,
|
|
239 | - HintingMode_CFF_FreeType,
|
|
240 | - HintingMode_CFF_Adobe
|
|
241 | - };
|
|
242 | - enum LCDFilter
|
|
243 | - {
|
|
244 | - LCDFilter_Default,
|
|
245 | - LCDFilter_Light,
|
|
246 | - LCDFilter_None,
|
|
247 | - LCDFilter_Legacy
|
|
248 | - };
|
|
232 | + |
|
249 | 233 | enum Units
|
250 | 234 | {
|
251 | 235 | Units_px,
|
... | ... | @@ -34,9 +34,11 @@ if qt5_dep.found() |
34 | 34 | 'widgets/qpushbuttonx.cpp',
|
35 | 35 | 'widgets/qspinboxx.cpp',
|
36 | 36 | |
37 | + 'models/ttsettingscomboboxmodel.cpp',
|
|
38 | + |
|
37 | 39 | 'ftinspect.cpp',
|
38 | 40 | 'maingui.cpp',
|
39 | - ])
|
|
41 | +])
|
|
40 | 42 | |
41 | 43 | moc_files = qt5.preprocess(
|
42 | 44 | moc_headers: [
|
... | ... | @@ -45,6 +47,7 @@ if qt5_dep.found() |
45 | 47 | 'widgets/qpushbuttonx.hpp',
|
46 | 48 | 'widgets/qspinboxx.hpp',
|
47 | 49 | 'maingui.hpp',
|
50 | + 'models/ttsettingscomboboxmodel.cpp',
|
|
48 | 51 | ],
|
49 | 52 | dependencies: qt5_dep)
|
50 | 53 |
1 | +// ttsettingscomboboxmodel.cpp
|
|
2 | + |
|
3 | +// Copyright (C) 2022 by Charlie Jiang.
|
|
4 | + |
|
5 | + |
|
6 | +#include "ttsettingscomboboxmodel.hpp"
|
|
7 | + |
|
8 | +#include <QApplication>
|
|
9 | +#include <QPalette>
|
|
10 | +#include <freetype/ftdriver.h>
|
|
11 | +#include <freetype/ftlcdfil.h>
|
|
12 | + |
|
13 | + |
|
14 | +/////////////////////////////////////////////////////////////////////////////
|
|
15 | +//
|
|
16 | +// HintingModeComboBoxModel
|
|
17 | +//
|
|
18 | +/////////////////////////////////////////////////////////////////////////////
|
|
19 | + |
|
20 | +HintingModeComboBoxModel::HintingModeComboBoxModel()
|
|
21 | +{
|
|
22 | + items_[HintingMode_TrueType_v35] = {
|
|
23 | + HintingEngineType_TrueType,
|
|
24 | + HintingMode_TrueType_v35,
|
|
25 | + TT_INTERPRETER_VERSION_35,
|
|
26 | + false, false,
|
|
27 | + "TrueType v35"
|
|
28 | + };
|
|
29 | + items_[HintingMode_TrueType_v38] = {
|
|
30 | + HintingEngineType_TrueType,
|
|
31 | + HintingMode_TrueType_v38,
|
|
32 | + TT_INTERPRETER_VERSION_38,
|
|
33 | + false, false,
|
|
34 | + "TrueType v38"
|
|
35 | + };
|
|
36 | + items_[HintingMode_TrueType_v40] = {
|
|
37 | + HintingEngineType_TrueType,
|
|
38 | + HintingMode_TrueType_v40,
|
|
39 | + TT_INTERPRETER_VERSION_40,
|
|
40 | + false, false,
|
|
41 | + "TrueType v40"
|
|
42 | + };
|
|
43 | + |
|
44 | + items_[HintingMode_CFF_FreeType] = {
|
|
45 | + HintingEngineType_CFF,
|
|
46 | + HintingMode_CFF_FreeType,
|
|
47 | + FT_HINTING_FREETYPE,
|
|
48 | + false, false,
|
|
49 | + "CFF (FreeType)"
|
|
50 | + };
|
|
51 | + items_[HintingMode_CFF_Adobe] = {
|
|
52 | + HintingEngineType_CFF,
|
|
53 | + HintingMode_CFF_Adobe,
|
|
54 | + FT_HINTING_ADOBE,
|
|
55 | + false, false,
|
|
56 | + "CFF (Adobe)"
|
|
57 | + };
|
|
58 | +}
|
|
59 | + |
|
60 | + |
|
61 | +int
|
|
62 | +HintingModeComboBoxModel::rowCount(const QModelIndex& parent) const
|
|
63 | +{
|
|
64 | + return items_.size();
|
|
65 | +}
|
|
66 | + |
|
67 | + |
|
68 | +QVariant
|
|
69 | +HintingModeComboBoxModel::data(const QModelIndex& index,
|
|
70 | + int role) const
|
|
71 | +{
|
|
72 | + int r = index.row();
|
|
73 | + if (r < 0 || r >= items_.size())
|
|
74 | + return QVariant {};
|
|
75 | + HintingModeItem const& item = items_[r];
|
|
76 | + |
|
77 | + switch (role)
|
|
78 | + {
|
|
79 | + case Qt::DisplayRole:
|
|
80 | + return item.displayName;
|
|
81 | + case Qt::ForegroundRole:
|
|
82 | + if (item.enabled && item.supported)
|
|
83 | + return QVariant {};
|
|
84 | + else
|
|
85 | + return QApplication::palette().color(QPalette::Disabled,
|
|
86 | + QPalette::Text);
|
|
87 | + default:
|
|
88 | + return QVariant {};
|
|
89 | + }
|
|
90 | +}
|
|
91 | + |
|
92 | + |
|
93 | +Qt::ItemFlags
|
|
94 | +HintingModeComboBoxModel::flags(const QModelIndex& index) const
|
|
95 | +{
|
|
96 | + int r = index.row();
|
|
97 | + if (r < 0 || r >= items_.size())
|
|
98 | + return Qt::ItemFlags {}; // not selectable, not enabled
|
|
99 | + HintingModeItem const& item = items_[r];
|
|
100 | + |
|
101 | + if (item.enabled && item.supported)
|
|
102 | + return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
103 | + |
|
104 | + return Qt::ItemFlags {};
|
|
105 | +}
|
|
106 | + |
|
107 | + |
|
108 | +int
|
|
109 | +HintingModeComboBoxModel::indexToValueForType(int index,
|
|
110 | + HintingEngineType type) const
|
|
111 | +{
|
|
112 | + if (index < 0 || index >= items_.size())
|
|
113 | + return -1;
|
|
114 | + HintingModeItem const& item = items_[index];
|
|
115 | + if (!item.supported || !item.enabled || item.type != type)
|
|
116 | + return -1;
|
|
117 | + return item.value;
|
|
118 | +}
|
|
119 | + |
|
120 | + |
|
121 | +int
|
|
122 | +HintingModeComboBoxModel::valueToIndexForType(int value,
|
|
123 | + HintingEngineType type) const
|
|
124 | +{
|
|
125 | + for (auto it = items_.begin();
|
|
126 | + it != items_.end();
|
|
127 | + ++it)
|
|
128 | + {
|
|
129 | + if (it->type == type && it->value == value)
|
|
130 | + return it->key;
|
|
131 | + }
|
|
132 | + return -1;
|
|
133 | +}
|
|
134 | + |
|
135 | + |
|
136 | +int
|
|
137 | +HintingModeComboBoxModel::indexToTTInterpreterVersion(int index) const
|
|
138 | +{
|
|
139 | + return indexToValueForType(index, HintingEngineType_TrueType);
|
|
140 | +}
|
|
141 | + |
|
142 | + |
|
143 | +int
|
|
144 | +HintingModeComboBoxModel::indexToCFFMode(int index) const
|
|
145 | +{
|
|
146 | + return indexToValueForType(index, HintingEngineType_CFF);
|
|
147 | +}
|
|
148 | + |
|
149 | + |
|
150 | +int
|
|
151 | +HintingModeComboBoxModel::cffModeToIndex(int mode) const
|
|
152 | +{
|
|
153 | + return valueToIndexForType(mode, HintingEngineType_CFF);
|
|
154 | +}
|
|
155 | + |
|
156 | + |
|
157 | +int
|
|
158 | +HintingModeComboBoxModel::ttInterpreterVersionToIndex(int version) const
|
|
159 | +{
|
|
160 | + return valueToIndexForType(version, HintingEngineType_TrueType);
|
|
161 | +}
|
|
162 | + |
|
163 | + |
|
164 | +void
|
|
165 | +HintingModeComboBoxModel::setSupportedModes(QList<int> supportedTTIVersions,
|
|
166 | + QList<int> supportedCFFModes)
|
|
167 | +{
|
|
168 | + for (auto it = items_.begin();
|
|
169 | + it != items_.end();
|
|
170 | + ++it)
|
|
171 | + {
|
|
172 | + if (it->type == HintingEngineType_TrueType)
|
|
173 | + it->supported = supportedTTIVersions.contains(it->value);
|
|
174 | + else if (it->type == HintingEngineType_CFF)
|
|
175 | + it->supported = supportedCFFModes.contains(it->value);
|
|
176 | + else
|
|
177 | + it->supported = false;
|
|
178 | + }
|
|
179 | +}
|
|
180 | + |
|
181 | + |
|
182 | +void
|
|
183 | +HintingModeComboBoxModel::setCurrentEngineType(HintingEngineType type)
|
|
184 | +{
|
|
185 | + for (auto it = items_.begin();
|
|
186 | + it != items_.end();
|
|
187 | + ++it)
|
|
188 | + it->enabled = it->supported && it->type == type;
|
|
189 | +}
|
|
190 | + |
|
191 | + |
|
192 | +/////////////////////////////////////////////////////////////////////////////
|
|
193 | +//
|
|
194 | +// SimpleComboBoxModel
|
|
195 | +//
|
|
196 | +/////////////////////////////////////////////////////////////////////////////
|
|
197 | + |
|
198 | + |
|
199 | +int
|
|
200 | +SimpleComboBoxModel::rowCount(const QModelIndex& parent) const
|
|
201 | +{
|
|
202 | + return items_.size();
|
|
203 | +}
|
|
204 | + |
|
205 | + |
|
206 | +QVariant
|
|
207 | +SimpleComboBoxModel::data(const QModelIndex& index, int role) const
|
|
208 | +{
|
|
209 | + if (role != Qt::DisplayRole)
|
|
210 | + return QVariant {};
|
|
211 | + |
|
212 | + int r = index.row();
|
|
213 | + if (r < 0 || r >= items_.size())
|
|
214 | + return QVariant {};
|
|
215 | + return items_[r].displayName;
|
|
216 | +}
|
|
217 | + |
|
218 | + |
|
219 | +int
|
|
220 | +SimpleComboBoxModel::indexToValue(int index)
|
|
221 | +{
|
|
222 | + if (index < 0 || index >= items_.size())
|
|
223 | + return -1;
|
|
224 | + return items_[index].value;
|
|
225 | +}
|
|
226 | + |
|
227 | + |
|
228 | +/////////////////////////////////////////////////////////////////////////////
|
|
229 | +//
|
|
230 | +// LCDFilterComboBoxModel
|
|
231 | +//
|
|
232 | +/////////////////////////////////////////////////////////////////////////////
|
|
233 | + |
|
234 | + |
|
235 | +LCDFilterComboBoxModel::LCDFilterComboBoxModel()
|
|
236 | +{
|
|
237 | + items_[LCDFilter_Default] = {
|
|
238 | + FT_LCD_FILTER_DEFAULT,
|
|
239 | + "Default"
|
|
240 | + };
|
|
241 | + items_[LCDFilter_Light] = {
|
|
242 | + FT_LCD_FILTER_LIGHT,
|
|
243 | + "Light"
|
|
244 | + };
|
|
245 | + items_[LCDFilter_None] = {
|
|
246 | + FT_LCD_FILTER_NONE,
|
|
247 | + "None"
|
|
248 | + };
|
|
249 | + items_[LCDFilter_Legacy] = {
|
|
250 | + FT_LCD_FILTER_LEGACY,
|
|
251 | + "Legacy"
|
|
252 | + };
|
|
253 | +}
|
|
254 | + |
|
255 | + |
|
256 | +/////////////////////////////////////////////////////////////////////////////
|
|
257 | +//
|
|
258 | +// AntiAliasingComboBoxModel
|
|
259 | +//
|
|
260 | +/////////////////////////////////////////////////////////////////////////////
|
|
261 | + |
|
262 | + |
|
263 | +AntiAliasingComboBoxModel::AntiAliasingComboBoxModel()
|
|
264 | +{
|
|
265 | + items_[AntiAliasing_None] = {
|
|
266 | + FT_LOAD_TARGET_MONO,
|
|
267 | + "None"
|
|
268 | + };
|
|
269 | + items_[AntiAliasing_Normal] = {
|
|
270 | + FT_LOAD_TARGET_NORMAL,
|
|
271 | + "Normal"
|
|
272 | + };
|
|
273 | + items_[AntiAliasing_Light] = {
|
|
274 | + FT_LOAD_TARGET_LIGHT,
|
|
275 | + "Light"
|
|
276 | + };
|
|
277 | + items_[AntiAliasing_LCD] = {
|
|
278 | + FT_LOAD_TARGET_LCD,
|
|
279 | + "LCD (RGB)"
|
|
280 | + };
|
|
281 | + items_[AntiAliasing_LCD_BGR] = {
|
|
282 | + FT_LOAD_TARGET_LCD,
|
|
283 | + "LCD (BGR)"
|
|
284 | + };
|
|
285 | + items_[AntiAliasing_LCD_Vertical] = {
|
|
286 | + FT_LOAD_TARGET_LCD_V,
|
|
287 | + "LCD (vert. RGB)"
|
|
288 | + };
|
|
289 | + items_[AntiAliasing_LCD_Vertical_BGR] = {
|
|
290 | + FT_LOAD_TARGET_LCD_V, // XXX Bug: No difference between RGB and BGR?
|
|
291 | + "LCD (vert. BGR)"
|
|
292 | + };
|
|
293 | + |
|
294 | + lightAntiAliasingEnabled_ = true;
|
|
295 | +}
|
|
296 | + |
|
297 | + |
|
298 | +QVariant
|
|
299 | +AntiAliasingComboBoxModel::data(const QModelIndex& index,
|
|
300 | + int role) const
|
|
301 | +{
|
|
302 | + if (role == Qt::ForegroundRole)
|
|
303 | + if (index.row() == AntiAliasing_Light && !lightAntiAliasingEnabled_)
|
|
304 | + return QApplication::palette().color(QPalette::Disabled,
|
|
305 | + QPalette::Text);
|
|
306 | + return SimpleComboBoxModel::data(index, role);
|
|
307 | +}
|
|
308 | + |
|
309 | + |
|
310 | +Qt::ItemFlags
|
|
311 | +AntiAliasingComboBoxModel::flags(const QModelIndex& index) const
|
|
312 | +{
|
|
313 | + if (index.row() == AntiAliasing_Light && !lightAntiAliasingEnabled_)
|
|
314 | + return Qt::ItemFlags {};
|
|
315 | + return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
|
316 | +}
|
|
317 | + |
|
318 | + |
|
319 | +// end of ttsettingscomboboxmodel.cpp |
1 | +// ttsettingscomboboxmodel.hpp
|
|
2 | + |
|
3 | +// Copyright (C) 2022 by Charlie Jiang.
|
|
4 | + |
|
5 | + |
|
6 | +#pragma once
|
|
7 | + |
|
8 | +#include <QAbstractListModel>
|
|
9 | +#include <QHash>
|
|
10 | + |
|
11 | +class HintingModeComboBoxModel
|
|
12 | +: public QAbstractListModel
|
|
13 | +{
|
|
14 | + Q_OBJECT
|
|
15 | +public:
|
|
16 | + enum HintingEngineType : int;
|
|
17 | + enum HintingMode : int;
|
|
18 | + struct HintingModeItem
|
|
19 | + {
|
|
20 | + HintingEngineType type;
|
|
21 | + HintingMode key;
|
|
22 | + int value;
|
|
23 | + bool enabled;
|
|
24 | + bool supported;
|
|
25 | + QString displayName;
|
|
26 | + };
|
|
27 | + |
|
28 | + HintingModeComboBoxModel();
|
|
29 | + ~HintingModeComboBoxModel() = default;
|
|
30 | + |
|
31 | + int rowCount(const QModelIndex& parent) const;
|
|
32 | + QVariant data(const QModelIndex& index,
|
|
33 | + int role) const;
|
|
34 | + Qt::ItemFlags flags(const QModelIndex& index) const;
|
|
35 | + |
|
36 | + int indexToTTInterpreterVersion(int index) const;
|
|
37 | + int indexToCFFMode(int index) const;
|
|
38 | + int cffModeToIndex(int mode) const;
|
|
39 | + int ttInterpreterVersionToIndex(int version) const;
|
|
40 | + |
|
41 | + void setSupportedModes(QList<int> supportedTTIVersions,
|
|
42 | + QList<int> supportedCFFModes);
|
|
43 | + void setCurrentEngineType(HintingEngineType type);
|
|
44 | + |
|
45 | +private:
|
|
46 | + QHash<int, HintingModeItem> items_;
|
|
47 | + |
|
48 | + int indexToValueForType(int index,
|
|
49 | + HintingEngineType type) const;
|
|
50 | + int valueToIndexForType(int value,
|
|
51 | + HintingEngineType type) const;
|
|
52 | + |
|
53 | +public:
|
|
54 | + // Note: Ensure related funcs are also changed when
|
|
55 | + // these enums are changed!
|
|
56 | + enum HintingEngineType
|
|
57 | + {
|
|
58 | + HintingEngineType_TrueType,
|
|
59 | + HintingEngineType_CFF
|
|
60 | + };
|
|
61 | + |
|
62 | + enum HintingMode
|
|
63 | + {
|
|
64 | + HintingMode_TrueType_v35 = 0,
|
|
65 | + HintingMode_TrueType_v38,
|
|
66 | + HintingMode_TrueType_v40,
|
|
67 | + HintingMode_CFF_FreeType,
|
|
68 | + HintingMode_CFF_Adobe
|
|
69 | + };
|
|
70 | +};
|
|
71 | + |
|
72 | + |
|
73 | +// A simple key-displayName-value model for QComboBox.
|
|
74 | +class SimpleComboBoxModel
|
|
75 | +: public QAbstractListModel
|
|
76 | +{
|
|
77 | + Q_OBJECT
|
|
78 | +public:
|
|
79 | + struct ComboBoxItem
|
|
80 | + {
|
|
81 | + int value;
|
|
82 | + QString displayName;
|
|
83 | + };
|
|
84 | + |
|
85 | + SimpleComboBoxModel() {}
|
|
86 | + ~SimpleComboBoxModel() = default;
|
|
87 | + |
|
88 | + int rowCount(const QModelIndex& parent) const;
|
|
89 | + QVariant data(const QModelIndex& index,
|
|
90 | + int role) const;
|
|
91 | + |
|
92 | + int indexToValue(int index);
|
|
93 | + |
|
94 | +protected:
|
|
95 | + QHash<int, ComboBoxItem> items_;
|
|
96 | +};
|
|
97 | + |
|
98 | + |
|
99 | +class LCDFilterComboBoxModel
|
|
100 | +: public SimpleComboBoxModel
|
|
101 | +{
|
|
102 | +public:
|
|
103 | + enum LCDFilter : int;
|
|
104 | + struct LCDFilterItem
|
|
105 | + {
|
|
106 | + int value;
|
|
107 | + QString displayName;
|
|
108 | + };
|
|
109 | + |
|
110 | + LCDFilterComboBoxModel();
|
|
111 | + ~LCDFilterComboBoxModel() = default;
|
|
112 | + |
|
113 | +public:
|
|
114 | + enum LCDFilter
|
|
115 | + {
|
|
116 | + LCDFilter_Default,
|
|
117 | + LCDFilter_Light,
|
|
118 | + LCDFilter_None,
|
|
119 | + LCDFilter_Legacy
|
|
120 | + };
|
|
121 | +};
|
|
122 | + |
|
123 | + |
|
124 | +class AntiAliasingComboBoxModel
|
|
125 | +: public SimpleComboBoxModel
|
|
126 | +{
|
|
127 | +public:
|
|
128 | + enum AntiAliasing : int;
|
|
129 | + |
|
130 | + AntiAliasingComboBoxModel();
|
|
131 | + ~AntiAliasingComboBoxModel() = default;
|
|
132 | +
|
|
133 | + QVariant data(const QModelIndex& index,
|
|
134 | + int role) const;
|
|
135 | + Qt::ItemFlags flags(const QModelIndex& index) const;
|
|
136 | + |
|
137 | + void setLightAntiAliasingEnabled(bool enabled)
|
|
138 | + {
|
|
139 | + lightAntiAliasingEnabled_ = enabled;
|
|
140 | + }
|
|
141 | + |
|
142 | +private:
|
|
143 | + bool lightAntiAliasingEnabled_;
|
|
144 | + |
|
145 | +public:
|
|
146 | + enum AntiAliasing
|
|
147 | + {
|
|
148 | + AntiAliasing_None,
|
|
149 | + AntiAliasing_Normal,
|
|
150 | + AntiAliasing_Light,
|
|
151 | + AntiAliasing_LCD,
|
|
152 | + AntiAliasing_LCD_BGR,
|
|
153 | + AntiAliasing_LCD_Vertical,
|
|
154 | + AntiAliasing_LCD_Vertical_BGR
|
|
155 | + };
|
|
156 | +};
|
|
157 | + |
|
158 | + |
|
159 | +// end of ttsettingscomboboxmodel.hpp |