Thread: [Kde-cygwin-cvs] CVS: qt-3/src/kernel qfontengine_win.cpp,1.1.2.36,1.1.2.37
Status: Inactive
Brought to you by:
habacker
From: Christian E. <che...@us...> - 2005-10-27 18:44:32
|
Update of /cvsroot/kde-cygwin/qt-3/src/kernel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5808/src/kernel Modified Files: Tag: QT_WIN32_3_3_BRANCH qfontengine_win.cpp Log Message: rearranged functions to fit with qt4 Index: qfontengine_win.cpp =================================================================== RCS file: /cvsroot/kde-cygwin/qt-3/src/kernel/Attic/qfontengine_win.cpp,v retrieving revision 1.1.2.36 retrieving revision 1.1.2.37 diff -u -r1.1.2.36 -r1.1.2.37 --- qfontengine_win.cpp 26 Oct 2005 20:36:56 -0000 1.1.2.36 +++ qfontengine_win.cpp 27 Oct 2005 18:44:24 -0000 1.1.2.37 @@ -166,6 +166,69 @@ } } +inline unsigned int getChar(const QChar *str, int &i, const int len) +{ + unsigned int uc = str[i].unicode(); + if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) { + uint low = str[i+1].unicode(); + if (low >= 0xdc00 && low < 0xe000) { + uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; + ++i; + } + } + return uc; +} + +void QFontEngine::getGlyphIndexes( const QChar *str, int numChars, glyph_t *glyphs, bool mirrored ) const +{ + if (mirrored) { + if (symbol) { + for (int i = 0; i < numChars; ++i) { + unsigned int uc = getChar(str, i, numChars); + *glyphs = getGlyphIndex(cmap, uc); + if(!*glyphs && uc < 0x100) + *glyphs = getGlyphIndex(cmap, uc + 0xf000); + glyphs++; + } + } else if (ttf) { + for (int i = 0; i < numChars; ++i) { + unsigned int uc = getChar(str, i, numChars); + *glyphs = getGlyphIndex(cmap, ::mirroredChar(uc).unicode()); + glyphs++; + } + } else { + for (int i = 0; i < numChars; ++i) { + *glyphs = ::mirroredChar(str->unicode()).unicode(); + glyphs++; + str++; + } + } + } else { + if (symbol) { + for (int i = 0; i < numChars; ++i) { + unsigned int uc = getChar(str, i, numChars); + *glyphs = getGlyphIndex(cmap, uc); + if(!*glyphs && uc < 0x100) + *glyphs = getGlyphIndex(cmap, uc + 0xf000); + glyphs++; + } + } else if (ttf) { + for (int i = 0; i < numChars; ++i) { + unsigned int uc = getChar(str, i, numChars); + *glyphs = getGlyphIndex(cmap, uc); + glyphs++; + } + } else { + for (int i = 0; i < numChars; ++i) { + *glyphs = str->unicode(); + glyphs++; + str++; + } + } + } + return; +} + // ------------------------------------------------------------------ // The box font engine // ------------------------------------------------------------------ @@ -326,10 +389,6 @@ return Box; } - - - - // ------------------------------------------------------------------ // Win font engine // ------------------------------------------------------------------ @@ -371,68 +430,6 @@ memset(widthCache, 0, sizeof(widthCache)); } -inline unsigned int getChar(const QChar *str, int &i, const int len) -{ - unsigned int uc = str[i].unicode(); - if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) { - uint low = str[i+1].unicode(); - if (low >= 0xdc00 && low < 0xe000) { - uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; - ++i; - } - } - return uc; -} - -void QFontEngine::getGlyphIndexes( const QChar *str, int numChars, glyph_t *glyphs, bool mirrored ) const -{ - if (mirrored) { - if (symbol) { - for (int i = 0; i < numChars; ++i) { - unsigned int uc = getChar(str, i, numChars); - *glyphs = getGlyphIndex(cmap, uc); - if(!*glyphs && uc < 0x100) - *glyphs = getGlyphIndex(cmap, uc + 0xf000); - glyphs++; - } - } else if (ttf) { - for (int i = 0; i < numChars; ++i) { - unsigned int uc = getChar(str, i, numChars); - *glyphs = getGlyphIndex(cmap, ::mirroredChar(uc).unicode()); - glyphs++; - } - } else { - for (int i = 0; i < numChars; ++i) { - *glyphs = ::mirroredChar(str->unicode()).unicode(); - glyphs++; - str++; - } - } - } else { - if (symbol) { - for (int i = 0; i < numChars; ++i) { - unsigned int uc = getChar(str, i, numChars); - *glyphs = getGlyphIndex(cmap, uc); - if(!*glyphs && uc < 0x100) - *glyphs = getGlyphIndex(cmap, uc + 0xf000); - glyphs++; - } - } else if (ttf) { - for (int i = 0; i < numChars; ++i) { - unsigned int uc = getChar(str, i, numChars); - *glyphs = getGlyphIndex(cmap, uc); - glyphs++; - } - } else { - for (int i = 0; i < numChars; ++i) { - *glyphs = str->unicode(); - glyphs++; - str++; - } - } - } - return; -} QFontEngine::Error QFontEngineWin::stringToCMap( const QChar *str, int len, glyph_t *glyphs, advance_t *advances, int *nglyphs, bool mirrored ) const { @@ -440,21 +437,6 @@ *nglyphs = len; return OutOfMemory; } - /* - TCHAR* uc; - TCHAR g64 [ 64 ]; - bool uc_delete = false; - if ( len < 64 ) - uc = g64; - else { - uc = new TCHAR [ len ]; - uc_delete = true; - } - - for ( int i = 0;i < len;i++ ) { - QT_WA_INLINE( uc[ i ] = str[ i ].unicode(), uc[ i ] = str[ i ].latin1()); - } - */ // if called before draw then hdc is wong !!!! (painter setfont??? @@ -499,11 +481,6 @@ } } - /* - if ( uc_delete ) - delete [] uc; - */ - return NoError; } @@ -664,9 +641,6 @@ SetBkMode( hdc, oldBkMode ); } - - - glyph_metrics_t QFontEngineWin::boundingBox( const glyph_t *glyphs, const advance_t *advances, const qoffset_t *offsets, int numGlyphs ) { glyph_metrics_t overall; @@ -846,7 +820,6 @@ } - const char *QFontEngineWin::name() const { return _name; @@ -854,27 +827,38 @@ bool QFontEngineWin::canRender( const QChar *string, int len ) { - glyph_t glyphs[ 256 ]; - int nglyphs = 255; - glyph_t *g = glyphs; - if ( stringToCMap( string, len, g, 0, &nglyphs, FALSE ) == OutOfMemory ) { - g = ( glyph_t * ) malloc( nglyphs * sizeof( glyph_t ) ); - stringToCMap( string, len, g, 0, &nglyphs, FALSE ); - } - - bool allExist = TRUE; - for ( int i = 0; i < nglyphs; i++ ) { - /*if ( !g[i] || !charStruct( tm.a , g[i] ) ) //todo - { - allExist = FALSE; - break; - }*/ + if (symbol) { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(string, i, len); + if (getGlyphIndex(cmap, uc) == 0) { + if (uc < 0x100) { + if (getGlyphIndex(cmap, uc + 0xf000) == 0) + return false; + } else { + return false; + } + } + } + } else if (ttf) { + for (int i = 0; i < len; ++i) { + unsigned int uc = getChar(string, i, len); + if (getGlyphIndex(cmap, uc) == 0) + return false; + } + } else { + QT_WA({ + while(len--) { + if (tm.w.tmFirstChar > string->unicode() || tm.w.tmLastChar < string->unicode()) + return false; + } + }, { + while(len--) { + if (tm.a.tmFirstChar > string->unicode() || tm.a.tmLastChar < string->unicode()) + return false; + } + }); } - - if ( g != glyphs ) - free( g ); - - return allExist; + return true; } QFontEngine::Type QFontEngineWin::type() const @@ -882,7 +866,9 @@ return Win; } - +// ---------------------------------------------------------------------------- +// True type support methods +// ---------------------------------------------------------------------------- #define MAKE_TAG(ch1, ch2, ch3, ch4) (\ (((DWORD)(ch4)) << 24) | \ |