[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] veeki-gsoc-experimental 773746c: Fixed base line and o
From: |
Veeki Yadav |
Subject: |
[freetype2-demos] veeki-gsoc-experimental 773746c: Fixed base line and other minor issues |
Date: |
Sun, 11 Aug 2019 02:08:29 -0400 (EDT) |
branch: veeki-gsoc-experimental
commit 773746c7eaaaffc4ed32a46f68b217fe88dd86e3
Author: gevic <address@hidden>
Commit: gevic <address@hidden>
Fixed base line and other minor issues
---
src/common.c | 7 +-
src/ftdiff.c | 23 +--
src/ftinspect/engine/engine.cpp | 77 ++++++++
src/ftinspect/engine/engine.hpp | 1 +
src/ftinspect/maingui.cpp | 340 +++++++++++++++++++++++++++++----
src/ftinspect/maingui.hpp | 11 ++
src/ftinspect/rendering/comparator.cpp | 46 +++--
src/ftinspect/rendering/view.cpp | 143 +++++++++++---
src/ftinspect/rendering/view.hpp | 2 +
9 files changed, 545 insertions(+), 105 deletions(-)
diff --git a/src/common.c b/src/common.c
index 1960165..aa688f3 100644
--- a/src/common.c
+++ b/src/common.c
@@ -91,7 +91,7 @@
if ( (const char*)p >= end || ( p[0] & 0xc0 ) != 0x80 )
goto BAD_DATA;
- ch = ( ch << 6 ) | ( p[0] & 0x3f );
+ ch = ( ch << 6 ) | ( p[0] & 0x3f );
p += 1;
len -= 1;
}
@@ -105,5 +105,10 @@
return -1;
}
+ if (the condition is true)
+ {
+ return 1;
+ }
+
/* End */
diff --git a/src/ftdiff.c b/src/ftdiff.c
index d0489ce..c312e09 100644
--- a/src/ftdiff.c
+++ b/src/ftdiff.c
@@ -118,24 +118,11 @@
static const char* default_text =
- "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras sit amet"
- " dui. Nam sapien. Fusce vestibulum ornare metus. Maecenas ligula orci,"
- " consequat vitae, dictum nec, lacinia non, elit. Aliquam iaculis"
- " molestie neque. Maecenas suscipit felis ut pede convallis malesuada."
- " Aliquam erat volutpat. Nunc pulvinar condimentum nunc. Donec ac sem vel"
- " leo bibendum aliquam. Pellentesque habitant morbi tristique senectus et"
- " netus et malesuada fames ac turpis egestas.\n"
- "\n"
- "Sed commodo. Nulla ut libero sit amet justo varius blandit. Mauris vitae"
- " nulla eget lorem pretium ornare. Proin vulputate erat porta risus."
- " Vestibulum malesuada, odio at vehicula lobortis, nisi metus hendrerit"
- " est, vitae feugiat quam massa a ligula. Aenean in tellus. Praesent"
- " convallis. Nullam vel lacus. Aliquam congue erat non urna mollis"
- " faucibus. Morbi vitae mauris faucibus quam condimentum ornare. Quisque"
- " sit amet augue. Morbi ullamcorper mattis enim. Aliquam erat volutpat."
- " Morbi nec felis non enim pulvinar lobortis. Ut libero. Nullam id orci"
- " quis nisl dapibus rutrum. Suspendisse consequat vulputate leo. Aenean"
- " non orci non tellus iaculis vestibulum. Sed neque.\n"
+ "One popular and recognizable form of hinting is found in the TrueType"
+ "font format, released in 1991 by Apple Inc. Hinting in TrueType invokes"
+ "tables of font data used to render fonts properly on screen. One aspect"
+ "of TrueType hinting is grid-fitting, which modifies the height and width"
+ "of font characters to line up to the set pixel grid of screen display."
"\n";
diff --git a/src/ftinspect/engine/engine.cpp b/src/ftinspect/engine/engine.cpp
index bd2b39c..2e5c552 100644
--- a/src/ftinspect/engine/engine.cpp
+++ b/src/ftinspect/engine/engine.cpp
@@ -282,6 +282,7 @@ Engine::Engine(MainGUI* g)
Engine::~Engine()
{
FTC_Manager_Done(cacheManager);
+ //FT_Done_Face(getFtSize()->face);
FT_Done_FreeType(library);
}
@@ -466,6 +467,82 @@ Engine::removeFont(int fontIndex)
}
}
+int
+Engine::debugEngine(QStringList fontList)
+{
+ FT_Face f;
+ FT_Library lib;
+ int num_glyphs;
+ FT_Error error;
+ static int ptsize = 20;
+ int Fail;
+
+ error = FT_Init_FreeType( &lib );
+
+ /* try to open the file with no extra extension first */
+ error = FT_New_Face(library,
+ fontList[0].toLatin1().constData(),
+ 0,
+ &f);
+
+ if (!error)
+ {
+ num_glyphs = (unsigned int)f->num_glyphs;
+ }
+
+ if ( error == FT_Err_Unknown_File_Format )
+ {
+ return 0;
+ }
+
+ error = FT_Set_Char_Size( f, ptsize << 6, ptsize << 6, 72, 72 );
+ if (error)
+ {
+ return 0;
+ }
+
+ Fail = 0;
+ {
+ for ( int id = 0; id < num_glyphs; id++ )
+ {
+ error = FT_Load_Glyph( f, id, FT_LOAD_DEFAULT );
+ if (error)
+ {
+ if ( Fail < 10 )
+ {
+
+ }
+ //printf( "glyph %4u: 0x%04x\n" , id, error );
+ Fail++;
+ }
+ }
+ }
+
+ if ( Fail == 0 )
+ {
+
+ }
+ //printf( "OK.\n" );
+ else
+ {
+ if ( Fail == 1 )
+ {
+
+ }
+ //printf( "1 fail.\n" );
+ else
+ {
+
+ }
+ //printf( "%d fails.\n", Fail );
+ }
+
+FT_Done_Face( f );
+
+FT_Done_FreeType(lib);
+exit( 0 ); /* for safety reasons */
+}
+
const QString&
Engine::currentFamilyName()
diff --git a/src/ftinspect/engine/engine.hpp b/src/ftinspect/engine/engine.hpp
index eb81939..c69bb93 100644
--- a/src/ftinspect/engine/engine.hpp
+++ b/src/ftinspect/engine/engine.hpp
@@ -59,6 +59,7 @@ public:
int namedInstanceIndex); // return number of glyphs
FT_Outline* loadOutline(int glyphIndex);
void removeFont(int fontIndex);
+ int debugEngine(QStringList fontList);
void setCFFHintingMode(int mode);
void setWarping();
FT_Size getFtSize();
diff --git a/src/ftinspect/maingui.cpp b/src/ftinspect/maingui.cpp
index 743347a..8ba414f 100644
--- a/src/ftinspect/maingui.cpp
+++ b/src/ftinspect/maingui.cpp
@@ -68,10 +68,10 @@ 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")
+ tr("<pre><b>Face number : %1 </b><br><br>"
+ "Family : <em>%2</em> <br>"
+ "Style : <em>%3</em> <br>"
+ "Postscript : <em>%4</em></pre><br>")
.arg(fontList.size())
.arg(engine->currentFamilyName())
.arg(engine->currentStyleName())
@@ -105,18 +105,18 @@ MainGUI::showFontType()
{
if (FT_HAS_VERTICAL( face ))
{
- direction = " horizontal vertical";
+ direction = "horizontal vertical";
}
else
{
- direction = " horizontal";
+ direction = "horizontal";
}
}
else
{
if (FT_HAS_VERTICAL( face ))
{
- direction = " vertical";
+ direction = "vertical";
}
}
@@ -124,19 +124,19 @@ MainGUI::showFontType()
{
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>")
+ tr("<pre><b>Face number : %1</b><br><br>"
+ "FreeType driver : <em>%2</em><br>"
+ "SFNT wrapped : <em>%3</em><br>"
+ "Type : <em>%4</em><br>"
+ "Direction : <em>%5</em><br>"
+ "Fixed Width : <em>%6</em><br>"
+ "Glyph Names : <em>%7</em><br></pre>"
+ "<pre><b>Scalability Properties</b><br><br>"
+ "EM size : <em>%9</em><br>"
+ "Global BBox : <em>(%10, %11):(%12,
%13)</em><br>"
+ "Ascent : <em>%14</em><br>"
+ "Descent : <em>%15</em><br>"
+ "Text Height : <em>%16</em></pre><br>")
.arg(fontList.size())
.arg(engine->DriverName())
.arg(FT_IS_SFNT( face ) ? QString("yes") : QString("no"))
@@ -158,13 +158,13 @@ MainGUI::showFontType()
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>")
+ tr("<pre><b>Face number : %1</b><br><br>"
+ "FreeType driver : <em>%2</em><br>"
+ "SFNT wrapped : <em>%3</em><br>"
+ "Type : <em>%4</em><br>"
+ "Direction : <em>%5</em><br>"
+ "Fixed Width : <em>%6</em><br>"
+ "Glyph Names : <em>%7</em><br></pre>")
.arg(fontList.size())
.arg(engine->DriverName())
.arg(FT_IS_SFNT( face ) ? QString("yes") : QString("no"))
@@ -177,6 +177,198 @@ MainGUI::showFontType()
void
+MainGUI::showTablesListInfo()
+{
+ FT_ULong num_tables, i;
+ FT_ULong tag, length;
+ FT_Byte buffer[4];
+ FT_Face face = engine->getFtSize()->face;
+
+ FT_Sfnt_Table_Info( face, 0, NULL, &num_tables );
+ QMessageBox msgBox;
+ //msgBox.setWindowTitle("SFNT Tables List");
+ QString tablesinfo = "<pre><b>SFNT Tables List</b></pre>";
+
+ tablesinfo.append("<pre><b>S No.</b> <b>Tags</b>
<b>Buffer</b></pre>");
+
+ for ( i = 0; i < num_tables; i++ )
+ {
+ FT_Sfnt_Table_Info( face, (FT_UInt)i, &tag, &length );
+
+ if ( length >= 4 )
+ {
+ length = 4;
+ FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
+ }
+ else
+ {
+ continue;
+ }
+
+ tablesinfo.append(QString("<pre>%1 : <em>%2 %3 %4 %5
%6 %7 %8 %9</em></pre>").arg(i)
+
.arg((FT_Char)( tag >> 24 ))
+
.arg((FT_Char)( tag >> 16 ))
+
.arg((FT_Char)( tag >> 8 ))
+
.arg((FT_Char)( tag ))
+
.arg((FT_UInt)buffer[0])
+
.arg((FT_UInt)buffer[1])
+
.arg((FT_UInt)buffer[2])
+
.arg((FT_UInt)buffer[3]));
+ }
+
+ QMessageBox::about(this, "SFNT Tables List", tablesinfo);
+}
+
+
+void
+MainGUI::showTablesInfo()
+{
+ FT_SfntName name;
+ FT_UInt num_names, i;
+ FT_Face face = engine->getFtSize()->face;
+ FT_Error error;
+
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("SFNT Tables");
+ QString tablesinfo = "<b>SFNT Tables</b><br>";// =
QString("%1").arg(desc.idVendor, 0, 16).rightJustified(4, '0');
+
+ //printf( "font string entries\n" );
+ tablesinfo.append(QString("<pre><b>Name ID</b> <b>Platform ID</b>
<b>Encoding ID</b></pre>"));
+
+ num_names = FT_Get_Sfnt_Name_Count( face );
+ for ( i = 0; i < num_names; i++ )
+ {
+ error = FT_Get_Sfnt_Name( face, i, &name );
+ if ( error == FT_Err_Ok )
+ {
+ const short unsigned int NameID = name.name_id;
+ const short unsigned int PlatformID = name.platform_id;
+
+ if ( NameID )
+ {
+ //printf( " %-15s [%s]", NameID, PlatformID );
+ if (NameID < 10)
+ {
+ tablesinfo.append(QString("<pre>%1 [%2]
").arg(NameID).arg(PlatformID));
+ } else if (NameID < 100)
+ {
+ tablesinfo.append(QString("<pre>%1 [%2]
").arg(NameID).arg(PlatformID));
+ } else if (NameID < 1000)
+ {
+ tablesinfo.append(QString("<pre>%1 [%2]
").arg(NameID).arg(PlatformID));
+ }
+ }
+ else
+ {
+ //printf( " Name ID %-5d [%s]", name.name_id, PlatformID );
+ tablesinfo.append(QString("Name ID %1
[%2]").arg(NameID).arg(PlatformID));
+ }
+ }
+
+
+ switch ( name.platform_id )
+ {
+ case TT_PLATFORM_APPLE_UNICODE:
+ //fputs( ":\n", stdout );
+ //tablesinfo.append("<pre> : </pre>");
+ switch ( name.encoding_id )
+ {
+ case TT_APPLE_ID_DEFAULT:
+ case TT_APPLE_ID_UNICODE_1_1:
+ case TT_APPLE_ID_ISO_10646:
+ //case TT_APPLE_ID_UNICODE_2_0:
+ //put_unicode_be16( name.string, name.string_len, 6, utf8 );
+ //break;
+
+ default:
+ //printf( "{unsupported Unicode encoding %d}", name.encoding_id );
+ tablesinfo.append(QString("unsupported Unicode encoding
%1").arg(name.encoding_id));
+ break;
+ }
+ break;
+
+ case TT_PLATFORM_MACINTOSH:
+ if ( name.language_id != TT_MAC_LANGID_ENGLISH )
+ {
+ tablesinfo.append(QString("(language=%1)").arg(name.language_id));
+ }
+ //printf( " (language=%u)", name.language_id );
+ //tablesinfo.append(":");
+
+ switch ( name.encoding_id )
+ {
+ //case TT_MAC_ID_ROMAN:
+ /* FIXME: convert from MacRoman to ASCII/ISO8895-1/whatever */
+ /* (MacRoman is mostly like ISO8895-1 but there are */
+ /* differences) */
+ //put_ascii( name.string, name.string_len, 6 );
+ //break;
+
+ default:
+ //printf( " [data in encoding %d]", name.encoding_id );
+ tablesinfo.append(QString("[data in encoding
%1]").arg(name.encoding_id));
+ break;
+ }
+ break;
+
+ case TT_PLATFORM_ISO:
+ //tablesinfo.append(":");
+ switch ( name.encoding_id )
+ {
+ case TT_ISO_ID_7BIT_ASCII:
+ //case TT_ISO_ID_8859_1:
+ // put_ascii( name.string, name.string_len, 6 );
+ // break;
+
+ //case TT_ISO_ID_10646:
+ //put_unicode_be16( name.string, name.string_len, 6, utf8 );
+ //break;
+
+ default:
+ //printf( "{unsupported encoding %d}", name.encoding_id );
+ tablesinfo.append(QString("{unsupported encoding
%1}").arg(name.encoding_id));
+ break;
+ }
+ break;
+
+ case TT_PLATFORM_MICROSOFT:
+ if ( name.language_id != TT_MS_LANGID_ENGLISH_UNITED_STATES )
+ {
+ //printf( " (language=0x%04x)", name.language_id );
+ tablesinfo.append(QString("{(language=%1)}").arg(name.language_id));
+ }
+ //fputs( ":\n", stdout );
+ //tablesinfo.append(":");
+
+ switch ( name.encoding_id )
+ {
+ /* TT_MS_ID_SYMBOL_CS is Unicode, similar to PID/EID=3/1 */
+ case TT_MS_ID_SYMBOL_CS:
+ // case TT_MS_ID_UNICODE_CS:
+ // put_unicode_be16( name.string, name.string_len, 6, utf8 );
+ // break;
+
+ default:
+ //printf( "{unsupported encoding %d}", name.encoding_id );
+ tablesinfo.append(QString("{unsupported encoding
%1}").arg(name.encoding_id));
+ break;
+ }
+ break;
+
+ default:
+ //printf( "{unsupported platform}" );
+ tablesinfo.append(QString("{unsupported platform}"));
+ break;
+ }
+
+ //stablesinfo.append("<br>");
+ }
+
+ QMessageBox::about(this, "SFNT Tables", tablesinfo);
+ }
+
+
+void
MainGUI::showCharmapsInfo()
{
FT_Face face = engine->getFtSize()->face;
@@ -186,10 +378,10 @@ MainGUI::showCharmapsInfo()
QMessageBox::about(
this,
tr("Charmaps Info"),
- tr("Format : %1<br>"
- "Platform : %2<br>"
- "Encoding : %3<br>"
- "Language : %4<br>")
+ tr("<pre>Format : <em>%1</em></pre>"
+ "<pre>Platform : <em>%2</em></pre>"
+ "<pre>Encoding : <em>%3</em></pre>"
+ "<pre>Language : <em>%4</em></pre>")
.arg(FT_Get_CMap_Format( face->charmaps[i] ))
.arg(face->charmaps[i]->platform_id)
.arg(face->charmaps[i]->encoding_id)
@@ -672,6 +864,34 @@ MainGUI::comparatorViewRender()
}
+ // Diable unused parameters
+ showPointNumbersCheckBox->setEnabled(false);
+ showBitmapCheckBox->setEnabled(false);
+ showPointsCheckBox->setEnabled(false);
+ showOutlinesCheckBox->setEnabled(false);
+ navigationLayout->setEnabled(false);
+
+ showPointNumbersCheckBox->setChecked(false);
+ showBitmapCheckBox->setChecked(false);
+ showPointsCheckBox->setChecked(false);
+ showOutlinesCheckBox->setChecked(false);
+
+ // diable glyph buttons
+ toStartButtonx->setEnabled(false);
+ toM1000Buttonx->setEnabled(false);
+ toM100Buttonx->setEnabled(false);
+ toM10Buttonx->setEnabled(false);
+ toM1Buttonx->setEnabled(false);
+ toP1Buttonx->setEnabled(false);
+ toP10Buttonx->setEnabled(false);
+ toP100Buttonx->setEnabled(false);
+ toP1000Buttonx->setEnabled(false);
+ toEndButtonx->setEnabled(false);
+
+ fontNameLabel->setEnabled(false);
+ glyphNameLabel->setEnabled(false);
+ glyphIndexLabel->setEnabled(false);
+
currentComparatorItem = new Comparator(engine->library,
size->face,
size,
@@ -710,7 +930,26 @@ MainGUI::gridViewRender()
currentComparatorItem = NULL;
}
-
+ // enable parameters
+ showPointNumbersCheckBox->setEnabled(true);
+ showBitmapCheckBox->setEnabled(true);
+ showPointsCheckBox->setEnabled(true);
+ showOutlinesCheckBox->setEnabled(true);
+
+ toStartButtonx->setEnabled(true);
+ toM1000Buttonx->setEnabled(true);
+ toM100Buttonx->setEnabled(true);
+ toM10Buttonx->setEnabled(true);
+ toM1Buttonx->setEnabled(true);
+ toP1Buttonx->setEnabled(true);
+ toP10Buttonx->setEnabled(true);
+ toP100Buttonx->setEnabled(true);
+ toP1000Buttonx->setEnabled(true);
+ toEndButtonx->setEnabled(true);
+
+ fontNameLabel->setEnabled(true);
+ glyphNameLabel->setEnabled(true);
+ glyphIndexLabel->setEnabled(true);
currentGridItem = new Grid(gridPen, axisPen);
glyphScene->addItem(currentGridItem);
@@ -807,6 +1046,27 @@ MainGUI::renderAll()
currentComparatorItem = NULL;
}
+ showPointNumbersCheckBox->setChecked(false);
+ showBitmapCheckBox->setChecked(false);
+ showPointsCheckBox->setChecked(false);
+ showOutlinesCheckBox->setChecked(false);
+
+ // disable glyph buttons
+ toStartButtonx->setEnabled(false);
+ toM1000Buttonx->setEnabled(false);
+ toM100Buttonx->setEnabled(false);
+ toM10Buttonx->setEnabled(false);
+ toM1Buttonx->setEnabled(false);
+ toP1Buttonx->setEnabled(false);
+ toP10Buttonx->setEnabled(false);
+ toP100Buttonx->setEnabled(false);
+ toP1000Buttonx->setEnabled(false);
+ toEndButtonx->setEnabled(false);
+
+ fontNameLabel->setEnabled(false);
+ glyphNameLabel->setEnabled(false);
+ glyphIndexLabel->setEnabled(false);
+
/* now, draw to our target surface */
currentRenderAllItem = new RenderAll(size->face,
size,
@@ -817,6 +1077,7 @@ MainGUI::renderAll()
render_mode,
engine->scaler,
engine->imageCache,
+ fontList,
x_factor,
y_factor,
slant_factor,
@@ -1569,8 +1830,8 @@ MainGUI::createLayout()
tabWidget = new QTabWidget;
tabWidget->addTab(generalTabWidget, tr("General"));
tabWidget->addTab(mmgxTabWidget, tr("MM/GX"));
- tabWidget->addTab(viewTabWidget, tr("Ftview"));
- tabWidget->addTab(diffTabWidget, tr("Ftdiff"));
+ tabWidget->addTab(viewTabWidget, tr("Glyphs"));
+ tabWidget->addTab(diffTabWidget, tr("Columns"));
leftLayout = new QVBoxLayout;
leftLayout->addLayout(infoLeftLayout);
@@ -1894,6 +2155,12 @@ MainGUI::createActions()
showCharmapsInfoAct = new QAction(tr("&Charmap Info"), this);
connect(showCharmapsInfoAct, SIGNAL(triggered()), SLOT(showCharmapsInfo()));
+ showTablesSFNTAct = new QAction(tr("&SFNT Name Tables"), this);
+ connect(showTablesSFNTAct, SIGNAL(triggered()), SLOT(showTablesInfo()));
+
+ showNamesSFNTAct = new QAction(tr("&SFNT Tables List"), this);
+ connect(showNamesSFNTAct, SIGNAL(triggered()), SLOT(showTablesListInfo()));
+
aboutAct = new QAction(tr("&About"), this);
connect(aboutAct, SIGNAL(triggered()), SLOT(about()));
@@ -1914,6 +2181,11 @@ MainGUI::createMenus()
menuInfo->addAction(showFontNameAct);
menuInfo->addAction(showFontTypeAct);
menuInfo->addAction(showCharmapsInfoAct);
+ //if (FT_IS_SFNT( engine->getFtSize()->face ))
+ //{
+ menuInfo->addAction(showTablesSFNTAct);
+ // }
+ menuInfo->addAction(showNamesSFNTAct);
if (fontList.size() <= 0)
{
diff --git a/src/ftinspect/maingui.hpp b/src/ftinspect/maingui.hpp
index 48ec7e3..524e07f 100644
--- a/src/ftinspect/maingui.hpp
+++ b/src/ftinspect/maingui.hpp
@@ -51,6 +51,13 @@
#include FT_LCD_FILTER_H
#include FT_COLOR_H
+#include FT_FREETYPE_H
+#include FT_SFNT_NAMES_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_TRUETYPE_TAGS_H
+#include FT_MULTIPLE_MASTERS_H
+
class MainGUI
: public QMainWindow
@@ -77,6 +84,8 @@ private slots:
void about();
void aboutQt();
void showCharmapsInfo();
+ void showTablesInfo();
+ void showTablesListInfo();
void showFontType();
void showFontName();
void adjustGlyphIndex(int);
@@ -151,6 +160,8 @@ private:
QAction *exitAct;
QAction *loadFontsAct;
QAction *showCharmapsInfoAct;
+ QAction *showTablesSFNTAct;
+ QAction *showNamesSFNTAct;
QAction *showFontTypeAct;
QAction *showFontNameAct;
diff --git a/src/ftinspect/rendering/comparator.cpp
b/src/ftinspect/rendering/comparator.cpp
index f3e98a9..97656c0 100644
--- a/src/ftinspect/rendering/comparator.cpp
+++ b/src/ftinspect/rendering/comparator.cpp
@@ -14,25 +14,11 @@
#define HEADER_HEIGHT 12
static const char* default_text =
- "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras sit amet"
- " dui. Nam sapien. Fusce vestibulum ornare metus. Maecenas ligula orci,"
- " consequat vitae, dictum nec, lacinia non, elit. Aliquam iaculis"
- " molestie neque. Maecenas suscipit felis ut pede convallis malesuada."
- " Aliquam erat volutpat. Nunc pulvinar condimentum nunc. Donec ac sem vel"
- " leo bibendum aliquam. Pellentesque habitant morbi tristique senectus et"
- " netus et malesuada fames ac turpis egestas.\n"
- "\n"
- "Sed commodo. Nulla ut libero sit amet justo varius blandit. Mauris vitae"
- " nulla eget lorem pretium ornare. Proin vulputate erat porta risus."
- " Vestibulum malesuada, odio at vehicula lobortis, nisi metus hendrerit"
- " est, vitae feugiat quam massa a ligula. Aenean in tellus. Praesent"
- " convallis. Nullam vel lacus. Aliquam congue erat non urna mollis"
- " faucibus. Morbi vitae mauris faucibus quam condimentum ornare. Quisque"
- " sit amet augue. Morbi ullamcorper mattis enim. Aliquam erat volutpat."
- " Morbi nec felis non enim pulvinar lobortis. Ut libero. Nullam id orci"
- " quis nisl dapibus rutrum. Suspendisse consequat vulputate leo. Aenean"
- " non orci non tellus iaculis vestibulum. Sed neque.\n"
- "\n";
+ "One popular and recognizable form of hinting is found in the TrueType"
+ "font format, released in 1991 by Apple Inc. Hinting in TrueType invokes"
+ "tables of font data used to render fonts properly on screen. One aspect"
+ "of TrueType hinting is grid-fitting, which modifies the height and width"
+ "of font characters to line up to the set pixel grid of screen display";
Comparator::Comparator(FT_Library lib,
@@ -135,13 +121,13 @@ Comparator::paint(QPainter* painter,
/* error = FT_New_Face(library,
fontList[0].toLatin1().constData(),
0,
- &f);
+ &f);*/
error = FT_Set_Char_Size(face,
0,
16 * 64,
0,
- 72);*/
+ 72);
//column_y_start = 10 + 2 * HEADER_HEIGHT;
//column_height = height - 8 * HEADER_HEIGHT - 5;
@@ -155,11 +141,15 @@ Comparator::paint(QPainter* painter,
"warping",
&warping_col[col]);
+ int count = 0;
+
for ( int i = 0; i < length; i++ )
{
+
+ count += 1;
QChar ch = default_text[i];
- // get char index
+ // get char index
glyph_idx = FT_Get_Char_Index( face , ch.unicode());
if ( kerning[col] && glyph_idx != 0 && previous != 0 )
@@ -198,10 +188,18 @@ Comparator::paint(QPainter* painter,
glyphImage.setColorTable(colorTable);
} else
{
- glyphImage.setColorTable(grayColorTable);
+ glyphImage.setColorTable(colorTable);
+ }
+
+ FT_Pos bottom = 0;
+
+ if (count == 1)
+ {
+ FT_Pos bottom = face->glyph->metrics.height/64;
}
- painter->drawImage(column_x_start[col], height,
+
+ painter->drawImage(column_x_start[col], height + bottom -
face->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
diff --git a/src/ftinspect/rendering/view.cpp b/src/ftinspect/rendering/view.cpp
index 56a0df0..7b05067 100644
--- a/src/ftinspect/rendering/view.cpp
+++ b/src/ftinspect/rendering/view.cpp
@@ -13,6 +13,7 @@
/* special encoding to display glyphs in order */
#define FT_ENCODING_ORDER 0xFFFF
#define ft_encoding_unicode FT_ENCODING_UNICODE
+#define TRUNC(x) ((x) >> 6)
extern "C" {
@@ -164,6 +165,7 @@ RenderAll::RenderAll(FT_Face face,
int render_mode,
FTC_ScalerRec scaler,
FTC_ImageCache imageCache,
+ QStringList fontList,
double x,
double y,
double slant_factor,
@@ -179,6 +181,7 @@ library(lib),
mode(render_mode),
scaler(scaler),
imageCache(imageCache),
+fontList(fontList),
x_factor(x),
y_factor(y),
slant_factor(slant_factor),
@@ -223,9 +226,12 @@ RenderAll::paint(QPainter* painter,
// Normal rendering mode
if (mode == 1)
{
+
+ int count = 0;
// Normal rendering
for ( int i = 0; i < face->num_glyphs; i++ )
{
+ count += 1;
// get char index
//glyph_idx = FT_Get_Char_Index( face , (FT_ULong)i );
if ( face->charmap->encoding != FT_ENCODING_ORDER )
@@ -263,9 +269,14 @@ RenderAll::paint(QPainter* painter,
}
glyphImage.setColorTable(colorTable);
-
- painter->drawImage(x, y,
+ FT_Pos bottom = 0;
+ if (count == 1)
+ {
+ FT_Pos bottom = face->glyph->metrics.height/64;
+ }
+
+ painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
x += face->glyph->advance.x/64;
@@ -282,6 +293,7 @@ RenderAll::paint(QPainter* painter,
// Fancy rendering mode
if (mode == 2)
{
+ int count = 0;
// fancy render
FT_Matrix shear;
FT_Pos xstr, ystr;
@@ -296,6 +308,7 @@ RenderAll::paint(QPainter* painter,
for ( int i = 0; i < face->num_glyphs; i++ )
{
+ count += 1;
// get char index
//glyph_idx = FT_Get_Char_Index( face , (FT_ULong)i );
if ( face->charmap->encoding != FT_ENCODING_ORDER )
@@ -376,9 +389,13 @@ RenderAll::paint(QPainter* painter,
}
glyphImage.setColorTable(colorTable);
-
+ FT_Pos bottom = 0;
+ if (count == 1)
+ {
+ FT_Pos bottom = face->glyph->metrics.height/64;
+ }
- painter->drawImage(x, y,
+ painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
x += face->glyph->advance.x/64;
@@ -450,7 +467,7 @@ RenderAll::paint(QPainter* painter,
-/*
+
if ( !error && slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
@@ -459,16 +476,16 @@ RenderAll::paint(QPainter* painter,
FT_Glyph_StrokeBorder(&glyph, stroker, 0, 1);
- FT_Outline* outline = engine->loadOutline(glyph_idx); */
+ FT_Outline* outline = engine->loadOutline(glyph_idx);
- /* error = FT_Glyph_Stroke( &glyph, stroker, 1 );
+ error = FT_Glyph_Stroke( &glyph, stroker, 1 );
if ( error )
{
//FT_Done_Glyph( glyph );
break;
- } */
+ }
- /* error = FT_Get_Glyph( slot, &glyph );
+ error = FT_Get_Glyph( slot, &glyph );
if ( error )
break;
@@ -502,13 +519,15 @@ RenderAll::paint(QPainter* painter,
y += (size->metrics.height + 4)/64;
x = -350;
}
- //}*/
+ }
}
}
// Render String mode
if (mode == 4)
{
+
+ int count = 0;
FT_Pos lsb_delta = 0; /* delta caused by hinting */
FT_Pos rsb_delta = 0; /* delta caused by hinting */
const char* p;
@@ -541,6 +560,7 @@ RenderAll::paint(QPainter* painter,
for ( int i = 0; i < length; i++ )
{
+ count += 1;
QChar ch = Sample[3][i];
// get char index
@@ -568,11 +588,26 @@ RenderAll::paint(QPainter* painter,
/* load glyph image into the slot (erase previous one) */
error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
- if ( error )
+ if ( !error )
{
- break; /* ignore errors */
+
+ if (!error)
+ {
+ FT_Pos left = face->glyph->metrics.horiBearingX;
+ FT_Pos right = left + face->glyph->metrics.width;
+ FT_Pos top = face->glyph->metrics.horiBearingY;
+ FT_Pos bottom = top - face->glyph->metrics.height;
+
+ m_glyphRect = QRect(QPoint(TRUNC(left),
+ -TRUNC(top) + 1),
+ QSize(TRUNC(right - left) + 1,
+ TRUNC(top - bottom) + 1));
+ //setFixedSize(m_glyphRect.width(),m_glyphRect.height());
+ }
}
+ painter->translate(-m_glyphRect.x(),-m_glyphRect.y());
+
error = FT_Render_Glyph(face->glyph,
FT_RENDER_MODE_NORMAL);
@@ -582,6 +617,13 @@ RenderAll::paint(QPainter* painter,
face->glyph->bitmap.pitch,
QImage::Format_Indexed8);
+ painter->translate(m_glyphRect.x(),m_glyphRect.y());
+
+ FT_Pos bottom = 0;
+ if (count == 1)
+ {
+ FT_Pos bottom = face->glyph->metrics.height/64;
+ }
QVector<QRgb> colorTable;
for (int i = 0; i < 256; ++i)
@@ -590,7 +632,7 @@ RenderAll::paint(QPainter* painter,
}
glyphImage.setColorTable(colorTable);
- painter->drawImage(x, y,
+ painter->drawImage(x, y + bottom - face->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
if (previous)
@@ -611,6 +653,12 @@ RenderAll::paint(QPainter* painter,
FT_Pos track_kern = 0;
FT_Bool use_kerning;
y = -180;
+ FT_Face f;
+
+ error = FT_New_Face(library,
+ fontList[0].toLatin1().constData(),
+ 0,
+ &f);
int length = strlen(Sample[3]);
@@ -618,7 +666,7 @@ RenderAll::paint(QPainter* painter,
if ( kerning_degree )
{
/* this function needs and returns points, not pixels */
- if ( !FT_Get_Track_Kerning( face,
+ if ( !FT_Get_Track_Kerning( f,
(FT_Fixed)scaler.width << 10,
-kerning_degree,
&track_kern ) )
@@ -627,15 +675,30 @@ RenderAll::paint(QPainter* painter,
72.0 );
}
+ int i = 10;
+ int res = 16;
+ int space = 0;
+
while (y <= 200)
- {
+ {
+ res = res + i;
+ space += 1;
+
+ error = FT_Set_Char_Size(f,
+ 0,
+ 16 * 64,
+ 0,
+ res);
int m = 0;
FT_Pos lsb_delta = 0; /* delta caused by hinting */
FT_Pos rsb_delta = 0; /* delta caused by hinting */
FT_UInt previous;
+ int count = 0;
+
while ( m < length )
{
+ count = count + 1;
FT_Glyph glyph;
QChar ch = Sample[3][m];
@@ -643,7 +706,7 @@ RenderAll::paint(QPainter* painter,
// get char index
- glyph_idx = FT_Get_Char_Index( face , ch.unicode());
+ glyph_idx = FT_Get_Char_Index( f , ch.unicode());
x += track_kern;
@@ -651,7 +714,7 @@ RenderAll::paint(QPainter* painter,
{
FT_Vector delta;
- FT_Get_Kerning( face, previous, glyph_idx,
+ FT_Get_Kerning( f, previous, glyph_idx,
FT_KERNING_UNFITTED, &delta );
x += delta.x;
@@ -673,7 +736,7 @@ RenderAll::paint(QPainter* painter,
NULL);
/* load glyph image into the slot (erase previous one) */
- error = FT_Load_Glyph( face, glyph_idx, FT_LOAD_DEFAULT );
+ error = FT_Load_Glyph( f, glyph_idx, FT_LOAD_DEFAULT );
if ( error )
{
break; /* ignore errors */
@@ -683,13 +746,13 @@ RenderAll::paint(QPainter* painter,
if ( error )
break;
- error = FT_Render_Glyph(face->glyph,
+ error = FT_Render_Glyph(f->glyph,
FT_RENDER_MODE_NORMAL);
- QImage glyphImage(face->glyph->bitmap.buffer,
- face->glyph->bitmap.width,
- face->glyph->bitmap.rows,
- face->glyph->bitmap.pitch,
+ QImage glyphImage(f->glyph->bitmap.buffer,
+ f->glyph->bitmap.width,
+ f->glyph->bitmap.rows,
+ f->glyph->bitmap.pitch,
QImage::Format_Indexed8);
@@ -701,9 +764,15 @@ RenderAll::paint(QPainter* painter,
}
glyphImage.setColorTable(colorTable);
-
- painter->drawImage(x, y,
+ FT_Pos bottom = 0;
+ if (count == 1)
+ {
+ FT_Pos bottom = f->glyph->metrics.height/64;
+ }
+
+
+ painter->drawImage(x, y + bottom - f->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
if (previous)
@@ -712,16 +781,24 @@ RenderAll::paint(QPainter* painter,
rsb_delta = face->glyph->rsb_delta;
}
- x += face->glyph->advance.x/64;
+ x += f->glyph->advance.x/64;
if (x >= 350)
{
break;
}
previous = glyph_idx;
}
- y = y + 50;
+ if (space == 1)
+ {
+ y += 20;
+ } else
+ {
+ y = y + 25 + space;
+ }
+
x = -280;
}
+ FT_Done_Face(f);
}
// Kerning comparison
@@ -771,8 +848,11 @@ RenderAll::paint(QPainter* painter,
72.0 );
}
+ int count = 0;
for ( int i = 0; i < length; i++ )
{
+
+ count += 1;
QChar ch = Sample[line][i];
// get char index
@@ -820,9 +900,16 @@ RenderAll::paint(QPainter* painter,
{
colorTable << qRgba(0, 0, 0, i);
}
+
+ FT_Pos bottom = 0;
+
+ if (count == 1)
+ {
+ FT_Pos bottom = face->glyph->metrics.height/64;
+ }
glyphImage.setColorTable(colorTable);
- painter->drawImage(x, y,
+ painter->drawImage(x, y + bottom -
face->glyph->metrics.horiBearingY/64,
glyphImage, 0, 0, -1, -1);
if (previous)
diff --git a/src/ftinspect/rendering/view.hpp b/src/ftinspect/rendering/view.hpp
index 7ce8d50..82326dd 100644
--- a/src/ftinspect/rendering/view.hpp
+++ b/src/ftinspect/rendering/view.hpp
@@ -40,6 +40,7 @@ public:
int mode,
FTC_ScalerRec scaler,
FTC_ImageCache imageCache,
+ QStringList fontList,
double x_factor,
double y_factor,
double slant_factor,
@@ -66,6 +67,7 @@ private:
MainGUI* gui;
FTC_ScalerRec scaler;
FTC_ImageCache imageCache;
+ QStringList fontList;
double x_factor;
double y_factor;
double slant_factor;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] veeki-gsoc-experimental 773746c: Fixed base line and other minor issues,
Veeki Yadav <=