[Kde-cygwin-cvs] CVS: qt-3/src/kernel qfontengine_win.cpp,1.1.2.37,1.1.2.38
Status: Inactive
Brought to you by:
habacker
From: Christian E. <che...@us...> - 2005-10-30 16:25:38
|
Update of /cvsroot/kde-cygwin/qt-3/src/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25133/src/kernel Modified Files: Tag: QT_WIN32_3_3_BRANCH qfontengine_win.cpp Log Message: fixed using wrong device context on textmetric calculation Index: qfontengine_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfontengine_win.cpp,v retrieving revision 1.1.2.37 retrieving revision 1.1.2.38 diff -u -r1.1.2.37 -r1.1.2.38 --- qfontengine_win.cpp 27 Oct 2005 18:44:24 -0000 1.1.2.37 +++ qfontengine_win.cpp 30 Oct 2005 16:25:30 -0000 1.1.2.38 @@ -105,7 +105,7 @@ QFontEngine::~QFontEngine() { // make sure we aren't by accident still selected - SelectObject(shared_dc, systemFont()); + SelectObject(hdc, systemFont()); if (cmap) delete [] cmap; } @@ -393,24 +393,24 @@ // Win font engine // ------------------------------------------------------------------ -QFontEngineWin::QFontEngineWin( const char *nameIn, HDC hdcIn, HFONT hfIn, bool bIn, LOGFONT lfIn ) +QFontEngineWin::QFontEngineWin( const char *nameIn, HDC hdcIn, HFONT hfIn, bool bStockFont, LOGFONT lfIn ) { _name = nameIn; hfont = hfIn; - hdc = CreateCompatibleDC(hdcIn ? hdcIn : shared_dc); + hdc = CreateCompatibleDC( hdcIn ? hdcIn : shared_dc ); logfont = lfIn; SelectObject( hdc, hfont ); - stockFont = false; + stockFont = bStockFont; lbearing = SHRT_MIN; rbearing = SHRT_MIN; BOOL res; QT_WA({ - res = GetTextMetricsW(shared_dc, &tm.w); + res = GetTextMetricsW(hdc, &tm.w); } , { - res = GetTextMetricsA(shared_dc, &tm.a); + res = GetTextMetricsA(hdc, &tm.a); }); if (!res) qWarning("QFontEngineWin: GetTextMetrics failed"); @@ -643,66 +643,17 @@ glyph_metrics_t QFontEngineWin::boundingBox( const glyph_t *glyphs, const advance_t *advances, const qoffset_t *offsets, int numGlyphs ) { - glyph_metrics_t overall; - - unsigned int ymax = 0; - unsigned int xmax = 0; - - GLYPHMETRICS gmw = {0}; - MAT2 mat; - ZeroMemory( &mat, sizeof mat ); - mat.eM11.value = mat.eM22.value = 1; - GetGlyphOutline ( hdc, 0, GGO_METRICS | GGO_GLYPH_INDEX, &gmw, 0, 0, &mat ); - for ( int i = 0; i < numGlyphs; i++ ) { - if ( GDI_ERROR == GetGlyphOutline( hdc, glyphs[ i ], GGO_METRICS | GGO_GLYPH_INDEX, &gmw, 0, 0, &mat ) ) { -#ifdef QFONTENGINE_WIN_LASTERROR - qlasterror( "QFontEngineWin::boundingBox(...) GetGlyphOutline:", GetLastError() ); -#endif - - } - //int x = overall.xoff + offsets[ i ].x - ( gmw.gmBlackBoxX - gmw.gmptGlyphOrigin.x ); - //int y = overall.yoff + offsets[ i ].y - ( gmw.gmBlackBoxY - gmw.gmptGlyphOrigin.y ); - int x = overall.xoff + offsets[ i ].x + gmw.gmptGlyphOrigin.x; - int y = overall.yoff + offsets[ i ].y + gmw.gmptGlyphOrigin.y; -#ifdef QFONTENGINE_WIN_DEBUG - - qDebug ( "QFontEngineWin::boundingBox: glyph: %d x = %d y = %d\n", glyphs[ i ], x, y ); - qDebug ( "QFontEngineWin::boundingBox: offsets[%d].x = %d, offets[%d].y = %d\n", i, offsets[ i ].x, i, offsets[ i ].y ); - qDebug ( "QFontEngineWin::boundingBox: overall.xoff = %d, overall.yoff = %d", overall.xoff, overall.yoff ); - qDebug ( "QFontEngineWin::boundingBox: gmw.gmBlackBoxX = %d, gmyw.gmptGlyphOrigin.x = %d", gmw.gmBlackBoxX, gmw.gmptGlyphOrigin.x ); -#endif + if (numGlyphs == 0) + return glyph_metrics_t(); - overall.x = QMIN( overall.x, x ); - overall.y = QMIN( overall.y, y ); -#ifdef QFONTENGINE_WIN_DEBUG - - qDebug ( "QFontEngineWin::boundingBox: overall.x = %d, overall.y = %d\n", overall.x, overall.y ); -#endif - - xmax = QMAX( xmax, x + gmw.gmBlackBoxX ); - ymax = QMAX( ymax, y + gmw.gmBlackBoxY ); - overall.xoff += advances[ i ]; - } - /* - for (int i = 0; i < numGlyphs; i++) { - getGlyphInfo( &xgi, _font, glyphs[i] ); - int x = overall.xoff + offsets[i].x - xgi.x; - int y = overall.yoff + offsets[i].y - xgi.y; - overall.x = QMIN( overall.x, x ); - overall.y = QMIN( overall.y, y ); - xmax = QMAX( xmax, x + xgi.width ); - ymax = QMAX( ymax, y + xgi.height ); - overall.xoff += advances[i]; - } - */ -#ifdef QFONTENGINE_WIN_DEBUG - qDebug ( "QFontEngineWin::boundingBox: overall.xoff = %d, overall.x = %d", overall.xoff, overall.x ); -#endif - - overall.height = ymax - overall.y; - overall.width = xmax - overall.x; - return overall; + int w = 0; + const advance_t *end = advances + numGlyphs; + while(end > advances) { + --end; + w += *end; + } + return glyph_metrics_t(0, -tm.w.tmAscent, w, tm.w.tmHeight, w, 0); } glyph_metrics_t QFontEngineWin::boundingBox( glyph_t glyph ) |