[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] gsoc-2022-chariri-3 17c09dc 22/36: [ftinspect] Fix Cha
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] gsoc-2022-chariri-3 17c09dc 22/36: [ftinspect] Fix CharMap selector when the font file is symlink. |
Date: |
Wed, 27 Jul 2022 06:32:45 -0400 (EDT) |
branch: gsoc-2022-chariri-3
commit 17c09dca4f0f78d5ecc98da4faf66123bc3997a9
Author: Charlie Jiang <w@chariri.moe>
Commit: Charlie Jiang <w@chariri.moe>
[ftinspect] Fix CharMap selector when the font file is symlink.
When the font file is a symlink, the font will be periodically reloaded
every 1s. When reloading, if the font's charmaps have no change, then the
charmap selector shouldn't be re-populated, or it would be hard to change
the current charmap.
* src/ftinspect/panels/continuous.cpp: Add a guard to prevent unnecessary
combobox repopulating.
* src/ftinspect/engine/charmap.hpp: Add proper `operator==` for class
`CharMapInfo`.
---
src/ftinspect/engine/charmap.hpp | 15 +++++++++++++++
src/ftinspect/panels/continuous.cpp | 5 +++++
2 files changed, 20 insertions(+)
diff --git a/src/ftinspect/engine/charmap.hpp b/src/ftinspect/engine/charmap.hpp
index f64d08b..a6c55e9 100644
--- a/src/ftinspect/engine/charmap.hpp
+++ b/src/ftinspect/engine/charmap.hpp
@@ -27,6 +27,21 @@ struct CharMapInfo
QString stringifyIndex(int code, int index);
QString stringifyIndexShort(int code);
+
+ friend bool
+ operator==(const CharMapInfo& lhs, const CharMapInfo& rhs)
+ {
+ return lhs.index == rhs.index && lhs.encoding == rhs.encoding;
+ }
+
+
+ friend bool
+ operator!=(const CharMapInfo& lhs, const CharMapInfo& rhs)
+ {
+ return !(lhs == rhs);
+ }
+
+
private:
int computeMaxIndex();
static int maxIndexForFaceAndCharMap(FT_CharMap charMap, unsigned max);
diff --git a/src/ftinspect/panels/continuous.cpp
b/src/ftinspect/panels/continuous.cpp
index eb82c68..284fcad 100644
--- a/src/ftinspect/panels/continuous.cpp
+++ b/src/ftinspect/panels/continuous.cpp
@@ -112,6 +112,11 @@ ContinuousTab::setGlyphBeginindex(int index)
void
ContinuousTab::setCharMaps(std::vector<CharMapInfo>& charMaps)
{
+ if (charMaps_ == charMaps)
+ {
+ charMaps_ = charMaps; // Still need to substitute because ptr may differ
+ return;
+ }
charMaps_ = charMaps;
int oldIndex = charMapSelector_->currentIndex();
unsigned oldEncoding = 0u;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] gsoc-2022-chariri-3 17c09dc 22/36: [ftinspect] Fix CharMap selector when the font file is symlink.,
Werner Lemberg <=