[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master bcf46fd 5/5: [ftinspect] Display more glyph and
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master bcf46fd 5/5: [ftinspect] Display more glyph and font information. |
Date: |
Thu, 12 May 2016 10:05:37 +0000 (UTC) |
branch: master
commit bcf46fd2a919d77aaaeffdd3089b8d02f5f2730d
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ftinspect] Display more glyph and font information.
* src/ftinspect.cpp (Engine::loadFont): Update `curFamilyName' and
`curStyleName'.
(Engine::currentFamilyName, Engine::currentStyleName,
Engine::glyphName): New methods.
(MainGUI::closeFont, MainGUI::showFont, MainGUI::adjustGlyphIndex,
MainGUI::createLayout): Updated.
* src/ftinspect.h (Engine): New members `curFamilyName' and
`curStyleName'.
Updated.
(MainGUI): New `fontFilenameLabel', `fontNameLabel', and
`glyphNameLabel' members.
Use `QGridLayout' for `infoRightLayout'.
---
ChangeLog | 19 +++++++++++++
src/ftinspect.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++------
src/ftinspect.h | 12 +++++++-
3 files changed, 104 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dbe5157..52b2210 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2016-05-12 Werner Lemberg <address@hidden>
+ [ftinspect] Display more glyph and font information.
+
+ * src/ftinspect.cpp (Engine::loadFont): Update `curFamilyName' and
+ `curStyleName'.
+ (Engine::currentFamilyName, Engine::currentStyleName,
+ Engine::glyphName): New methods.
+
+ (MainGUI::closeFont, MainGUI::showFont, MainGUI::adjustGlyphIndex,
+ MainGUI::createLayout): Updated.
+
+ * src/ftinspect.h (Engine): New members `curFamilyName' and
+ `curStyleName'.
+ Updated.
+ (MainGUI): New `fontFilenameLabel', `fontNameLabel', and
+ `glyphNameLabel' members.
+ Use `QGridLayout' for `infoRightLayout'.
+
+2016-05-12 Werner Lemberg <address@hidden>
+
[ftinspect] Fix logical mistakes in font navigation.
* src/ftinspect.cpp (Engine::Engine): Initialize `ftSize'.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index a84d665..12642a3 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -323,6 +323,10 @@ Engine::loadFont(int fontIndex,
if (scaler.face_id == 0)
{
// an invalid font, missing in the hash
+ ftSize = NULL;
+ curFamilyName = QString();
+ curStyleName = QString();
+
return -1;
}
@@ -330,6 +334,10 @@ Engine::loadFont(int fontIndex,
if (error)
{
// XXX error handling
+ ftSize = NULL;
+ curFamilyName = QString();
+ curStyleName = QString();
+
return -1;
}
@@ -339,6 +347,9 @@ Engine::loadFont(int fontIndex,
if (currentFontFileInfo.exists())
currentRetry = 0;
+ curFamilyName = QString(ftSize->face->family_name);
+ curStyleName = QString(ftSize->face->style_name);
+
FT_Module module = &ftSize->face->driver->root;
// XXX cover all available modules
@@ -442,6 +453,39 @@ Engine::removeFont(int fontIndex,
}
+const QString&
+Engine::currentFamilyName()
+{
+ return curFamilyName;
+}
+
+
+const QString&
+Engine::currentStyleName()
+{
+ return curStyleName;
+}
+
+
+QString
+Engine::glyphName(int index)
+{
+ QString name;
+
+ if (ftSize && FT_HAS_GLYPH_NAMES(ftSize->face))
+ {
+ char buffer[256];
+ if (!FT_Get_Glyph_Name(ftSize->face,
+ index,
+ buffer,
+ sizeof(buffer)))
+ name = QString(buffer);
+ }
+
+ return name;
+}
+
+
FT_Outline*
Engine::loadOutline(int glyphIndex)
{
@@ -1157,7 +1201,7 @@ MainGUI::MainGUI()
// we are going to watch the current font file once in a second
timer = new QTimer();
timer->setInterval(1000);
- timer->start();
+// timer->start();
setGraphicsDefaults();
createLayout();
@@ -1285,6 +1329,13 @@ MainGUI::closeFont()
currentInstanceIndex = 0;
}
+ if (currentFontIndex < 0)
+ {
+ fontFilenameLabel->clear();
+ fontNameLabel->clear();
+ glyphNameLabel->clear();
+ }
+
showFont();
}
@@ -1298,6 +1349,8 @@ MainGUI::showFont(bool preserveIndices)
Font& font = fontList[currentFontIndex];
+ fontFilenameLabel->setText(QFileInfo(font.filePathname).fileName());
+
// if not yet available, extract the number of faces and indices
// for the current font
@@ -1374,6 +1427,10 @@ MainGUI::showFont(bool preserveIndices)
currentInstanceIndex = -1;
currentNumGlyphs = -1;
}
+
+ fontNameLabel->setText(QString("%1 %2")
+ .arg(engine->currentFamilyName())
+ .arg(engine->currentStyleName()));
}
else
{
@@ -1386,6 +1443,7 @@ MainGUI::showFont(bool preserveIndices)
checkCurrentFaceIndex();
checkCurrentInstanceIndex();
checkHinting();
+ adjustGlyphIndex(0);
drawGlyph();
}
@@ -1594,9 +1652,10 @@ MainGUI::adjustGlyphIndex(int delta)
}
QString upperHex = QString::number(currentGlyphIndex, 16).toUpper();
- glyphIndexLabel->setText(tr("Glyph Index %1 (0x%2)")
- .arg(currentGlyphIndex)
- .arg(upperHex));
+ glyphIndexLabel->setText(QString("%1 (0x%2)")
+ .arg(currentGlyphIndex)
+ .arg(upperHex));
+ glyphNameLabel->setText(engine->glyphName(currentGlyphIndex));
drawGlyph();
}
@@ -1931,7 +1990,7 @@ void
MainGUI::createLayout()
{
// left side
- infoLeftLayout = new QHBoxLayout;
+ fontFilenameLabel = new QLabel;
hintingCheckBox = new QCheckBox(tr("Hinting"));
@@ -2016,6 +2075,9 @@ MainGUI::createLayout()
showPointNumbersCheckBox = new QCheckBox(tr("Show Point Numbers"));
showOutlinesCheckBox = new QCheckBox(tr("Show Outlines"));
+ infoLeftLayout = new QHBoxLayout;
+ infoLeftLayout->addWidget(fontFilenameLabel);
+
hintingModeLayout = new QHBoxLayout;
hintingModeLayout->addWidget(hintingModeLabel);
hintingModeLayout->addWidget(hintingModeComboBoxx);
@@ -2106,9 +2168,8 @@ MainGUI::createLayout()
// right side
glyphIndexLabel = new QLabel;
-
- infoRightLayout = new QHBoxLayout;
- infoRightLayout->addWidget(glyphIndexLabel);
+ glyphNameLabel = new QLabel;
+ fontNameLabel = new QLabel;
glyphScene = new QGraphicsScene;
glyphScene->addItem(new Grid(gridPen, axisPen));
@@ -2172,6 +2233,11 @@ MainGUI::createLayout()
previousInstanceButton = new QPushButton(tr("Previous Named Instance"));
nextInstanceButton = new QPushButton(tr("Next Named Instance"));
+ infoRightLayout = new QGridLayout;
+ infoRightLayout->addWidget(glyphIndexLabel, 0, 0);
+ infoRightLayout->addWidget(glyphNameLabel, 0, 1);
+ infoRightLayout->addWidget(fontNameLabel, 0, 2);
+
navigationLayout = new QHBoxLayout;
navigationLayout->setSpacing(0);
navigationLayout->addStretch(1);
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 8f383cf..5fe5355 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -112,6 +112,9 @@ public:
Engine(MainGUI*);
~Engine();
+ const QString& currentFamilyName();
+ const QString& currentStyleName();
+ QString glyphName(int);
int numFaces(int);
int numNamedInstances(int, int);
int loadFont(int, int, int); // returns number of glyphs
@@ -141,6 +144,10 @@ private:
// if it suddenly disappears (because it is
// in the process of being regenerated)
int currentRetry;
+
+ QString curFamilyName;
+ QString curStyleName;
+
FT_Library library;
FTC_Manager cacheManager;
FTC_ImageCache imageCache;
@@ -401,6 +408,7 @@ private:
QGraphicsView *glyphView;
QGridLayout *fontLayout;
+ QGridLayout *infoRightLayout;
QHash<int, int> hintingModesTrueTypeHash;
QHash<int, int> hintingModesCFFHash;
@@ -413,7 +421,6 @@ private:
QHBoxLayout *hintingModeLayout;
QHBoxLayout *horizontalHintingLayout;
QHBoxLayout *infoLeftLayout;
- QHBoxLayout *infoRightLayout;
QHBoxLayout *lcdFilterLayout;
QHBoxLayout *navigationLayout;
QHBoxLayout *pointNumbersLayout;
@@ -424,8 +431,11 @@ private:
QLabel *antiAliasingLabel;
QLabel *dpiLabel;
+ QLabel *fontFilenameLabel;
+ QLabel *fontNameLabel;
QLabel *gammaLabel;
QLabel *glyphIndexLabel;
+ QLabel *glyphNameLabel;
QLabel *hintingModeLabel;
QLabel *lcdFilterLabel;
QLabel *sizeLabel;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master bcf46fd 5/5: [ftinspect] Display more glyph and font information.,
Werner LEMBERG <=