[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master d8ce094: [ftinspect] Fix a bunch of glitches.
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master d8ce094: [ftinspect] Fix a bunch of glitches. |
Date: |
Mon, 9 May 2016 13:05:57 +0000 (UTC) |
branch: master
commit d8ce094b8f065689a298d810041b569ca653ff08
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ftinspect] Fix a bunch of glitches.
* src/ftinspect.cpp (FaceID::FaceID): Initialize members with `-1'.
While not needed, it better indicates an invalid lookup in the hash
for debugging purposes.
(Engine::Engine): Don't call `update' here, since
`MainGUI::setDefaults' wasn't called yet.
(Engine::loadFont): Call `update'.
Return -1 for an invalid face ID.
(Engine::removeFont): Properly handle invalid face ID.
(Engine::update): Fix code reversal for pixels vs. points.
(MainGUI::MainGUI): Initialize `engine'.
(MainGUI::closeFont): First remove the font, then the face ID.
Handle invalid font also.
(MainGUI::showFont): Handle invalid font also.
(MainGUI::setGraphicsDefault): Set width of outline pen.
---
ChangeLog | 19 +++++++++++++++++++
src/ftinspect.cpp | 47 ++++++++++++++++++++++++++++++-----------------
src/ftinspect.h | 4 +++-
3 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 913876c..cbc33f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2016-05-09 Werner Lemberg <address@hidden>
+
+ [ftinspect] Fix a bunch of glitches.
+
+ * src/ftinspect.cpp (FaceID::FaceID): Initialize members with `-1'.
+ While not needed, it better indicates an invalid lookup in the hash
+ for debugging purposes.
+ (Engine::Engine): Don't call `update' here, since
+ `MainGUI::setDefaults' wasn't called yet.
+ (Engine::loadFont): Call `update'.
+ Return -1 for an invalid face ID.
+ (Engine::removeFont): Properly handle invalid face ID.
+ (Engine::update): Fix code reversal for pixels vs. points.
+ (MainGUI::MainGUI): Initialize `engine'.
+ (MainGUI::closeFont): First remove the font, then the face ID.
+ Handle invalid font also.
+ (MainGUI::showFont): Handle invalid font also.
+ (MainGUI::setGraphicsDefault): Set width of outline pen.
+
2016-05-08 Werner Lemberg <address@hidden>
[ftinspect] Display axes.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 2cf8ecf..b0caa62 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -9,9 +9,9 @@
FaceID::FaceID()
-: fontIndex(0),
- faceIndex(0),
- instanceIndex(0)
+: fontIndex(-1),
+ faceIndex(-1),
+ instanceIndex(-1)
{
// empty
}
@@ -224,8 +224,6 @@ Engine::Engine(MainGUI* g)
"warping",
&doWarping);
}
-
- update();
}
@@ -313,10 +311,17 @@ Engine::loadFont(int fontIndex,
int faceIndex,
int instanceIndex)
{
+ update();
+
scaler.face_id = reinterpret_cast<void*>
(gui->faceIDHash.value(FaceID(fontIndex,
faceIndex,
instanceIndex)));
+ if (scaler.face_id == 0)
+ {
+ // an invalid font, missing in the hash
+ return -1;
+ }
FT_Error error = FTC_Manager_LookupSize(cacheManager, &scaler, &ftSize);
if (error)
@@ -338,7 +343,8 @@ Engine::removeFont(int fontIndex,
(gui->faceIDHash.value(FaceID(fontIndex,
faceIndex,
instanceIndex)));
- FTC_Manager_RemoveFaceID(cacheManager, face_id);
+ if (face_id)
+ FTC_Manager_RemoveFaceID(cacheManager, face_id);
}
@@ -349,13 +355,13 @@ Engine::update()
if (gui->unitsComboBox->currentIndex() == MainGUI::Units_px)
{
- pointSize = gui->sizeDoubleSpinBox->value();
- pixelSize = pointSize * dpi / 72.0;
+ pixelSize = gui->sizeDoubleSpinBox->value();
+ pointSize = pixelSize * 72.0 / dpi;
}
else
{
- pixelSize = gui->sizeDoubleSpinBox->value();
- pointSize = pixelSize * 72.0 / dpi;
+ pointSize = gui->sizeDoubleSpinBox->value();
+ pixelSize = pointSize * dpi / 72.0;
}
doHinting = gui->hintingCheckBox->isChecked();
@@ -441,8 +447,6 @@ Engine::update()
scaler.x_res = dpi;
scaler.y_res = dpi;
}
-
-
}
@@ -502,6 +506,8 @@ Grid::paint(QPainter* painter,
MainGUI::MainGUI()
{
+ engine = NULL;
+
setGraphicsDefaults();
createLayout();
createConnections();
@@ -597,8 +603,8 @@ MainGUI::closeFont()
for (int i = 0; i < fonts[currentFontIndex].numInstancesList.size(); i++)
for (int j = 0; j < fonts[currentFontIndex].numInstancesList[i]; j++)
{
- faceIDHash.remove(FaceID(currentFontIndex, i, j));
engine->removeFont(currentFontIndex, i, j);
+ faceIDHash.remove(FaceID(currentFontIndex, i, j));
}
fonts.removeAt(currentFontIndex);
@@ -607,7 +613,8 @@ MainGUI::closeFont()
currentFontIndex--;
if (currentFontIndex < 0
- || fonts[currentFontIndex].numInstancesList.isEmpty())
+ || fonts[currentFontIndex].numInstancesList.isEmpty()
+ || fonts[currentFontIndex].numInstancesList[0] == 0)
{
currentFaceIndex = -1;
currentInstanceIndex = -1;
@@ -682,7 +689,8 @@ MainGUI::showFont()
currentInstanceIndex = 0;
}
- if (currentFaceIndex >= 0)
+ if (currentFontIndex >= 0
+ && fonts[currentFontIndex].numInstancesList[0] != 0)
{
// up to now we only called for rudimentary font handling
// (via the `engine->numFaces' and `engine->numInstances' methods);
@@ -698,6 +706,11 @@ MainGUI::showFont()
currentFaceIndex,
currentInstanceIndex));
}
+ else
+ {
+ currentFaceIndex = -1;
+ currentNumGlyphs = -1;
+ }
}
checkCurrentFontIndex();
@@ -1054,6 +1067,7 @@ MainGUI::setGraphicsDefaults()
offPen.setColor(QColor(0, 128, 0, 255)); // dark green
onPen.setColor(QColor(255, 0, 0, 255)); // red
outlinePen.setColor(QColor(255, 0, 0, 255)); // red
+ outlinePen.setWidth(0);
segmentPen.setColor(QColor(64, 255, 128, 64)); // light green
segmentPen.setWidth(0);
}
@@ -1533,8 +1547,7 @@ MainGUI::setDefaults()
hintingModeComboBoxx->setItemEnabled(hintingModesAlwaysDisabled[i],
false);
- // starting value 0 for a cache's face ID
- // only works with FreeType 2.6.4 or newer
+ // we reserve value 0 for the `invalid face ID'
faceCounter = 1;
currentFontIndex = -1;
diff --git a/src/ftinspect.h b/src/ftinspect.h
index caae8b8..e401700 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -160,7 +160,9 @@ public:
Grid(const QPen&,
const QPen&);
QRectF boundingRect() const;
- void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
+ void paint(QPainter*,
+ const QStyleOptionGraphicsItem*,
+ QWidget*);
private:
QPen gridPen;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master d8ce094: [ftinspect] Fix a bunch of glitches.,
Werner LEMBERG <=