summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--freetype/fontfactoryttf_qws.cpp19
-rw-r--r--freetype/fontfactoryttf_qws.h3
-rw-r--r--freetype/freetype.pro2
-rw-r--r--freetype/freetypefactoryimpl.cpp2
-rw-r--r--freetype/opie-freetype.control2
5 files changed, 17 insertions, 11 deletions
diff --git a/freetype/fontfactoryttf_qws.cpp b/freetype/fontfactoryttf_qws.cpp
index 5aa53fb..1f082a9 100644
--- a/freetype/fontfactoryttf_qws.cpp
+++ b/freetype/fontfactoryttf_qws.cpp
@@ -20,68 +20,69 @@
#include "fontfactoryttf_qws.h"
#ifdef QT_NO_FREETYPE
#include "qfontdata_p.h"
#include <string.h>
#include <stdio.h>
#define FLOOR(x) ((x) & -64)
#define CEIL(x) (((x)+63) & -64)
#define TRUNC(x) ((x) >> 6)
extern "C" {
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_OUTLINE_H
-#include FT_BBOX_H
+#include <freetype/freetype.h>
+#include <freetype/ftglyph.h>
+#include <freetype/ftoutln.h>
+#include <freetype/ftbbox.h>
}
class QDiskFontFT : public QDiskFontPrivate {
public:
FT_Face face;
};
class QRenderedFontFT : public QRenderedFont {
public:
QRenderedFontFT(QDiskFont* f, const QFontDef &d) :
QRenderedFont(f,d)
{
QDiskFontFT *df = (QDiskFontFT*)(f->p);
myface=df->face;
selectThisSize();
// A 1-pixel baseline is excluded in Qt/Windows/X11 fontmetrics
// (see QFontMetrics::height())
//
fascent=CEIL(myface->size->metrics.ascender)/64;
fdescent=-FLOOR(myface->size->metrics.descender)/64-1;
fmaxwidth=CEIL(myface->size->metrics.max_advance)/64;
fleading=CEIL(myface->size->metrics.height)/64
- fascent - fdescent + 1;
// FT has these in font units
funderlinepos = ptsize/200+1;
funderlinewidth = ptsize/200+1;
}
~QRenderedFontFT()
{
+ // When inter-process glyph sharing is implemented, the glyph data
+ // for this font can be dereferenced here.
}
bool unicode(int & i) const
{
int ret;
FT_Face theface=myface;
ret=FT_Get_Char_Index(theface,i);
if (ret==0) {
return FALSE;
} else {
i=ret;
return TRUE;
}
@@ -95,33 +96,33 @@ public:
QGlyph render(QChar ch)
{
selectThisSize();
int index = ch.unicode();
if ( !unicode(index) )
index = 0;
QGlyph result;
FT_Error err;
err=FT_Load_Glyph(myface,index,FT_LOAD_DEFAULT);
if(err)
qFatal("Load glyph error %x",err);
- int width,height,pitch,size = 0;
+ int width=0,height=0,pitch=0,size=0;
FT_Glyph glyph;
err=FT_Get_Glyph( myface->glyph, &glyph );
if(err)
qFatal("Get glyph error %x",err);
FT_BBox bbox;
FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_gridfit, &bbox);
FT_Vector origin;
origin.x = -bbox.xMin;
origin.y = -bbox.yMin;
if ( FT_IS_SCALABLE(myface) ) {
err=FT_Glyph_To_Bitmap(&glyph,
smooth ? ft_render_mode_normal : ft_render_mode_mono,
&origin, 1); // destroy original glyph
@@ -142,32 +143,38 @@ public:
result.data = new uchar[0]; // XXX memory manage me
}
} else {
result.data = new uchar[0]; // XXX memory manage me
}
result.metrics = new QGlyphMetrics;
memset((char*)result.metrics, 0, sizeof(QGlyphMetrics));
result.metrics->bearingx=myface->glyph->metrics.horiBearingX/64;
result.metrics->advance=myface->glyph->metrics.horiAdvance/64;
result.metrics->bearingy=myface->glyph->metrics.horiBearingY/64;
result.metrics->linestep=pitch;
result.metrics->width=width;
result.metrics->height=height;
+ // XXX memory manage me
+ // At some point inter-process glyph data sharing must be implemented
+ // and the flag below can be set to prevent Qt from deleting the glyph
+ // data.
+ // result.metrics->flags = QGlyphMetrics::RendererOwnsData;
+
FT_Done_Glyph( glyph );
return result;
}
FT_Face myface;
private:
void selectThisSize()
{
int psize=(ptsize<<6)/10;
// Assume 72 dpi for now
const int dpi=72;
FT_Error err;
err=FT_Set_Char_Size(myface, psize,psize,dpi,dpi);
diff --git a/freetype/fontfactoryttf_qws.h b/freetype/fontfactoryttf_qws.h
index 4ba8ce5..208ab61 100644
--- a/freetype/fontfactoryttf_qws.h
+++ b/freetype/fontfactoryttf_qws.h
@@ -20,34 +20,33 @@
#ifndef FONTFACTORY_FT_H
#define FONTFACTORY_FT_H
#include <qfontmanager_qws.h>
#if QT_VERSION >= 300
# include <private/qfontdata_p.h>
#else
# include "qfontdata_p.h"
#endif
#ifdef QT_NO_FREETYPE
extern "C" {
-#include <ft2build.h>
-#include FT_FREETYPE_H
+#include <freetype/freetype.h>
}
// ascent, descent, width(ch), width(string), maxwidth?
// leftbearing, rightbearing, minleftbearing,minrightbearing
// leading
class QFontFactoryFT : public QFontFactory {
public:
QFontFactoryFT();
virtual ~QFontFactoryFT();
QRenderedFont * get(const QFontDef &,QDiskFont *);
virtual void load(QDiskFont *) const;
virtual QString name();
diff --git a/freetype/freetype.pro b/freetype/freetype.pro
index 5800b48..ca7edd3 100644
--- a/freetype/freetype.pro
+++ b/freetype/freetype.pro
@@ -1,11 +1,11 @@
TEMPLATE = lib
CONFIG += qt warn_on release
HEADERS = fontfactoryttf_qws.h freetypefactoryimpl.h
SOURCES = fontfactoryttf_qws.cpp freetypefactoryimpl.cpp
qt2:HEADERS += qfontdata_p.h
TARGET = freetypefactory
DESTDIR = $(OPIEDIR)/plugins/fontfactories
-INCLUDEPATH += $(OPIEDIR)/include
+INCLUDEPATH += $(QTDIR)/src/3rdparty/freetype/include $(QTDIR)/src/3rdparty/freetype/include/freetype/config $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lfreetype
VERSION = 1.0.0
diff --git a/freetype/freetypefactoryimpl.cpp b/freetype/freetypefactoryimpl.cpp
index 71460b2..24fb13a 100644
--- a/freetype/freetypefactoryimpl.cpp
+++ b/freetype/freetypefactoryimpl.cpp
@@ -35,23 +35,23 @@ QFontFactory *FreeTypeFactoryImpl::fontFactory()
{
if ( !factory )
factory = new QFontFactoryFT();
return factory;
}
QRESULT FreeTypeFactoryImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_FontFactory )
*iface = this;
if ( *iface )
(*iface)->addRef();
- return QS_OK;
+ return (*iface) ? QS_OK : QS_FALSE;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( FreeTypeFactoryImpl )
}
diff --git a/freetype/opie-freetype.control b/freetype/opie-freetype.control
index f1ce408..2863adb 100644
--- a/freetype/opie-freetype.control
+++ b/freetype/opie-freetype.control
@@ -1,8 +1,8 @@
Files: plugins/fontfactories/libfreetypefactory*
Priority: optional
Section: opie/plugins
Maintainer: Opie <opie@llornkcor.com>
Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
-Depends: opie-base ($QPE_VERSION)
+Depends: opie-base ($QPE_VERSION), libfreetype6
Description: Freetype fontfactory plugin