Diffstat (limited to 'freetype/fontfactoryttf_qws.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | freetype/fontfactoryttf_qws.cpp | 19 |
1 files changed, 13 insertions, 6 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 @@ -24,29 +24,28 @@ #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) { @@ -60,24 +59,26 @@ public: 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; @@ -99,25 +100,25 @@ public: 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; @@ -146,24 +147,30 @@ public: } 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; |