Charlie Jiang pushed to branch gsoc-2022-chariri-3 at FreeType / FreeType Demo Programs
Commits:
-
1b46b6a1
by Charlie Jiang at 2022-08-30T09:46:51+08:00
-
c6f28457
by Charlie Jiang at 2022-08-30T10:13:47+08:00
6 changed files:
- src/ftinspect/engine/engine.cpp
- src/ftinspect/engine/engine.hpp
- src/ftinspect/models/customcomboboxmodels.cpp
- src/ftinspect/models/customcomboboxmodels.hpp
- src/ftinspect/panels/settingpanel.cpp
- src/ftinspect/panels/settingpanel.hpp
Changes:
... | ... | @@ -463,6 +463,15 @@ Engine::currentFaceSlot() |
463 | 463 | }
|
464 | 464 | |
465 | 465 | |
466 | +bool
|
|
467 | +Engine::currentFontTricky()
|
|
468 | +{
|
|
469 | + if (!ftFallbackFace_)
|
|
470 | + return false;
|
|
471 | + return FT_IS_TRICKY(ftFallbackFace_);
|
|
472 | +}
|
|
473 | + |
|
474 | + |
|
466 | 475 | FT_Pos
|
467 | 476 | Engine::currentFontTrackingKerning(int degree)
|
468 | 477 | {
|
... | ... | @@ -804,8 +813,6 @@ void |
804 | 813 | Engine::update()
|
805 | 814 | {
|
806 | 815 | loadFlags_ = FT_LOAD_DEFAULT;
|
807 | - if (doAutoHinting_)
|
|
808 | - loadFlags_ |= FT_LOAD_FORCE_AUTOHINT;
|
|
809 | 816 | |
810 | 817 | if (!embeddedBitmap_)
|
811 | 818 | loadFlags_ |= FT_LOAD_NO_BITMAP;
|
... | ... | @@ -813,10 +820,14 @@ Engine::update() |
813 | 820 | if (doHinting_)
|
814 | 821 | {
|
815 | 822 | loadFlags_ |= antiAliasingTarget_;
|
823 | + if (doAutoHinting_)
|
|
824 | + loadFlags_ |= FT_LOAD_FORCE_AUTOHINT;
|
|
816 | 825 | }
|
817 | 826 | else
|
818 | 827 | {
|
819 | 828 | loadFlags_ |= FT_LOAD_NO_HINTING;
|
829 | + if (currentFontTricky())
|
|
830 | + loadFlags_ |= FT_LOAD_NO_AUTOHINT;
|
|
820 | 831 | |
821 | 832 | if (!antiAliasingEnabled_)
|
822 | 833 | loadFlags_ |= FT_LOAD_MONOCHROME;
|
... | ... | @@ -118,7 +118,10 @@ public: |
118 | 118 | int currentFontIndex() { return curFontIndex_; }
|
119 | 119 | FT_Face currentFallbackFtFace() { return ftFallbackFace_; }
|
120 | 120 | FT_Size currentFtSize() { return ftSize_; }
|
121 | + FT_Size_Metrics const& currentFontMetrics();
|
|
122 | + FT_GlyphSlot currentFaceSlot();
|
|
121 | 123 | int currentFontType() const { return fontType_; }
|
124 | + bool currentFontTricky();
|
|
122 | 125 | const QString& currentFamilyName() { return curFamilyName_; }
|
123 | 126 | const QString& currentStyleName() { return curStyleName_; }
|
124 | 127 | int currentFontNumberOfGlyphs() { return curNumGlyphs_; }
|
... | ... | @@ -133,8 +136,6 @@ public: |
133 | 136 | int currentFontFirstUnicodeCharMap();
|
134 | 137 | // Note: the current font face must be properly set
|
135 | 138 | unsigned glyphIndexFromCharCode(int code, int charMapIndex);
|
136 | - FT_Size_Metrics const& currentFontMetrics();
|
|
137 | - FT_GlyphSlot currentFaceSlot();
|
|
138 | 139 | FT_Pos currentFontTrackingKerning(int degree);
|
139 | 140 | FT_Vector currentFontKerning(int glyphIndex, int prevIndex);
|
140 | 141 | std::pair<int, int> currentSizeAscDescPx();
|
... | ... | @@ -177,10 +177,14 @@ HintingModeComboBoxModel::setSupportedModes(QList<int> supportedTTIVersions, |
177 | 177 | |
178 | 178 | |
179 | 179 | void
|
180 | -HintingModeComboBoxModel::setCurrentEngineType(HintingEngineType type)
|
|
180 | +HintingModeComboBoxModel::setCurrentEngineType(HintingEngineType type,
|
|
181 | + bool tricky)
|
|
181 | 182 | {
|
182 | 183 | for (auto& item : items_)
|
183 | - item.enabled = item.supported && item.type == type;
|
|
184 | + if (!tricky)
|
|
185 | + item.enabled = item.supported && item.type == type;
|
|
186 | + else
|
|
187 | + item.enabled = item.supported && item.key == HintingMode_TrueType_v35;
|
|
184 | 188 | }
|
185 | 189 | |
186 | 190 |
... | ... | @@ -40,7 +40,7 @@ public: |
40 | 40 | |
41 | 41 | void setSupportedModes(QList<int> supportedTTIVersions,
|
42 | 42 | QList<int> supportedCFFModes);
|
43 | - void setCurrentEngineType(HintingEngineType type);
|
|
43 | + void setCurrentEngineType(HintingEngineType type, bool tricky);
|
|
44 | 44 | |
45 | 45 | private:
|
46 | 46 | QHash<int, HintingModeItem> items_;
|
... | ... | @@ -77,7 +77,6 @@ void |
77 | 77 | SettingPanel::checkAllSettings()
|
78 | 78 | {
|
79 | 79 | onFontChanged();
|
80 | - checkAutoHinting();
|
|
81 | 80 | checkAntiAliasing();
|
82 | 81 | }
|
83 | 82 | |
... | ... | @@ -86,27 +85,62 @@ void |
86 | 85 | SettingPanel::onFontChanged()
|
87 | 86 | {
|
88 | 87 | auto blockState = blockSignals(signalsBlocked() || comparatorMode_);
|
88 | + |
|
89 | + engine_->reloadFont();
|
|
90 | + if (engine_->currentFontType() == Engine::FontType_CFF)
|
|
91 | + {
|
|
92 | + hintingModeComboBoxModel_->setCurrentEngineType(
|
|
93 | + HintingModeComboBoxModel::HintingEngineType_CFF, false);
|
|
94 | + hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
|
|
95 | + }
|
|
96 | + else if (engine_->currentFontType() == Engine::FontType_TrueType)
|
|
97 | + {
|
|
98 | + auto tricky = engine_->currentFontTricky();
|
|
99 | + hintingModeComboBoxModel_->setCurrentEngineType(
|
|
100 | + HintingModeComboBoxModel::HintingEngineType_TrueType, tricky);
|
|
101 | + hintingModeComboBox_->setCurrentIndex(
|
|
102 | + tricky ? HintingModeComboBoxModel::HintingMode::HintingMode_TrueType_v35
|
|
103 | + : currentTTInterpreterVersion_);
|
|
104 | + }
|
|
105 | + else
|
|
106 | + {
|
|
107 | + hintingModeLabel_->setEnabled(false);
|
|
108 | + hintingModeComboBox_->setEnabled(false);
|
|
109 | + }
|
|
110 | + |
|
111 | + checkHinting();
|
|
112 | + |
|
113 | + engine_->reloadFont();
|
|
114 | + auto hasColor = engine_->currentFontHasColorLayers();
|
|
115 | + colorLayerCheckBox_->setEnabled(hasColor);
|
|
116 | + if (!hasColor)
|
|
117 | + colorLayerCheckBox_->setChecked(false);
|
|
118 | + populatePalettes();
|
|
119 | + mmgxPanel_->reloadFont();
|
|
120 | + blockSignals(blockState);
|
|
121 | + |
|
122 | + // Place this after `blockSignals` to let the signals emitted normally
|
|
123 | + auto bmapOnly = engine_->currentFontBitmapOnly();
|
|
124 | + embeddedBitmapCheckBox_->setEnabled(
|
|
125 | + !bmapOnly && engine_->currentFontHasEmbeddedBitmap());
|
|
126 | + if (bmapOnly)
|
|
127 | + embeddedBitmapCheckBox_->setChecked(true);
|
|
128 | +}
|
|
129 | + |
|
130 | + |
|
131 | +void
|
|
132 | +SettingPanel::checkHinting()
|
|
133 | +{
|
|
89 | 134 | if (hintingCheckBox_->isChecked())
|
90 | 135 | {
|
91 | - if (engine_->currentFontType() == Engine::FontType_CFF)
|
|
92 | - {
|
|
93 | - hintingModeComboBoxModel_->setCurrentEngineType(
|
|
94 | - HintingModeComboBoxModel::HintingEngineType_CFF);
|
|
95 | - hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
|
|
96 | - }
|
|
97 | - else if (engine_->currentFontType() == Engine::FontType_TrueType)
|
|
98 | - {
|
|
99 | - hintingModeComboBoxModel_->setCurrentEngineType(
|
|
100 | - HintingModeComboBoxModel::HintingEngineType_TrueType);
|
|
101 | - hintingModeComboBox_->setCurrentIndex(currentTTInterpreterVersion_);
|
|
102 | - }
|
|
103 | - else
|
|
136 | + engine_->reloadFont();
|
|
137 | + auto tricky = engine_->currentFontTricky();
|
|
104 | 138 | {
|
105 | - hintingModeLabel_->setEnabled(false);
|
|
106 | - hintingModeComboBox_->setEnabled(false);
|
|
139 | + QSignalBlocker blocker(autoHintingCheckBox_);
|
|
140 | + autoHintingCheckBox_->setEnabled(!tricky);
|
|
141 | + if (tricky)
|
|
142 | + autoHintingCheckBox_->setChecked(false);
|
|
107 | 143 | }
|
108 | - |
|
109 | - autoHintingCheckBox_->setEnabled(true);
|
|
110 | 144 | checkAutoHinting(); // this will emit repaint
|
111 | 145 | }
|
112 | 146 | else
|
... | ... | @@ -133,22 +167,6 @@ SettingPanel::onFontChanged() |
133 | 167 |
|
134 | 168 | emit repaintNeeded();
|
135 | 169 | }
|
136 | - |
|
137 | - engine_->reloadFont();
|
|
138 | - auto hasColor = engine_->currentFontHasColorLayers();
|
|
139 | - colorLayerCheckBox_->setEnabled(hasColor);
|
|
140 | - if (!hasColor)
|
|
141 | - colorLayerCheckBox_->setChecked(false);
|
|
142 | - populatePalettes();
|
|
143 | - mmgxPanel_->reloadFont();
|
|
144 | - blockSignals(blockState);
|
|
145 | - |
|
146 | - // Place this after `blockSignals` to let the signals emitted normally
|
|
147 | - auto bmapOnly = engine_->currentFontBitmapOnly();
|
|
148 | - embeddedBitmapCheckBox_->setEnabled(
|
|
149 | - !bmapOnly && engine_->currentFontHasEmbeddedBitmap());
|
|
150 | - if (bmapOnly)
|
|
151 | - embeddedBitmapCheckBox_->setChecked(true);
|
|
152 | 170 | }
|
153 | 171 | |
154 | 172 | |
... | ... | @@ -448,7 +466,7 @@ SettingPanel::createConnections() |
448 | 466 | this, &SettingPanel::updateGamma);
|
449 | 467 |
|
450 | 468 | connect(hintingCheckBox_, &QCheckBox::clicked,
|
451 | - this, &SettingPanel::repaintNeeded);
|
|
469 | + this, &SettingPanel::checkHinting);
|
|
452 | 470 | |
453 | 471 | if (debugMode_)
|
454 | 472 | {
|
... | ... | @@ -616,7 +634,7 @@ SettingPanel::createLayout() |
616 | 634 | "Enable embedded bitmap strikes (force enabled for bitmap-only fonts)."));
|
617 | 635 | stemDarkeningCheckBox_->setToolTip(
|
618 | 636 | tr("Enable stem darkening (only valid for auto-hinter with gamma "
|
619 | - "correction enabled)."));
|
|
637 | + "correction enabled and with Light AA modes)."));
|
|
620 | 638 | gammaSlider_->setToolTip("Gamma correction value.");
|
621 | 639 | colorLayerCheckBox_->setToolTip(tr("Enable color layer rendering."));
|
622 | 640 | paletteComboBox_->setToolTip(tr("Select color layer palette (only valid when "
|
... | ... | @@ -49,6 +49,7 @@ signals: |
49 | 49 | public slots:
|
50 | 50 | void checkAllSettings();
|
51 | 51 | void onFontChanged();
|
52 | + void checkHinting();
|
|
52 | 53 | void checkHintingMode();
|
53 | 54 | void checkAutoHinting();
|
54 | 55 | void checkAntiAliasing();
|