[Kde-cygwin-cvs] CVS: qt-3/src/kernel qfont_win.cpp,1.1.2.16.2.12,1.1.2.16.2.13 qfontdatabase_win.cp
Status: Inactive
Brought to you by:
habacker
From: Christian E. <che...@us...> - 2005-10-25 19:42:23
|
Update of /cvsroot/kde-cygwin/qt-3/src/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8226/src/kernel Modified Files: Tag: QT_WIN32_3_3_BRANCH qfont_win.cpp qfontdatabase_win.cpp qfontengine_win.cpp Log Message: shared_dc like qt4 Index: qfont_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfont_win.cpp,v retrieving revision 1.1.2.16.2.12 retrieving revision 1.1.2.16.2.13 diff -u -r1.1.2.16.2.12 -r1.1.2.16.2.13 --- qfont_win.cpp 24 Oct 2005 18:09:16 -0000 1.1.2.16.2.12 +++ qfont_win.cpp 25 Oct 2005 19:42:13 -0000 1.1.2.16.2.13 @@ -76,6 +76,8 @@ #define QT_CHECK_STATE +extern HDC shared_dc; // common dc for all fonts + // ### maybe move to qapplication_win QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/) { @@ -98,8 +100,8 @@ qf.setWeight(weight); } int lfh = QABS(lf.lfHeight); - Q_ASSERT(qt_display_dc()); - qf.setPointSize(lfh * 72.0 / GetDeviceCaps(qt_display_dc(),LOGPIXELSY)); + Q_ASSERT(shared_dc); + qf.setPointSize(lfh * 72.0 / GetDeviceCaps(shared_dc,LOGPIXELSY)); qf.setUnderline(false); qf.setOverline(false); qf.setStrikeOut(false); @@ -183,21 +185,23 @@ */ void QFont::initialize() { - // create global font cache - if ( ! QFontCache::instance ) - ( void ) new QFontCache; - + if (QFontCache::instance) + return; + shared_dc = CreateCompatibleDC(qt_display_dc()); + if (!shared_dc) + qWarning("QFont::initialize: CreateCompatibleDC failed"); + new QFontCache(); } /*! \internal Internal function that cleans up the font system. */ -//333 void QFont::cleanup() { - // delete the global font cache delete QFontCache::instance; + DeleteDC(shared_dc); + shared_dc = 0; } /*! \internal Index: qfontdatabase_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfontdatabase_win.cpp,v retrieving revision 1.1.2.6.2.22 retrieving revision 1.1.2.6.2.23 diff -u -r1.1.2.6.2.22 -r1.1.2.6.2.23 --- qfontdatabase_win.cpp 24 Oct 2005 18:09:16 -0000 1.1.2.6.2.22 +++ qfontdatabase_win.cpp 25 Oct 2005 19:42:14 -0000 1.1.2.6.2.23 @@ -50,7 +50,8 @@ #include "qt_windows.h" -static HDC shared_dc; +extern HDC shared_dc; // common dc for all fonts +static HFONT stock_sysfont = 0; static QFontDatabasePrivate *privateDb() { @@ -603,13 +604,16 @@ static void initializeDb() { - shared_dc = GetDC( NULL ); - QFontDatabasePrivate *db = privateDb(); if (!db || db->count) return; populate_database(QString()); + // don't know why I have to do this... + for (int f = 0; f < db->count; f++) { + QtFontFamily *family = db->families[f]; + populate_database(family->name); + } #ifdef QFONTDATABASE_DEBUG // print the database for (int f = 0; f < db->count; f++) { @@ -643,9 +647,6 @@ // -------------------------------------------------------------------------------------- // font loader // -------------------------------------------------------------------------------------- - -static HFONT stock_sysfont = 0; - static inline HFONT systemFont() { if ( stock_sysfont == 0 ) @@ -670,7 +671,7 @@ LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); - HDC hdc = GetDC( NULL ); + HDC hdc = shared_dc; bool stockFont = false; Index: qfontengine_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfontengine_win.cpp,v retrieving revision 1.1.2.34 retrieving revision 1.1.2.35 diff -u -r1.1.2.34 -r1.1.2.35 --- qfontengine_win.cpp 24 Oct 2005 16:07:40 -0000 1.1.2.34 +++ qfontengine_win.cpp 25 Oct 2005 19:42:14 -0000 1.1.2.35 @@ -1,7 +1,4 @@ /**************************************************************************** -** $Id$ -** -** ??? ** ** Created : 20040828 ** @@ -59,7 +56,16 @@ //extern int qt_xlfd_encoding_id( const char *encoding ); -extern HDC shared_dc; +HDC shared_dc = 0; // common dc for all fonts +static HFONT stock_sysfont = 0; + +static inline HFONT systemFont() +{ + if (stock_sysfont == 0) + stock_sysfont = (HFONT)GetStockObject(SYSTEM_FONT); + return stock_sysfont; +} + extern void qt_draw_transformed_rect( QPainter *p, int x, int y, int w, int h, bool fill ); @@ -89,7 +95,12 @@ } QFontEngine::~QFontEngine() -{} +{ + // make sure we aren't by accident still selected + SelectObject(shared_dc, systemFont()); + if (cmap) + delete [] cmap; +} int QFontEngine::lineThickness() const { @@ -121,6 +132,7 @@ : _size( size ) { cache_cost = sizeof( QFontEngineBox ); + cmap = 0; } QFontEngineBox::~QFontEngineBox() @@ -286,6 +298,7 @@ { _name = nameIn; logfont = lfIn; + cmap = 0; if ( hdcIn ) { hdc = hdcIn; |