diff --git a/src/ftinspect/engine/engine.cpp b/src/ftinspect/engine/engine.cpp index 6856beb..43ce423 100644 --- a/src/ftinspect/engine/engine.cpp +++ b/src/ftinspect/engine/engine.cpp @@ -401,12 +401,20 @@ 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; @@ -415,6 +423,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; @@ -459,6 +470,29 @@ Engine::currentStyleName() return curStyleName; } +const QString& +Engine::currentPostscriptName() +{ + return postscriptName; +} + +const QString& +Engine::DriverName() +{ + return driverName; +} + +const QString& +Engine::issfntwrapped() +{ + return issfnt; +} + +FT_Size +Engine::getftSize() +{ + return ftSize; +} QString Engine::glyphName(int index) diff --git a/src/ftinspect/engine/engine.hpp b/src/ftinspect/engine/engine.hpp index 175e8db..efe8f0e 100644 --- a/src/ftinspect/engine/engine.hpp +++ b/src/ftinspect/engine/engine.hpp @@ -46,6 +46,12 @@ public: const QString& currentFamilyName(); const QString& currentStyleName(); + const QString& currentPostscriptName(); + const QString& DriverName(); + const QString& issfntwrapped(); + FT_Size getftSize(); + FT_Size ftSize; + QString glyphName(int glyphIndex); long numberOfFaces(int fontIndex); int numberOfNamedInstances(int fontIndex, @@ -81,6 +87,9 @@ private: QString curFamilyName; QString curStyleName; + QString postscriptName; + QString driverName; + QString issfnt; FT_Library library; FTC_Manager cacheManager; @@ -88,7 +97,6 @@ private: FTC_SBitCache sbitsCache; FTC_ScalerRec scaler; - FT_Size ftSize; int cffHintingEngineDefault; int cffHintingEngineOther; diff --git a/src/ftinspect/ftdump.cpp b/src/ftinspect/ftdump.cpp index 6a13d76..9b1b317 100644 --- a/src/ftinspect/ftdump.cpp +++ b/src/ftinspect/ftdump.cpp @@ -1,14 +1,194 @@ -#include "ftdump.h" -#include "ui_ftdump.h" +#include "ftdump.hpp" -ftdump::ftdump(QWidget *parent) : - QDialog(parent), - ui(new Ui::ftdump) +#include +#include +#include +#include +#include +#include +#include +#include + +#include FT_FREETYPE_H +#include FT_DRIVER_H +#include FT_TRUETYPE_TABLES_H +#include FT_TRUETYPE_IDS_H + +ftdump::ftdump() { - ui->setupUi(this); + } +QString +ftdump::platform_id( int id ) + { + switch ( id ) + { + case TT_PLATFORM_APPLE_UNICODE: + return "Apple (Unicode)"; + case TT_PLATFORM_MACINTOSH: + return "Macintosh"; + case TT_PLATFORM_ISO: + return "ISO (deprecated)"; + case TT_PLATFORM_MICROSOFT: + return "Microsoft"; + case TT_PLATFORM_CUSTOM: + return "custom"; + case TT_PLATFORM_ADOBE: + return "Adobe"; + + default: + return "UNKNOWN"; + } + } + ftdump::~ftdump() { - delete ui; + // +} + +void ftdump::createLayout(Engine* engine) +{ + familyNameLabel = new QLabel(tr("Family : %1") + .arg(engine->currentFamilyName())); + styleLabel = new QLabel(tr("Style : %1") + .arg(engine->currentStyleName())); + postScriptLabel = new QLabel(tr("postscript: %1") + .arg(engine->currentPostscriptName())); + + infoLeftLayout = new QHBoxLayout; + + fontNameTabLayout = new QVBoxLayout; + fontNameTabLayout->addWidget(familyNameLabel); + fontNameTabLayout->addWidget(styleLabel); + fontNameTabLayout->addWidget(postScriptLabel); + + fontNameTabWidget = new QWidget; + fontNameTabWidget->setLayout(fontNameTabLayout); + + + FT_Face face = engine->ftSize->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"; + } + + ftDriverLabel = new QLabel(tr(" FreeType driver : %1") + .arg(engine->DriverName())); + issfntwrappedLabel = new QLabel(tr(" sfnt wrapped : %1") + .arg(FT_IS_SFNT( face ) ? QString("yes") : QString("no"))); + fontTypeLabel = new QLabel(tr("Type : %1") + .arg(fontType)); + directionLabel = new QLabel(tr("Direction : %1") + .arg(direction)); + fixedWidthLabel = new QLabel(tr("Fixed width : %1") + .arg(FT_IS_FIXED_WIDTH(face) ? QString("yes") : QString("no"))); + glyphNameLabel = new QLabel(tr("Glyph names : %1") + .arg(FT_HAS_GLYPH_NAMES( face ) ? QString("yes") : QString("no"))); + + fontTypeInfoTabLayout = new QVBoxLayout; + fontTypeInfoTabLayout->addWidget(ftDriverLabel); + fontTypeInfoTabLayout->addWidget(issfntwrappedLabel); + fontTypeInfoTabLayout->addWidget(fontTypeLabel); + fontTypeInfoTabLayout->addWidget(directionLabel); + fontTypeInfoTabLayout->addWidget(glyphNameLabel); + + if( FT_IS_SCALABLE( face )) + { + EMsizeLabel = new QLabel(tr("EM size : %1") + .arg(face->units_per_EM)); + BBoxLabel = new QLabel(tr("Global BBox : (%2, %3):(%4, %5)") + .arg(face->bbox.xMin) + .arg(face->bbox.yMin) + .arg(face->bbox.xMax) + .arg(face->bbox.yMax)); + ascentLabel = new QLabel(tr("Ascent : %1") + .arg(face->ascender)); + descentLabel = new QLabel(tr("Descent : %1") + .arg(face->descender)); + heightLabel = new QLabel(tr("Height : %1") + .arg(face->height)); + + fontTypeInfoTabLayout->addWidget(EMsizeLabel); + fontTypeInfoTabLayout->addWidget(BBoxLabel); + fontTypeInfoTabLayout->addWidget(ascentLabel); + fontTypeInfoTabLayout->addWidget(descentLabel); + fontTypeInfoTabLayout->addWidget(heightLabel); + } + + fontTypeTabWidget = new QWidget; + fontTypeTabWidget->setLayout(fontTypeInfoTabLayout); + + charmapsInfoTabLayout = new QVBoxLayout; + + for( int i=0; i < face->num_charmaps; i++) + { + formatLabel = new QLabel(tr("Format : %1") + .arg(FT_Get_CMap_Format( face->charmaps[i] ))); + platformLabel = new QLabel(tr(" Platform : %1") + .arg(platform_id(face->charmaps[i]->platform_id))); + encodingLabel = new QLabel(tr("Encoding : %1") + .arg(face->charmaps[i]->platform_id)); + languageLabel = new QLabel(tr("Language : %1") + .arg(FT_Get_CMap_Language_ID(face->charmaps[i]))); + + charmapsInfoTabLayout->addWidget(formatLabel); + charmapsInfoTabLayout->addWidget(platformLabel); + charmapsInfoTabLayout->addWidget(encodingLabel); + charmapsInfoTabLayout->addWidget(languageLabel); + } + + charmapsInfoTabWidget = new QWidget; + charmapsInfoTabWidget->setLayout(charmapsInfoTabLayout); + + tabWidget = new QTabWidget; + tabWidget->addTab(fontNameTabWidget, tr("Font Name")); + tabWidget->addTab(fontTypeTabWidget, tr("Font Type")); + tabWidget->addTab(charmapsInfoTabWidget, tr("Charmaps Info")); + + leftLayout = new QVBoxLayout; + leftLayout->addLayout(infoLeftLayout); + leftLayout->addWidget(tabWidget); + + leftWidget = new QWidget; + leftWidget->setLayout(leftLayout); + + QSizePolicy leftWidgetPolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + leftWidgetPolicy.setHorizontalStretch(0); + leftWidgetPolicy.setVerticalPolicy(leftWidget->sizePolicy().verticalPolicy()); + leftWidgetPolicy.setHeightForWidth(leftWidget->sizePolicy().hasHeightForWidth()); + + leftWidget->setSizePolicy(leftWidgetPolicy); + leftWidget->setMinimumSize(500, 200); + + ftinspectLayout = new QHBoxLayout; + ftinspectLayout->addWidget(leftWidget); + + this->setLayout(ftinspectLayout); + setWindowTitle("FTdump"); } diff --git a/src/ftinspect/ftdump.hpp b/src/ftinspect/ftdump.hpp index 34d9b0f..bf700a2 100644 --- a/src/ftinspect/ftdump.hpp +++ b/src/ftinspect/ftdump.hpp @@ -1,22 +1,110 @@ #ifndef FTDUMP_H #define FTDUMP_H +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace Ui { -class ftdump; -} +//////////////////////////// +/// \brief The ftdump class +/// + +#include "engine/engine.hpp" + +#include +#include FT_LCD_FILTER_H class ftdump : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit ftdump(QWidget *parent = nullptr); - ~ftdump(); + ftdump(); + ~ftdump(); + void createLayout(Engine* engine); + QString platform_id(int); private: - Ui::ftdump *ui; + + QLabel *familyNameLabel; + QLabel *fontTypeLabel; + QLabel *issfntwrappedLabel; + QLabel *styleLabel; + QLabel *postScriptLabel; + QLabel *ftDriverLabel; + QLabel *directionLabel; + QLabel *fixedWidthLabel; + QLabel *glyphNameLabel; + QLabel *EMsizeLabel; + QLabel *BBoxLabel; + QLabel *ascentLabel; + QLabel *descentLabel; + QLabel *heightLabel; + QLabel *platformLabel; + QLabel *formatLabel; + QLabel *encodingLabel; + QLabel *languageLabel; + + QTabWidget *tabWidget; + + QVBoxLayout *fontNameInfoTabLayout; + QVBoxLayout *fontTypeInfoTabLayout; + QVBoxLayout *charmapsInfoTabLayout; + + QWidget *fontNameInfoTabWidget; + + ////////////////////////////////////////////// + + QHBoxLayout *ftinspectLayout; + QHBoxLayout *hintingModeLayout; + QHBoxLayout *horizontalHintingLayout; + QHBoxLayout *infoLeftLayout; + QHBoxLayout *navigationLayout; + + + + + + + + + + QVBoxLayout *fontNameTabLayout; + QVBoxLayout *leftLayout; + QVBoxLayout *rightLayout; + + + QWidget *charmapsInfoTabWidget; + QWidget *ftinspectWidget; + QWidget *fontNameTabWidget; + QWidget *leftWidget; + QWidget *rightWidget; + QWidget *fontTypeTabWidget; + }; #endif // FTDUMP_H diff --git a/src/ftinspect/ftinspect.pro b/src/ftinspect/ftinspect.pro index 6538438..f2aec35 100644 --- a/src/ftinspect/ftinspect.pro +++ b/src/ftinspect/ftinspect.pro @@ -34,7 +34,8 @@ SOURCES += \ widgets/qpushbuttonx.cpp \ widgets/qspinboxx.cpp \ ftinspect.cpp \ - maingui.cpp + maingui.cpp \ + ftdump.cpp HEADERS += \ engine/engine.hpp \ @@ -47,7 +48,8 @@ HEADERS += \ widgets/qgraphicsviewx.hpp \ widgets/qpushbuttonx.hpp \ widgets/qspinboxx.hpp \ - maingui.hpp + maingui.hpp \ + ftdump.hpp TARGET = ftinspect @@ -55,3 +57,5 @@ QT += widgets # end of ftinpect.pro + +FORMS += diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp index 7fd185f..fef4ae0 100644 --- a/src/ftinspect/maingui.cpp +++ b/src/ftinspect/maingui.cpp @@ -5,6 +5,7 @@ #include "maingui.hpp" #include "rendering/grid.hpp" +#include "ftdump.hpp" #include #include @@ -13,6 +14,7 @@ #include #include FT_DRIVER_H +#include FT_TRUETYPE_TABLES_H MainGUI::MainGUI() @@ -59,6 +61,23 @@ MainGUI::closeEvent(QCloseEvent* event) event->accept(); } +void +MainGUI::showFontInfo() +{ + + if(engine->ftSize != NULL) + { + fontInfo = new ftdump(); + fontInfo->createLayout(engine); + fontInfo->show(); + } + else + QMessageBox::warning( + this, + tr("Font File not loaded"), + tr("To use this function first load a
" + "valid font file.")); +} void MainGUI::about() @@ -1130,10 +1149,13 @@ MainGUI::createActions() closeFontAct->setShortcuts(QKeySequence::Close); connect(closeFontAct, SIGNAL(triggered()), SLOT(closeFont())); - exitAct = new QAction(tr("E&xit"), this); + exitAct = new QAction(tr("&Exit"), this); exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), SLOT(close())); + showFontInfoAct = new QAction(tr("&ftdump")); + connect(showFontInfoAct, SIGNAL(triggered()), SLOT(showFontInfo())); + aboutAct = new QAction(tr("&About"), this); connect(aboutAct, SIGNAL(triggered()), SLOT(about())); @@ -1150,6 +1172,9 @@ MainGUI::createMenus() menuFile->addAction(closeFontAct); menuFile->addAction(exitAct); + menuInfo = menuBar()->addMenu(tr("&Font Info")); + menuInfo->addAction(showFontInfoAct); + menuHelp = menuBar()->addMenu(tr("&Help")); menuHelp->addAction(aboutAct); menuHelp->addAction(aboutQtAct); diff --git a/src/ftinspect/maingui.hpp b/src/ftinspect/maingui.hpp index 8ad6c30..24e5d10 100644 --- a/src/ftinspect/maingui.hpp +++ b/src/ftinspect/maingui.hpp @@ -6,6 +6,7 @@ #pragma once #include "engine/engine.hpp" +#include "ftdump.hpp" #include "rendering/glyphbitmap.hpp" #include "rendering/glyphoutline.hpp" #include "rendering/glyphpointnumbers.hpp" @@ -64,12 +65,17 @@ public: FT_Pointer, FT_Face*); + Engine* engine; protected: void closeEvent(QCloseEvent*); private slots: void about(); void aboutQt(); +// void showCharmapsInfo(); +// void showFontType(); +// void showFontName(); + void showFontInfo(); void adjustGlyphIndex(int); void checkAntiAliasing(); void checkAutoHinting(); @@ -94,7 +100,7 @@ private slots: void zoom(); private: - Engine* engine; + ftdump* fontInfo; QStringList fontList; int currentFontIndex; @@ -119,6 +125,9 @@ private: QAction *aboutAct; QAction *aboutQtAct; +// QAction *showCharmapsInfoAct; + QAction *showFontInfoAct; +// QAction *showFontNameAct; QAction *closeFontAct; QAction *exitAct; QAction *loadFontsAct; @@ -186,6 +195,7 @@ private: QLocale *locale; QMenu *menuFile; + QMenu *menuInfo; QMenu *menuHelp; QPen axisPen;