Diffstat (limited to 'freetype/fontfactoryttf_qws.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | freetype/fontfactoryttf_qws.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/freetype/fontfactoryttf_qws.cpp b/freetype/fontfactoryttf_qws.cpp index 1ed0d2c..6d41c33 100644 --- a/freetype/fontfactoryttf_qws.cpp +++ b/freetype/fontfactoryttf_qws.cpp @@ -1,133 +1,137 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "fontfactoryttf_qws.h" #include <opie2/odebug.h> using namespace Opie::Core; #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 <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; } } bool inFont(QChar ch) const { int index = ch.unicode(); return unicode(index); } 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) ofatal << "Load glyph error " << err << "" << oendl; int width=0,height=0,pitch=0,size=0; FT_Glyph glyph; err=FT_Get_Glyph( myface->glyph, &glyph ); if(err) ofatal << "Get glyph error " << err << "" << oendl; 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 if(err) owarn << "Get bitmap error " << err << "" << oendl; } |