[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] gsoc-2019-veeki ce4f424: Basic ftdump functionality
From: |
Veeki Yadav |
Subject: |
[freetype2-demos] gsoc-2019-veeki ce4f424: Basic ftdump functionality |
Date: |
Wed, 19 Jun 2019 04:09:02 -0400 (EDT) |
branch: gsoc-2019-veeki
commit ce4f424791d482b6e0d85ef76a08b722b2ff4860
Author: gevic <address@hidden>
Commit: gevic <address@hidden>
Basic ftdump functionality
---
src/ftinspect/engine/engine.cpp | 33 ++++++++
src/ftinspect/engine/engine.hpp | 7 ++
src/ftinspect/maingui.cpp | 162 ++++++++++++++++++++++++++++++++++++++++
src/ftinspect/maingui.hpp | 7 ++
4 files changed, 209 insertions(+)
diff --git a/src/ftinspect/engine/engine.cpp b/src/ftinspect/engine/engine.cpp
index d9c207a..f721703 100644
--- a/src/ftinspect/engine/engine.cpp
+++ b/src/ftinspect/engine/engine.cpp
@@ -408,12 +408,21 @@ Engine::loadFont(int fontIndex,
ftSize = NULL;
curFamilyName = QString();
curStyleName = QString();
+ postscriptName = QString();
+ driverName = QString();
+ issfnt = QString();
}
else
{
curFamilyName = QString(ftSize->face->family_name);
curStyleName = QString(ftSize->face->style_name);
+ postscriptName = FT_Get_Postscript_Name(ftSize->face);
+ if( postscriptName == NULL )
+ {
+ postscriptName = "UNAVAILABLE";
+ }
+
FT_Module module = &ftSize->face->driver->root;
const char* moduleName = module->clazz->module_name;
@@ -422,6 +431,9 @@ Engine::loadFont(int fontIndex,
fontType = FontType_CFF;
else if (!strcmp(moduleName, "truetype"))
fontType = FontType_TrueType;
+
+ driverName = moduleName;
+ issfnt = FT_IS_SFNT( ftSize->face ) ? QString("yes") : QString("no");
}
return numGlyphs;
@@ -467,6 +479,27 @@ Engine::currentStyleName()
}
+const QString&
+Engine::currentPostscriptName()
+{
+ return postscriptName;
+}
+
+
+const QString&
+Engine::DriverName()
+{
+ return driverName;
+}
+
+
+const QString&
+Engine::issfntwrapped()
+{
+ return issfnt;
+}
+
+
QString
Engine::glyphName(int index)
{
diff --git a/src/ftinspect/engine/engine.hpp b/src/ftinspect/engine/engine.hpp
index 6f4f42f..97d8b79 100644
--- a/src/ftinspect/engine/engine.hpp
+++ b/src/ftinspect/engine/engine.hpp
@@ -46,6 +46,10 @@ public:
const QString& currentFamilyName();
const QString& currentStyleName();
+ const QString& currentPostscriptName();
+ const QString& DriverName();
+ const QString& issfntwrapped();
+
QString glyphName(int glyphIndex);
long numberOfFaces(int fontIndex);
int numberOfNamedInstances(int fontIndex,
@@ -83,6 +87,9 @@ private:
QString curFamilyName;
QString curStyleName;
+ QString postscriptName;
+ QString driverName;
+ QString issfnt;
FT_Library library;
FTC_Manager cacheManager;
diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index 866455f..b43fc61 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -13,6 +13,7 @@
#include <QSettings>
#include FT_DRIVER_H
+#include FT_TRUETYPE_TABLES_H
MainGUI::MainGUI()
@@ -61,6 +62,142 @@ MainGUI::closeEvent(QCloseEvent* event)
void
+MainGUI::showFontName()
+{
+ QMessageBox::about(
+ this,
+ tr("Font Name Entries"),
+ tr("<b> Face number : %1 </b><br><br>"
+ "Family : %2 <br>"
+ "Style : %3 <br>"
+ "Postscript : %4")
+ .arg(fontList.size())
+ .arg(engine->currentFamilyName())
+ .arg(engine->currentStyleName())
+ .arg(engine->currentPostscriptName()));
+}
+
+
+void
+MainGUI::showFontType()
+{
+ FT_Face face = engine->getFtSize()->face;
+ const char* fontType;
+ if (FT_IS_SCALABLE( face ) != 0 )
+ {
+ if (FT_HAS_MULTIPLE_MASTERS( face ) != 0 )
+ {
+ fontType = "scalable, multiple masters";
+ }
+ else
+ {
+ fontType = "scalable";
+ }
+ }
+ else if (FT_HAS_FIXED_SIZES( face ) != 0)
+ {
+ fontType = "fixed size";
+ }
+
+ const char* direction = "" ;
+ if (FT_HAS_HORIZONTAL( face))
+ {
+ if (FT_HAS_VERTICAL( face ))
+ {
+ direction = " horizontal vertical";
+ }
+ else
+ {
+ direction = " horizontal";
+ }
+ }
+ else
+ {
+ if (FT_HAS_VERTICAL( face ))
+ {
+ direction = " vertical";
+ }
+ }
+
+ if(FT_IS_SCALABLE( face ))
+ {
+ QMessageBox::about(this,
+ tr("Font Type Entries"),
+ tr("<p><b>Face number : %1</b><br><br>"
+ "FreeType driver: %2<br>"
+ "sfnt wrapped : %3<br>"
+ "type : %4<br>"
+ "direction : %5 <br>"
+ "fixed width : %6 <br>"
+ "glyph names : %7 <br></p>"
+ "<b>Scalability Properties</b><br>"
+ "EM size : %9 <br>"
+ "global BBox : (%10, %11):(%12, %13) <br>"
+ "ascent : %14 <br>"
+ "descent : %15<br>"
+ "text height : %16 <br>")
+ .arg(fontList.size())
+ .arg(engine->DriverName())
+ .arg(FT_IS_SFNT( face ) ? QString("yes") : QString("no"))
+ .arg(fontType)
+ .arg(direction)
+ .arg(FT_IS_FIXED_WIDTH(face) ? QString("yes") : QString("no"))
+ .arg(FT_HAS_GLYPH_NAMES( face ) ? QString("yes") : QString("no"))
+ .arg(face->units_per_EM)
+ .arg(face->bbox.xMin)
+ .arg(face->bbox.yMin)
+ .arg(face->bbox.xMax)
+ .arg(face->bbox.yMax)
+ .arg(face->ascender)
+ .arg(face->descender)
+ .arg(face->height));
+ }
+ else
+ {
+ QMessageBox::about(
+ this,
+ tr("Font Type Entries"),
+ tr("<b>Face number : %1</b><br><br>"
+ "FreeType driver: %2<br>"
+ "sfnt wrapped : %3<br>"
+ "type : %4<br>"
+ "direction : %5 <br>"
+ "fixed width : %6 <br>"
+ "glyph names : %7 <br>")
+ .arg(fontList.size())
+ .arg(engine->DriverName())
+ .arg(FT_IS_SFNT( face ) ? QString("yes") : QString("no"))
+ .arg(fontType)
+ .arg(direction)
+ .arg(FT_IS_FIXED_WIDTH(face) ? QString("yes") : QString("no"))
+ .arg(FT_HAS_GLYPH_NAMES( face ) ? QString("yes") : QString("no")));
+ }
+}
+
+
+void
+MainGUI::showCharmapsInfo()
+{
+ FT_Face face = engine->getFtSize()->face;
+ QMessageBox msgBox;
+ for(int i = 0 ; i < face->num_charmaps ; i++)
+ {
+ QMessageBox::about(
+ this,
+ tr("Charmaps Info"),
+ tr("Format : %1<br>"
+ "Platform : %2<br>"
+ "Encoding : %3<br>"
+ "Language : %4<br>")
+ .arg(FT_Get_CMap_Format( face->charmaps[i] ))
+ .arg(face->charmaps[i]->platform_id)
+ .arg(face->charmaps[i]->encoding_id)
+ .arg(FT_Get_CMap_Language_ID(face->charmaps[i])));
+ }
+}
+
+
+void
MainGUI::about()
{
QMessageBox::about(
@@ -107,6 +244,9 @@ MainGUI::loadFonts()
// XXX sort data, uniquify elements
fontList.append(files);
+ // Enable font info menu
+ menuInfo->setEnabled(true);
+
// if we have new fonts, set the current index to the first new one
if (oldSize < fontList.size())
currentFontIndex = oldSize;
@@ -134,6 +274,9 @@ MainGUI::closeFont()
else
currentFontIndex = 0;
+ // disable font info menu
+ menuInfo->setEnabled(false);
+
showFont();
}
@@ -1160,6 +1303,15 @@ MainGUI::createActions()
exitAct->setShortcuts(QKeySequence::Quit);
connect(exitAct, SIGNAL(triggered()), SLOT(close()));
+ showFontNameAct = new QAction(tr("&Font Name"), this);
+ connect(showFontNameAct, SIGNAL(triggered()), SLOT(showFontName()));
+
+ showFontTypeAct = new QAction(tr("&Font Type"), this);
+ connect(showFontTypeAct, SIGNAL(triggered()), SLOT(showFontType()));
+
+ showCharmapsInfoAct = new QAction(tr("&Charmap Info"), this);
+ connect(showCharmapsInfoAct, SIGNAL(triggered()), SLOT(showCharmapsInfo()));
+
aboutAct = new QAction(tr("&About"), this);
connect(aboutAct, SIGNAL(triggered()), SLOT(about()));
@@ -1176,6 +1328,16 @@ MainGUI::createMenus()
menuFile->addAction(closeFontAct);
menuFile->addAction(exitAct);
+ menuInfo = menuBar()->addMenu(tr("&Elements"));
+ menuInfo->addAction(showFontNameAct);
+ menuInfo->addAction(showFontTypeAct);
+ menuInfo->addAction(showCharmapsInfoAct);
+
+ if (fontList.size() <= 0)
+ {
+ menuInfo->setEnabled(false);
+ }
+
menuHelp = menuBar()->addMenu(tr("&Help"));
menuHelp->addAction(aboutAct);
menuHelp->addAction(aboutQtAct);
diff --git a/src/ftinspect/maingui.hpp b/src/ftinspect/maingui.hpp
index 92d32a9..c983270 100644
--- a/src/ftinspect/maingui.hpp
+++ b/src/ftinspect/maingui.hpp
@@ -71,6 +71,9 @@ protected:
private slots:
void about();
void aboutQt();
+ void showCharmapsInfo();
+ void showFontType();
+ void showFontName();
void adjustGlyphIndex(int);
void checkAntiAliasing();
void checkAutoHinting();
@@ -124,6 +127,9 @@ private:
QAction *closeFontAct;
QAction *exitAct;
QAction *loadFontsAct;
+ QAction *showCharmapsInfoAct;
+ QAction *showFontTypeAct;
+ QAction *showFontNameAct;
QCheckBox *autoHintingCheckBox;
QCheckBox *blueZoneHintingCheckBox;
@@ -189,6 +195,7 @@ private:
QMenu *menuFile;
QMenu *menuHelp;
+ QMenu *menuInfo;
QPen axisPen;
QPen blueZonePen;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] gsoc-2019-veeki ce4f424: Basic ftdump functionality,
Veeki Yadav <=