Changeset 20 for trunk/src


Ignore:
Timestamp:
Nov 17, 2005, 7:00:27 PM (20 years ago)
Author:
dmik
Message:

Fixed a bunch of compiler warnings

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qclipboard_pm.cpp

    r19 r20  
    399399    if ( !ok )
    400400        qSystemWarning( "QClipboard: Failed to write data" );
     401#else
     402    Q_UNUSED( ok );
    401403#endif
    402404}
     
    573575    if ( !ok )
    574576        qSystemWarning( "QClipboard: Failed to empty clipboard" );
     577#else
     578    Q_UNUSED( ok );
    575579#endif
    576580
  • trunk/src/kernel/qfontengine_pm.cpp

    r19 r20  
    957957
    958958/// @todo (dmik) need this all?
    959 //#define MAKE_TAG(ch1, ch2, ch3, ch4) (\
    960 //    (((DWORD)(ch4)) << 24) | \
    961 //    (((DWORD)(ch3)) << 16) | \
    962 //    (((DWORD)(ch2)) << 8) | \
    963 //    ((DWORD)(ch1)) \
    964 //    )
    965 //
    966 //static inline Q_UINT32 getUInt(unsigned char *p)
    967 //{
    968 //    Q_UINT32 val;
    969 //    val = *p++ << 24;
    970 //    val |= *p++ << 16;
    971 //    val |= *p++ << 8;
    972 //    val |= *p;
    973 //
    974 //    return val;
    975 //}
    976 //
    977 //static inline Q_UINT16 getUShort(unsigned char *p)
    978 //{
    979 //    Q_UINT16 val;
    980 //    val = *p++ << 8;
    981 //    val |= *p;
    982 //
    983 //    return val;
    984 //}
    985 //
    986 //static inline void tag_to_string( char *string, Q_UINT32 tag )
    987 //{
    988 //    string[0] = (tag >> 24)&0xff;
    989 //    string[1] = (tag >> 16)&0xff;
    990 //    string[2] = (tag >> 8)&0xff;
    991 //    string[3] = tag&0xff;
    992 //    string[4] = 0;
    993 //}
    994 //
    995 //static Q_UINT16 getGlyphIndex( unsigned char *table, unsigned short unicode )
    996 //{
    997 //    unsigned short format = getUShort( table );
    998 //    if ( format == 0 ) {
    999 //      if ( unicode < 256 )
    1000 //          return (int) *(table+6+unicode);
    1001 //    } else if ( format == 2 ) {
    1002 //      qWarning("format 2 encoding table for Unicode, not implemented!");
    1003 //    } else if ( format == 4 ) {
    1004 //      Q_UINT16 segCountX2 = getUShort( table + 6 );
    1005 //      unsigned char *ends = table + 14;
    1006 //      Q_UINT16 endIndex = 0;
    1007 //      int i = 0;
    1008 //      for ( ; i < segCountX2/2 && (endIndex = getUShort( ends + 2*i )) < unicode; i++ );
    1009 //
    1010 //      unsigned char *idx = ends + segCountX2 + 2 + 2*i;
    1011 //      Q_UINT16 startIndex = getUShort( idx );
    1012 //
    1013 //      if ( startIndex > unicode )
    1014 //          return 0;
    1015 //
    1016 //      idx += segCountX2;
    1017 //      Q_INT16 idDelta = (Q_INT16)getUShort( idx );
    1018 //      idx += segCountX2;
    1019 //      Q_UINT16 idRangeoffset_t = (Q_UINT16)getUShort( idx );
    1020 //
    1021 //      Q_UINT16 glyphIndex;
    1022 //      if ( idRangeoffset_t ) {
    1023 //          Q_UINT16 id = getUShort( idRangeoffset_t + 2*(unicode - startIndex) + idx);
    1024 //          if ( id )
    1025 //              glyphIndex = ( idDelta + id ) % 0x10000;
    1026 //          else
    1027 //              glyphIndex = 0;
    1028 //      } else {
    1029 //          glyphIndex = (idDelta + unicode) % 0x10000;
    1030 //      }
    1031 //      return glyphIndex;
    1032 //    }
    1033 //
    1034 //    return 0;
    1035 //}
    1036 //
    1037 //
    1038 //static unsigned char *getCMap( HDC hdc, bool &symbol )
    1039 //{
    1040 //    const DWORD CMAP = MAKE_TAG( 'c', 'm', 'a', 'p' );
    1041 //
    1042 //    unsigned char header[4];
    1043 //
    1044 //    // get the CMAP header and the number of encoding tables
    1045 //    DWORD bytes =
    1046 //#ifndef Q_OS_TEMP
    1047 //      GetFontData( hdc, CMAP, 0, &header, 4 );
    1048 //#else
    1049 //      0;
    1050 //#endif
    1051 //    if ( bytes == GDI_ERROR )
    1052 //      return 0;
    1053 //    unsigned short version = getUShort( header );
    1054 //    if ( version != 0 )
    1055 //      return 0;
    1056 //
    1057 //    unsigned short numTables = getUShort( header+2);
    1058 //    unsigned char *maps = new unsigned char[8*numTables];
    1059 //
    1060 //    // get the encoding table and look for Unicode
    1061 //#ifndef Q_OS_TEMP
    1062 //    bytes = GetFontData( hdc, CMAP, 4, maps, 8*numTables );
    1063 //#endif
    1064 //    if ( bytes == GDI_ERROR )
    1065 //      return 0;
    1066 //
    1067 //    symbol = TRUE;
    1068 //    unsigned int unicode_table = 0;
    1069 //    for ( int n = 0; n < numTables; n++ ) {
    1070 //      Q_UINT32 version = getUInt( maps + 8*n );
    1071 //      // accept both symbol and Unicode encodings. prefer unicode.
    1072 //      if ( version == 0x00030001 || version == 0x00030000 ) {
    1073 //          unicode_table = getUInt( maps + 8*n + 4 );
    1074 //          if ( version == 0x00030001 ) {
    1075 //              symbol = FALSE;
    1076 //              break;
    1077 //          }
    1078 //      }
    1079 //    }
    1080 //
    1081 //    if ( !unicode_table ) {
    1082 //      // qDebug("no unicode table found" );
    1083 //      return 0;
    1084 //    }
    1085 //
    1086 //    delete [] maps;
    1087 //
    1088 //    // get the header of the unicode table
    1089 //#ifndef Q_OS_TEMP
    1090 //    bytes = GetFontData( hdc, CMAP, unicode_table, &header, 4 );
    1091 //#endif
    1092 //    if ( bytes == GDI_ERROR )
    1093 //      return 0;
    1094 //
    1095 //    unsigned short length = getUShort( header+2 );
    1096 //    unsigned char *unicode_data = new unsigned char[length];
    1097 //
    1098 //    // get the cmap table itself
    1099 //#ifndef Q_OS_TEMP
    1100 //    bytes = GetFontData( hdc, CMAP, unicode_table, unicode_data, length );
    1101 //#endif
    1102 //    if ( bytes == GDI_ERROR ) {
    1103 //      delete [] unicode_data;
    1104 //      return 0;
    1105 //    }
    1106 //    return unicode_data;
    1107 //}
    1108 
    1109 
    1110 
     959#if 0
     960#define MAKE_TAG(ch1, ch2, ch3, ch4) (\
     961    (((DWORD)(ch4)) << 24) | \
     962    (((DWORD)(ch3)) << 16) | \
     963    (((DWORD)(ch2)) << 8) | \
     964    ((DWORD)(ch1)) \
     965    )
     966
     967static inline Q_UINT32 getUInt(unsigned char *p)
     968{
     969    Q_UINT32 val;
     970    val = *p++ << 24;
     971    val |= *p++ << 16;
     972    val |= *p++ << 8;
     973    val |= *p;
     974
     975    return val;
     976}
     977
     978static inline Q_UINT16 getUShort(unsigned char *p)
     979{
     980    Q_UINT16 val;
     981    val = *p++ << 8;
     982    val |= *p;
     983
     984    return val;
     985}
     986
     987static inline void tag_to_string( char *string, Q_UINT32 tag )
     988{
     989    string[0] = (tag >> 24)&0xff;
     990    string[1] = (tag >> 16)&0xff;
     991    string[2] = (tag >> 8)&0xff;
     992    string[3] = tag&0xff;
     993    string[4] = 0;
     994}
     995
     996static Q_UINT16 getGlyphIndex( unsigned char *table, unsigned short unicode )
     997{
     998    unsigned short format = getUShort( table );
     999    if ( format == 0 ) {
     1000        if ( unicode < 256 )
     1001            return (int) *(table+6+unicode);
     1002    } else if ( format == 2 ) {
     1003        qWarning("format 2 encoding table for Unicode, not implemented!");
     1004    } else if ( format == 4 ) {
     1005        Q_UINT16 segCountX2 = getUShort( table + 6 );
     1006        unsigned char *ends = table + 14;
     1007        Q_UINT16 endIndex = 0;
     1008        int i = 0;
     1009        for ( ; i < segCountX2/2 && (endIndex = getUShort( ends + 2*i )) < unicode; i++ );
     1010
     1011        unsigned char *idx = ends + segCountX2 + 2 + 2*i;
     1012        Q_UINT16 startIndex = getUShort( idx );
     1013
     1014        if ( startIndex > unicode )
     1015            return 0;
     1016
     1017        idx += segCountX2;
     1018        Q_INT16 idDelta = (Q_INT16)getUShort( idx );
     1019        idx += segCountX2;
     1020        Q_UINT16 idRangeoffset_t = (Q_UINT16)getUShort( idx );
     1021
     1022        Q_UINT16 glyphIndex;
     1023        if ( idRangeoffset_t ) {
     1024            Q_UINT16 id = getUShort( idRangeoffset_t + 2*(unicode - startIndex) + idx);
     1025            if ( id )
     1026                glyphIndex = ( idDelta + id ) % 0x10000;
     1027            else
     1028                glyphIndex = 0;
     1029        } else {
     1030            glyphIndex = (idDelta + unicode) % 0x10000;
     1031        }
     1032        return glyphIndex;
     1033    }
     1034
     1035    return 0;
     1036}
     1037
     1038
     1039static unsigned char *getCMap( HDC hdc, bool &symbol )
     1040{
     1041    const DWORD CMAP = MAKE_TAG( 'c', 'm', 'a', 'p' );
     1042
     1043    unsigned char header[4];
     1044
     1045    // get the CMAP header and the number of encoding tables
     1046    DWORD bytes =
     1047#ifndef Q_OS_TEMP
     1048        GetFontData( hdc, CMAP, 0, &header, 4 );
     1049#else
     1050        0;
     1051#endif
     1052    if ( bytes == GDI_ERROR )
     1053        return 0;
     1054    unsigned short version = getUShort( header );
     1055    if ( version != 0 )
     1056        return 0;
     1057
     1058    unsigned short numTables = getUShort( header+2);
     1059    unsigned char *maps = new unsigned char[8*numTables];
     1060
     1061    // get the encoding table and look for Unicode
     1062#ifndef Q_OS_TEMP
     1063    bytes = GetFontData( hdc, CMAP, 4, maps, 8*numTables );
     1064#endif
     1065    if ( bytes == GDI_ERROR )
     1066        return 0;
     1067
     1068    symbol = TRUE;
     1069    unsigned int unicode_table = 0;
     1070    for ( int n = 0; n < numTables; n++ ) {
     1071        Q_UINT32 version = getUInt( maps + 8*n );
     1072        // accept both symbol and Unicode encodings. prefer unicode.
     1073        if ( version == 0x00030001 || version == 0x00030000 ) {
     1074            unicode_table = getUInt( maps + 8*n + 4 );
     1075            if ( version == 0x00030001 ) {
     1076                symbol = FALSE;
     1077                break;
     1078            }
     1079        }
     1080    }
     1081
     1082    if ( !unicode_table ) {
     1083        // qDebug("no unicode table found" );
     1084        return 0;
     1085    }
     1086
     1087    delete [] maps;
     1088
     1089    // get the header of the unicode table
     1090#ifndef Q_OS_TEMP
     1091    bytes = GetFontData( hdc, CMAP, unicode_table, &header, 4 );
     1092#endif
     1093    if ( bytes == GDI_ERROR )
     1094        return 0;
     1095
     1096    unsigned short length = getUShort( header+2 );
     1097    unsigned char *unicode_data = new unsigned char[length];
     1098
     1099    // get the cmap table itself
     1100#ifndef Q_OS_TEMP
     1101    bytes = GetFontData( hdc, CMAP, unicode_table, unicode_data, length );
     1102#endif
     1103    if ( bytes == GDI_ERROR ) {
     1104        delete [] unicode_data;
     1105        return 0;
     1106    }
     1107    return unicode_data;
     1108}
     1109#endif // if 0
     1110
     1111
  • trunk/src/kernel/qmime_pm.cpp

    r19 r20  
    7474    \i CF_TEXT - converted to "text/plain;charset=system" or "text/plain"
    7575            and supported by QTextDrag.
    76     \i CF_BITMAP - converted to "image/*", where * is
     76    \i CF_BITMAP - converted to "image/fmt", where fmt is
    7777                a \link QImage::outputFormats() Qt image format\endlink,
    7878            and supported by QImageDrag.
  • trunk/src/kernel/qtextengine_pm.cpp

    r19 r20  
    4242
    4343
    44 //@@TODO (dmik): remove?
    45 //// these defines are from usp10.h
    46 //typedef void *SCRIPT_CACHE;
    47 //typedef struct tag_SCRIPT_CONTROL {
    48 //    DWORD   uDefaultLanguage    :16;
    49 //    DWORD   fContextDigits      :1;
    50 //    DWORD   fInvertPreBoundDir  :1;
    51 //    DWORD   fInvertPostBoundDir :1;
    52 //    DWORD   fLinkStringBefore   :1;
    53 //    DWORD   fLinkStringAfter    :1;
    54 //    DWORD   fNeutralOverride    :1;
    55 //    DWORD   fNumericOverride    :1;
    56 //    DWORD   fLegacyBidiClass    :1;
    57 //    DWORD   fReserved           :8;
    58 //} SCRIPT_CONTROL;
     44/// @todo (dmik) remove?
     45#if 0
     46// these defines are from usp10.h
     47typedef void *SCRIPT_CACHE;
     48typedef struct tag_SCRIPT_CONTROL {
     49    DWORD   uDefaultLanguage    :16;
     50    DWORD   fContextDigits      :1;
     51    DWORD   fInvertPreBoundDir  :1;
     52    DWORD   fInvertPostBoundDir :1;
     53    DWORD   fLinkStringBefore   :1;
     54    DWORD   fLinkStringAfter    :1;
     55    DWORD   fNeutralOverride    :1;
     56    DWORD   fNumericOverride    :1;
     57    DWORD   fLegacyBidiClass    :1;
     58    DWORD   fReserved           :8;
     59} SCRIPT_CONTROL;
     60
     61typedef struct tag_SCRIPT_STATE {
     62    WORD    uBidiLevel         :5;
     63    WORD    fOverrideDirection :1;
     64    WORD    fInhibitSymSwap    :1;
     65    WORD    fCharShape         :1;
     66    WORD    fDigitSubstitute   :1;
     67    WORD    fInhibitLigate     :1;
     68    WORD    fDisplayZWG        :1;
     69    WORD    fArabicNumContext  :1;
     70    WORD    fGcpClusters       :1;
     71    WORD    fReserved          :1;
     72    WORD    fEngineReserved    :2;
     73} SCRIPT_STATE;
     74
     75typedef struct tag_SCRIPT_ITEM {
     76    int              iCharPos;
     77    QScriptAnalysis  a;
     78} SCRIPT_ITEM;
     79
     80typedef GlyphAttributes SCRIPT_VISATTR;
     81typedef qoffset_t GOFFSET;
     82
     83#define USP_E_SCRIPT_NOT_IN_FONT   \
     84        MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200)    // Script doesn't exist in font
     85
     86typedef struct {
     87  DWORD   langid              :16;
     88  DWORD   fNumeric            :1;
     89  DWORD   fComplex            :1;
     90  DWORD   fNeedsWordBreaking  :1;
     91  DWORD   fNeedsCaretInfo     :1;
     92  DWORD   bCharSet            :8;
     93  DWORD   fControl            :1;
     94  DWORD   fPrivateUseArea     :1;
     95  DWORD   fNeedsCharacterJustify :1;
     96  DWORD   fInvalidGlyph       :1;
     97  DWORD   fInvalidLogAttr     :1;
     98  DWORD   fCDM                :1;
     99  DWORD   fAmbiguousCharSet   :1;
     100  DWORD   fClusterSizeVaries  :1;
     101  DWORD   fRejectInvalid      :1;
     102} SCRIPT_PROPERTIES;
     103
     104#if defined(Q_OS_TEMP) && UNDER_CE < 400
     105typedef struct _ABC {
     106  int     abcA;
     107  UINT    abcB;
     108  int     abcC;
     109} ABC;
     110#endif
     111
     112typedef HRESULT (WINAPI *fScriptFreeCache)( SCRIPT_CACHE *);
     113typedef HRESULT (WINAPI *fScriptItemize)( const WCHAR *, int, int, const SCRIPT_CONTROL *,
     114                                          const SCRIPT_STATE *, SCRIPT_ITEM *, int *);
     115typedef HRESULT (WINAPI *fScriptShape)( HDC hdc, SCRIPT_CACHE *, const WCHAR *, int, int,
     116                                        QScriptAnalysis *, WORD *, WORD *, SCRIPT_VISATTR *, int *);
     117typedef HRESULT (WINAPI *fScriptPlace)( HDC, SCRIPT_CACHE *, const WORD *, int, const SCRIPT_VISATTR *, QScriptAnalysis *, int *,
     118                                        GOFFSET *, ABC * );
     119typedef HRESULT (WINAPI *fScriptTextOut)( const HDC, SCRIPT_CACHE *, int, int, UINT, const RECT *, const QScriptAnalysis *,
     120                                         const WCHAR *, int, const WORD *, int, const int *, const int *, const GOFFSET *);
     121typedef HRESULT (WINAPI *fScriptBreak)( const WCHAR *, int, const QScriptAnalysis *, QCharAttributes * );
     122//typedef HRESULT (WINAPI *fScriptGetFontProperties)( HDC, SCRIPT_CACHE *, SCRIPT_FONTPROPERTIES * );
     123typedef HRESULT (WINAPI *fScriptGetProperties)( const SCRIPT_PROPERTIES ***, int *);
     124
     125fScriptFreeCache ScriptFreeCache = 0;
     126static fScriptItemize ScriptItemize = 0;
     127static fScriptShape ScriptShape = 0;
     128static fScriptPlace ScriptPlace = 0;
     129fScriptTextOut ScriptTextOut = 0;
     130static fScriptBreak ScriptBreak = 0;
     131//static fScriptGetFontProperties ScriptGetFontProperties = 0;
     132static fScriptGetProperties ScriptGetProperties = 0;
     133
     134static bool resolvedUsp10 = FALSE;
     135bool hasUsp10 = FALSE;
     136
     137const SCRIPT_PROPERTIES **script_properties = 0;
     138int num_scripts = 0;
     139int usp_latin_script = 0;
     140
     141
     142const QFont::Script japanese_tryScripts[] = {
     143    QFont::Latin,
     144    QFont::Han_Japanese,
     145    QFont::Hangul,
     146    QFont::Han_SimplifiedChinese,
     147    QFont::Han_TraditionalChinese
     148};
     149
     150const QFont::Script korean_tryScripts[] = {
     151    QFont::Latin,
     152    QFont::Hangul,
     153    QFont::Han_Japanese,
     154    QFont::Han_SimplifiedChinese,
     155    QFont::Han_TraditionalChinese
     156};
     157
     158const QFont::Script simplifiedChinese_tryScripts[] = {
     159    QFont::Latin,
     160    QFont::Han_SimplifiedChinese,
     161    QFont::Han_TraditionalChinese,
     162    QFont::Han_Japanese,
     163    QFont::Hangul
     164};
     165
     166const QFont::Script traditionalChinese_tryScripts[] = {
     167    QFont::Latin,
     168    QFont::Han_TraditionalChinese,
     169    QFont::Han_SimplifiedChinese,
     170    QFont::Han_Japanese,
     171    QFont::Hangul
     172};
     173
     174const QFont::Script *tryScripts = japanese_tryScripts;
     175
     176static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir);
     177
     178static void resolveUsp10()
     179{
     180#ifndef QT_NO_COMPONENT
     181    if ( !resolvedUsp10 ) {
     182        // need to resolve the security info functions
     183
     184#ifdef QT_THREAD_SUPPORT
     185        // protect initialization
     186        QMutexLocker locker( qt_global_mutexpool ?
     187                             qt_global_mutexpool->get( (void*)&resolveUsp10 ) : 0 );
     188        // check triedResolve again, since another thread may have already
     189        // done the initialization
     190        if ( resolvedUsp10 ) {
     191            // another thread did initialize the security function pointers,
     192            // so we shouldn't do it again.
     193            return;
     194        }
     195#endif
     196
     197        resolvedUsp10 = TRUE;
     198        QLibrary lib("usp10");
     199        lib.setAutoUnload( FALSE );
     200
     201        ScriptFreeCache = (fScriptFreeCache) lib.resolve( "ScriptFreeCache" );
     202        ScriptItemize = (fScriptItemize) lib.resolve( "ScriptItemize" );
     203        ScriptShape = (fScriptShape) lib.resolve( "ScriptShape" );
     204        ScriptPlace = (fScriptPlace) lib.resolve( "ScriptPlace" );
     205        ScriptTextOut = (fScriptTextOut) lib.resolve( "ScriptTextOut" );
     206        ScriptBreak = (fScriptBreak) lib.resolve( "ScriptBreak" );
     207        ScriptGetProperties = (fScriptGetProperties) lib.resolve( "ScriptGetProperties" );
     208
     209        if ( !ScriptFreeCache )
     210            return;
     211
     212        hasUsp10 = TRUE;
     213        ScriptGetProperties( &script_properties, &num_scripts );
     214
     215        // get the usp script for western
     216        for( int i = 0; i < num_scripts; i++ ) {
     217            if (script_properties[i]->langid == LANG_ENGLISH &&
     218                !script_properties[i]->fAmbiguousCharSet ) {
     219                usp_latin_script = i;
     220                break;
     221            }
     222        }
     223
     224        // initialize tryScripts according to locale
     225        LANGID lid = GetUserDefaultLangID();
     226        switch( lid&0xff ) {
     227        case LANG_CHINESE: // Chinese (Taiwan)
     228            if ( lid == 0x0804 ) // Taiwan
     229                tryScripts = traditionalChinese_tryScripts;
     230            else
     231                tryScripts = simplifiedChinese_tryScripts;
     232            break;
     233        case LANG_JAPANESE:
     234            // japanese is already the default
     235            break;
     236        case LANG_KOREAN:
     237                tryScripts = korean_tryScripts;
     238                break;
     239        default:
     240            break;
     241        }
     242
     243        appendItems = uspAppendItems;
     244    }
     245#endif
     246}
     247
     248static unsigned char script_for_win_language[ 0x80 ] = {
     249    //0x00 LANG_NEUTRAL Neutral
     250    QFont::Latin,
     251    //0x01 LANG_ARABIC Arabic
     252    QFont::Arabic,
     253    //0x02 LANG_BULGARIAN Bulgarian
     254    QFont::NScripts,
     255    //0x03 LANG_CATALAN Catalan
     256    QFont::NScripts,
     257    //0x04 LANG_CHINESE Chinese
     258    QFont::Han,
     259    //0x05 LANG_CZECH Czech
     260    QFont::NScripts,
     261    //0x06 LANG_DANISH Danish
     262    QFont::NScripts,
     263    //0x07 LANG_GERMAN German
     264    QFont::NScripts,
     265    //0x08 LANG_GREEK Greek
     266    QFont::Greek,
     267    //0x09 LANG_ENGLISH English
     268    QFont::Latin,
     269    //0x0a LANG_SPANISH Spanish
     270    QFont::NScripts,
     271    //0x0b LANG_FINNISH Finnish
     272    QFont::NScripts,
     273    //0x0c LANG_FRENCH French
     274    QFont::NScripts,
     275    //0x0d LANG_HEBREW Hebrew
     276    QFont::Hebrew,
     277    //0x0e LANG_HUNGARIAN Hungarian
     278    QFont::NScripts,
     279    //0x0f LANG_ICELANDIC Icelandic
     280    QFont::NScripts,
     281
     282    //0x10 LANG_ITALIAN Italian
     283    QFont::NScripts,
     284    //0x11 LANG_JAPANESE Japanese
     285    QFont::Hiragana,
     286    //0x12 LANG_KOREAN Korean
     287    QFont::Hangul,
     288    //0x13 LANG_DUTCH Dutch
     289    QFont::NScripts,
     290    //0x14 LANG_NORWEGIAN Norwegian
     291    QFont::NScripts,
     292    //0x15 LANG_POLISH Polish
     293    QFont::NScripts,
     294    //0x16 LANG_PORTUGUESE Portuguese
     295    QFont::NScripts,
     296    QFont::NScripts,
     297    //0x18 LANG_ROMANIAN Romanian
     298    QFont::NScripts,
     299    //0x19 LANG_RUSSIAN Russian
     300    QFont::Cyrillic,
     301    //0x1a LANG_CROATIAN Croatian
     302    //0x1a LANG_SERBIAN Serbian
     303    QFont::NScripts,
     304    //0x1b LANG_SLOVAK Slovak
     305    QFont::NScripts,
     306    //0x1c LANG_ALBANIAN Albanian
     307    QFont::NScripts,
     308    //0x1d LANG_SWEDISH Swedish
     309    QFont::NScripts,
     310    //0x1e LANG_THAI Thai
     311    QFont::Thai,
     312    //0x1f LANG_TURKISH Turkish
     313    QFont::NScripts,
     314
     315    //0x20 LANG_URDU Urdu
     316    QFont::NScripts,
     317    //0x21 LANG_INDONESIAN Indonesian
     318    QFont::NScripts,
     319    //0x22 LANG_UKRAINIAN Ukrainian
     320    QFont::NScripts,
     321    //0x23 LANG_BELARUSIAN Belarusian
     322    QFont::NScripts,
     323    //0x24 LANG_SLOVENIAN Slovenian
     324    QFont::NScripts,
     325    //0x25 LANG_ESTONIAN Estonian
     326    QFont::NScripts,
     327    //0x26 LANG_LATVIAN Latvian
     328    QFont::NScripts,
     329    //0x27 LANG_LITHUANIAN Lithuanian
     330    QFont::NScripts,
     331    QFont::NScripts,
     332    //0x29 LANG_FARSI Farsi
     333    QFont::NScripts,
     334    //0x2a LANG_VIETNAMESE Vietnamese
     335    QFont::Latin, // ##### maybe use QFont::CombiningMarks instead?
     336    //0x2b LANG_ARMENIAN Armenian
     337    QFont::Armenian,
     338    //0x2c LANG_AZERI Azeri
     339    QFont::NScripts,
     340    //0x2d LANG_BASQUE Basque
     341    QFont::NScripts,
     342    QFont::NScripts,
     343    //0x2f LANG_MACEDONIAN FYRO Macedonian
     344    QFont::NScripts,
     345
     346    QFont::NScripts,
     347    QFont::NScripts,
     348    QFont::NScripts,
     349    QFont::NScripts,
     350    QFont::NScripts,
     351    QFont::NScripts,
     352    //0x36 LANG_AFRIKAANS Afrikaans
     353    QFont::NScripts,
     354    //0x37 LANG_GEORGIAN Georgian
     355    QFont::NScripts,
     356    //0x38 LANG_FAEROESE Faeroese
     357    QFont::NScripts,
     358    //0x39 LANG_HINDI Hindi
     359    QFont::Devanagari,
     360    QFont::NScripts,
     361    QFont::NScripts,
     362    QFont::NScripts,
     363    QFont::NScripts,
     364    //0x3e LANG_MALAY Malay
     365    QFont::NScripts,
     366    //0x3f LANG_KAZAK Kazak
     367    QFont::NScripts,
     368
     369    //0x40 LANG_KYRGYZ Kyrgyz
     370    QFont::NScripts,
     371    //0x41 LANG_SWAHILI Swahili
     372    QFont::NScripts,
     373    QFont::NScripts,
     374    //0x43 LANG_UZBEK Uzbek
     375    QFont::NScripts,
     376    //0x44 LANG_TATAR Tatar
     377    QFont::NScripts,
     378    //0x45 LANG_BENGALI Not supported.
     379    QFont::Bengali,
     380    //0x46 LANG_PUNJABI Punjabi
     381    QFont::Gurmukhi,
     382    //0x47 LANG_GUJARATI Gujarati
     383    QFont::Gujarati,
     384    //0x48 LANG_ORIYA Not supported.
     385    QFont::Oriya,
     386    //0x49 LANG_TAMIL Tamil
     387    QFont::Tamil,
     388    //0x4a LANG_TELUGU Telugu
     389    QFont::Telugu,
     390    //0x4b LANG_KANNADA Kannada
     391    QFont::Kannada,
     392    //0x4c LANG_MALAYALAM Not supported.
     393    QFont::Malayalam,
     394    //0x4d LANG_ASSAMESE Not supported.
     395    QFont::NScripts,
     396    //0x4e LANG_MARATHI Marathi
     397    QFont::NScripts,
     398    //0x4f LANG_SANSKRIT Sanskrit
     399    QFont::Devanagari,
     400
     401    //0x50 LANG_MONGOLIAN Mongolian
     402    QFont::Mongolian,
     403    QFont::NScripts,
     404    QFont::NScripts,
     405    QFont::NScripts,
     406    QFont::NScripts,
     407    QFont::NScripts,
     408    //0x56 LANG_GALICIAN Galician
     409    QFont::NScripts,
     410    //0x57 LANG_KONKANI Konkani
     411    QFont::NScripts,
     412    //0x58 LANG_MANIPURI Not supported.
     413    QFont::NScripts,
     414    //0x59 LANG_SINDHI Not supported.
     415    QFont::NScripts,
     416    //0x5a LANG_SYRIAC Syriac
     417    QFont::Syriac,
     418    QFont::NScripts,
     419    QFont::NScripts,
     420    QFont::NScripts,
     421    QFont::NScripts,
     422    QFont::NScripts,
     423
     424    //0x60 LANG_KASHMIRI Not supported.
     425    QFont::NScripts,
     426    //0x61 LANG_NEPALI Not supported.
     427    QFont::NScripts,
     428    QFont::NScripts,
     429    QFont::NScripts,
     430    QFont::NScripts,
     431    //0x65 LANG_DIVEHI Divehi
     432    QFont::NScripts,
     433    QFont::NScripts,
     434    QFont::NScripts,
     435    QFont::NScripts,
     436    QFont::NScripts,
     437    QFont::NScripts,
     438    QFont::NScripts,
     439    QFont::NScripts,
     440    QFont::NScripts,
     441    QFont::NScripts,
     442    QFont::NScripts,
     443
     444    QFont::NScripts,
     445    QFont::NScripts,
     446    QFont::NScripts,
     447    QFont::NScripts,
     448    QFont::NScripts,
     449    QFont::NScripts,
     450    QFont::NScripts,
     451    QFont::NScripts,
     452    QFont::NScripts,
     453    QFont::NScripts,
     454    QFont::NScripts,
     455    QFont::NScripts,
     456    QFont::NScripts,
     457    QFont::NScripts,
     458    QFont::NScripts,
     459    //0x7f LANG_INVARIANT
     460    QFont::NScripts,
     461};
     462
     463static inline QFont::Script scriptForWinLanguage( DWORD langid )
     464{
     465    QFont::Script script = (QFont::Script)script_for_win_language[langid];
     466    if ( script == QFont::NScripts )
     467        qWarning( "Qt Uniscribe support: Encountered unhandled language id %x", (unsigned int)langid );
     468    return script;
     469}
     470
     471static inline bool isAsian( unsigned short ch )
     472{
     473    return (ch > 0x2dff && ch < 0xfb00) || ((ch & 0xff00) == 0x1100);
     474}
     475
     476
     477// we're not using Uniscribe's BiDi algorithm, since it is (a) not 100% Unicode compliant and
     478// (b) seems to work wrongly when trying to use it with a base level != 0.
    59479//
    60 //typedef struct tag_SCRIPT_STATE {
    61 //    WORD    uBidiLevel         :5;
    62 //    WORD    fOverrideDirection :1;
    63 //    WORD    fInhibitSymSwap    :1;
    64 //    WORD    fCharShape         :1;
    65 //    WORD    fDigitSubstitute   :1;
    66 //    WORD    fInhibitLigate     :1;
    67 //    WORD    fDisplayZWG        :1;
    68 //    WORD    fArabicNumContext  :1;
    69 //    WORD    fGcpClusters       :1;
    70 //    WORD    fReserved          :1;
    71 //    WORD    fEngineReserved    :2;
    72 //} SCRIPT_STATE;
    73 //
    74 //typedef struct tag_SCRIPT_ITEM {
    75 //    int              iCharPos;
    76 //    QScriptAnalysis  a;
    77 //} SCRIPT_ITEM;
    78 //
    79 //typedef GlyphAttributes SCRIPT_VISATTR;
    80 //typedef qoffset_t GOFFSET;
    81 //
    82 //#define USP_E_SCRIPT_NOT_IN_FONT   \
    83 //        MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200)    // Script doesn't exist in font
    84 //
    85 //typedef struct {
    86 //  DWORD   langid              :16;
    87 //  DWORD   fNumeric            :1;
    88 //  DWORD   fComplex            :1;
    89 //  DWORD   fNeedsWordBreaking  :1;
    90 //  DWORD   fNeedsCaretInfo     :1;
    91 //  DWORD   bCharSet            :8;
    92 //  DWORD   fControl            :1;
    93 //  DWORD   fPrivateUseArea     :1;
    94 //  DWORD   fNeedsCharacterJustify :1;
    95 //  DWORD   fInvalidGlyph       :1;
    96 //  DWORD   fInvalidLogAttr     :1;
    97 //  DWORD   fCDM                :1;
    98 //  DWORD   fAmbiguousCharSet   :1;
    99 //  DWORD   fClusterSizeVaries  :1;
    100 //  DWORD   fRejectInvalid      :1;
    101 //} SCRIPT_PROPERTIES;
    102 //
    103 //#if defined(Q_OS_TEMP) && UNDER_CE < 400
    104 //typedef struct _ABC {
    105 //  int     abcA;
    106 //  UINT    abcB;
    107 //  int     abcC;
    108 //} ABC;
    109 //#endif
    110 //
    111 //typedef HRESULT (WINAPI *fScriptFreeCache)( SCRIPT_CACHE *);
    112 //typedef HRESULT (WINAPI *fScriptItemize)( const WCHAR *, int, int, const SCRIPT_CONTROL *,
    113 //                                        const SCRIPT_STATE *, SCRIPT_ITEM *, int *);
    114 //typedef HRESULT (WINAPI *fScriptShape)( HDC hdc, SCRIPT_CACHE *, const WCHAR *, int, int,
    115 //                                      QScriptAnalysis *, WORD *, WORD *, SCRIPT_VISATTR *, int *);
    116 //typedef HRESULT (WINAPI *fScriptPlace)( HDC, SCRIPT_CACHE *, const WORD *, int, const SCRIPT_VISATTR *, QScriptAnalysis *, int *,
    117 //                                      GOFFSET *, ABC * );
    118 //typedef HRESULT (WINAPI *fScriptTextOut)( const HDC, SCRIPT_CACHE *, int, int, UINT, const RECT *, const QScriptAnalysis *,
    119 //                                       const WCHAR *, int, const WORD *, int, const int *, const int *, const GOFFSET *);
    120 //typedef HRESULT (WINAPI *fScriptBreak)( const WCHAR *, int, const QScriptAnalysis *, QCharAttributes * );
    121 ////typedef HRESULT (WINAPI *fScriptGetFontProperties)( HDC, SCRIPT_CACHE *, SCRIPT_FONTPROPERTIES * );
    122 //typedef HRESULT (WINAPI *fScriptGetProperties)( const SCRIPT_PROPERTIES ***, int *);
    123 //
    124 //fScriptFreeCache ScriptFreeCache = 0;
    125 //static fScriptItemize ScriptItemize = 0;
    126 //static fScriptShape ScriptShape = 0;
    127 //static fScriptPlace ScriptPlace = 0;
    128 //fScriptTextOut ScriptTextOut = 0;
    129 //static fScriptBreak ScriptBreak = 0;
    130 ////static fScriptGetFontProperties ScriptGetFontProperties = 0;
    131 //static fScriptGetProperties ScriptGetProperties = 0;
    132 //
    133 //static bool resolvedUsp10 = FALSE;
    134 //bool hasUsp10 = FALSE;
    135 //
    136 //const SCRIPT_PROPERTIES **script_properties = 0;
    137 //int num_scripts = 0;
    138 //int usp_latin_script = 0;
    139 //
    140 //
    141 //const QFont::Script japanese_tryScripts[] = {
    142 //    QFont::Latin,
    143 //    QFont::Han_Japanese,
    144 //    QFont::Hangul,
    145 //    QFont::Han_SimplifiedChinese,
    146 //    QFont::Han_TraditionalChinese
    147 //};
    148 //
    149 //const QFont::Script korean_tryScripts[] = {
    150 //    QFont::Latin,
    151 //    QFont::Hangul,
    152 //    QFont::Han_Japanese,
    153 //    QFont::Han_SimplifiedChinese,
    154 //    QFont::Han_TraditionalChinese
    155 //};
    156 //
    157 //const QFont::Script simplifiedChinese_tryScripts[] = {
    158 //    QFont::Latin,
    159 //    QFont::Han_SimplifiedChinese,
    160 //    QFont::Han_TraditionalChinese,
    161 //    QFont::Han_Japanese,
    162 //    QFont::Hangul
    163 //};
    164 //
    165 //const QFont::Script traditionalChinese_tryScripts[] = {
    166 //    QFont::Latin,
    167 //    QFont::Han_TraditionalChinese,
    168 //    QFont::Han_SimplifiedChinese,
    169 //    QFont::Han_Japanese,
    170 //    QFont::Hangul
    171 //};
    172 //
    173 //const QFont::Script *tryScripts = japanese_tryScripts;
    174 //
    175 //static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir);
    176 //
    177 //static void resolveUsp10()
    178 //{
    179 //#ifndef QT_NO_COMPONENT
    180 //    if ( !resolvedUsp10 ) {
    181 //      // need to resolve the security info functions
    182 //
    183 //#ifdef QT_THREAD_SUPPORT
    184 //      // protect initialization
    185 //      QMutexLocker locker( qt_global_mutexpool ?
    186 //                           qt_global_mutexpool->get( (void*)&resolveUsp10 ) : 0 );
    187 //      // check triedResolve again, since another thread may have already
    188 //      // done the initialization
    189 //      if ( resolvedUsp10 ) {
    190 //          // another thread did initialize the security function pointers,
    191 //          // so we shouldn't do it again.
    192 //          return;
    193 //      }
    194 //#endif
    195 //
    196 //      resolvedUsp10 = TRUE;
    197 //      QLibrary lib("usp10");
    198 //      lib.setAutoUnload( FALSE );
    199 //
    200 //      ScriptFreeCache = (fScriptFreeCache) lib.resolve( "ScriptFreeCache" );
    201 //      ScriptItemize = (fScriptItemize) lib.resolve( "ScriptItemize" );
    202 //      ScriptShape = (fScriptShape) lib.resolve( "ScriptShape" );
    203 //      ScriptPlace = (fScriptPlace) lib.resolve( "ScriptPlace" );
    204 //      ScriptTextOut = (fScriptTextOut) lib.resolve( "ScriptTextOut" );
    205 //      ScriptBreak = (fScriptBreak) lib.resolve( "ScriptBreak" );
    206 //      ScriptGetProperties = (fScriptGetProperties) lib.resolve( "ScriptGetProperties" );
    207 //
    208 //      if ( !ScriptFreeCache )
    209 //          return;
    210 //
    211 //      hasUsp10 = TRUE;
    212 //      ScriptGetProperties( &script_properties, &num_scripts );
    213 //
    214 //      // get the usp script for western
    215 //      for( int i = 0; i < num_scripts; i++ ) {
    216 //          if (script_properties[i]->langid == LANG_ENGLISH &&
    217 //              !script_properties[i]->fAmbiguousCharSet ) {
    218 //              usp_latin_script = i;
    219 //              break;
    220 //          }
    221 //      }
    222 //
    223 //      // initialize tryScripts according to locale
    224 //      LANGID lid = GetUserDefaultLangID();
    225 //      switch( lid&0xff ) {
    226 //      case LANG_CHINESE: // Chinese (Taiwan)
    227 //          if ( lid == 0x0804 ) // Taiwan
    228 //              tryScripts = traditionalChinese_tryScripts;
    229 //          else
    230 //              tryScripts = simplifiedChinese_tryScripts;
    231 //          break;
    232 //      case LANG_JAPANESE:
    233 //          // japanese is already the default
    234 //          break;
    235 //      case LANG_KOREAN:
    236 //              tryScripts = korean_tryScripts;
    237 //              break;
    238 //      default:
    239 //          break;
    240 //      }
    241 //
    242 //      appendItems = uspAppendItems;
    243 //    }
    244 //#endif
    245 //}
    246 //
    247 //static unsigned char script_for_win_language[ 0x80 ] = {
    248 //    //0x00 LANG_NEUTRAL Neutral
    249 //    QFont::Latin,
    250 //    //0x01 LANG_ARABIC Arabic
    251 //    QFont::Arabic,
    252 //    //0x02 LANG_BULGARIAN Bulgarian
    253 //    QFont::NScripts,
    254 //    //0x03 LANG_CATALAN Catalan
    255 //    QFont::NScripts,
    256 //    //0x04 LANG_CHINESE Chinese
    257 //    QFont::Han,
    258 //    //0x05 LANG_CZECH Czech
    259 //    QFont::NScripts,
    260 //    //0x06 LANG_DANISH Danish
    261 //    QFont::NScripts,
    262 //    //0x07 LANG_GERMAN German
    263 //    QFont::NScripts,
    264 //    //0x08 LANG_GREEK Greek
    265 //    QFont::Greek,
    266 //    //0x09 LANG_ENGLISH English
    267 //    QFont::Latin,
    268 //    //0x0a LANG_SPANISH Spanish
    269 //    QFont::NScripts,
    270 //    //0x0b LANG_FINNISH Finnish
    271 //    QFont::NScripts,
    272 //    //0x0c LANG_FRENCH French
    273 //    QFont::NScripts,
    274 //    //0x0d LANG_HEBREW Hebrew
    275 //    QFont::Hebrew,
    276 //    //0x0e LANG_HUNGARIAN Hungarian
    277 //    QFont::NScripts,
    278 //    //0x0f LANG_ICELANDIC Icelandic
    279 //    QFont::NScripts,
    280 //
    281 //    //0x10 LANG_ITALIAN Italian
    282 //    QFont::NScripts,
    283 //    //0x11 LANG_JAPANESE Japanese
    284 //    QFont::Hiragana,
    285 //    //0x12 LANG_KOREAN Korean
    286 //    QFont::Hangul,
    287 //    //0x13 LANG_DUTCH Dutch
    288 //    QFont::NScripts,
    289 //    //0x14 LANG_NORWEGIAN Norwegian
    290 //    QFont::NScripts,
    291 //    //0x15 LANG_POLISH Polish
    292 //    QFont::NScripts,
    293 //    //0x16 LANG_PORTUGUESE Portuguese
    294 //    QFont::NScripts,
    295 //    QFont::NScripts,
    296 //    //0x18 LANG_ROMANIAN Romanian
    297 //    QFont::NScripts,
    298 //    //0x19 LANG_RUSSIAN Russian
    299 //    QFont::Cyrillic,
    300 //    //0x1a LANG_CROATIAN Croatian
    301 //    //0x1a LANG_SERBIAN Serbian
    302 //    QFont::NScripts,
    303 //    //0x1b LANG_SLOVAK Slovak
    304 //    QFont::NScripts,
    305 //    //0x1c LANG_ALBANIAN Albanian
    306 //    QFont::NScripts,
    307 //    //0x1d LANG_SWEDISH Swedish
    308 //    QFont::NScripts,
    309 //    //0x1e LANG_THAI Thai
    310 //    QFont::Thai,
    311 //    //0x1f LANG_TURKISH Turkish
    312 //    QFont::NScripts,
    313 //
    314 //    //0x20 LANG_URDU Urdu
    315 //    QFont::NScripts,
    316 //    //0x21 LANG_INDONESIAN Indonesian
    317 //    QFont::NScripts,
    318 //    //0x22 LANG_UKRAINIAN Ukrainian
    319 //    QFont::NScripts,
    320 //    //0x23 LANG_BELARUSIAN Belarusian
    321 //    QFont::NScripts,
    322 //    //0x24 LANG_SLOVENIAN Slovenian
    323 //    QFont::NScripts,
    324 //    //0x25 LANG_ESTONIAN Estonian
    325 //    QFont::NScripts,
    326 //    //0x26 LANG_LATVIAN Latvian
    327 //    QFont::NScripts,
    328 //    //0x27 LANG_LITHUANIAN Lithuanian
    329 //    QFont::NScripts,
    330 //    QFont::NScripts,
    331 //    //0x29 LANG_FARSI Farsi
    332 //    QFont::NScripts,
    333 //    //0x2a LANG_VIETNAMESE Vietnamese
    334 //    QFont::Latin, // ##### maybe use QFont::CombiningMarks instead?
    335 //    //0x2b LANG_ARMENIAN Armenian
    336 //    QFont::Armenian,
    337 //    //0x2c LANG_AZERI Azeri
    338 //    QFont::NScripts,
    339 //    //0x2d LANG_BASQUE Basque
    340 //    QFont::NScripts,
    341 //    QFont::NScripts,
    342 //    //0x2f LANG_MACEDONIAN FYRO Macedonian
    343 //    QFont::NScripts,
    344 //
    345 //    QFont::NScripts,
    346 //    QFont::NScripts,
    347 //    QFont::NScripts,
    348 //    QFont::NScripts,
    349 //    QFont::NScripts,
    350 //    QFont::NScripts,
    351 //    //0x36 LANG_AFRIKAANS Afrikaans
    352 //    QFont::NScripts,
    353 //    //0x37 LANG_GEORGIAN Georgian
    354 //    QFont::NScripts,
    355 //    //0x38 LANG_FAEROESE Faeroese
    356 //    QFont::NScripts,
    357 //    //0x39 LANG_HINDI Hindi
    358 //    QFont::Devanagari,
    359 //    QFont::NScripts,
    360 //    QFont::NScripts,
    361 //    QFont::NScripts,
    362 //    QFont::NScripts,
    363 //    //0x3e LANG_MALAY Malay
    364 //    QFont::NScripts,
    365 //    //0x3f LANG_KAZAK Kazak
    366 //    QFont::NScripts,
    367 //
    368 //    //0x40 LANG_KYRGYZ Kyrgyz
    369 //    QFont::NScripts,
    370 //    //0x41 LANG_SWAHILI Swahili
    371 //    QFont::NScripts,
    372 //    QFont::NScripts,
    373 //    //0x43 LANG_UZBEK Uzbek
    374 //    QFont::NScripts,
    375 //    //0x44 LANG_TATAR Tatar
    376 //    QFont::NScripts,
    377 //    //0x45 LANG_BENGALI Not supported.
    378 //    QFont::Bengali,
    379 //    //0x46 LANG_PUNJABI Punjabi
    380 //    QFont::Gurmukhi,
    381 //    //0x47 LANG_GUJARATI Gujarati
    382 //    QFont::Gujarati,
    383 //    //0x48 LANG_ORIYA Not supported.
    384 //    QFont::Oriya,
    385 //    //0x49 LANG_TAMIL Tamil
    386 //    QFont::Tamil,
    387 //    //0x4a LANG_TELUGU Telugu
    388 //    QFont::Telugu,
    389 //    //0x4b LANG_KANNADA Kannada
    390 //    QFont::Kannada,
    391 //    //0x4c LANG_MALAYALAM Not supported.
    392 //    QFont::Malayalam,
    393 //    //0x4d LANG_ASSAMESE Not supported.
    394 //    QFont::NScripts,
    395 //    //0x4e LANG_MARATHI Marathi
    396 //    QFont::NScripts,
    397 //    //0x4f LANG_SANSKRIT Sanskrit
    398 //    QFont::Devanagari,
    399 //
    400 //    //0x50 LANG_MONGOLIAN Mongolian
    401 //    QFont::Mongolian,
    402 //    QFont::NScripts,
    403 //    QFont::NScripts,
    404 //    QFont::NScripts,
    405 //    QFont::NScripts,
    406 //    QFont::NScripts,
    407 //    //0x56 LANG_GALICIAN Galician
    408 //    QFont::NScripts,
    409 //    //0x57 LANG_KONKANI Konkani
    410 //    QFont::NScripts,
    411 //    //0x58 LANG_MANIPURI Not supported.
    412 //    QFont::NScripts,
    413 //    //0x59 LANG_SINDHI Not supported.
    414 //    QFont::NScripts,
    415 //    //0x5a LANG_SYRIAC Syriac
    416 //    QFont::Syriac,
    417 //    QFont::NScripts,
    418 //    QFont::NScripts,
    419 //    QFont::NScripts,
    420 //    QFont::NScripts,
    421 //    QFont::NScripts,
    422 //
    423 //    //0x60 LANG_KASHMIRI Not supported.
    424 //    QFont::NScripts,
    425 //    //0x61 LANG_NEPALI Not supported.
    426 //    QFont::NScripts,
    427 //    QFont::NScripts,
    428 //    QFont::NScripts,
    429 //    QFont::NScripts,
    430 //    //0x65 LANG_DIVEHI Divehi
    431 //    QFont::NScripts,
    432 //    QFont::NScripts,
    433 //    QFont::NScripts,
    434 //    QFont::NScripts,
    435 //    QFont::NScripts,
    436 //    QFont::NScripts,
    437 //    QFont::NScripts,
    438 //    QFont::NScripts,
    439 //    QFont::NScripts,
    440 //    QFont::NScripts,
    441 //    QFont::NScripts,
    442 //
    443 //    QFont::NScripts,
    444 //    QFont::NScripts,
    445 //    QFont::NScripts,
    446 //    QFont::NScripts,
    447 //    QFont::NScripts,
    448 //    QFont::NScripts,
    449 //    QFont::NScripts,
    450 //    QFont::NScripts,
    451 //    QFont::NScripts,
    452 //    QFont::NScripts,
    453 //    QFont::NScripts,
    454 //    QFont::NScripts,
    455 //    QFont::NScripts,
    456 //    QFont::NScripts,
    457 //    QFont::NScripts,
    458 //    //0x7f LANG_INVARIANT
    459 //    QFont::NScripts,
    460 //};
    461 //
    462 //static inline QFont::Script scriptForWinLanguage( DWORD langid )
    463 //{
    464 //    QFont::Script script = (QFont::Script)script_for_win_language[langid];
    465 //    if ( script == QFont::NScripts )
    466 //      qWarning( "Qt Uniscribe support: Encountered unhandled language id %x", (unsigned int)langid );
    467 //    return script;
    468 //}
    469 //
    470 //static inline bool isAsian( unsigned short ch )
    471 //{
    472 //    return (ch > 0x2dff && ch < 0xfb00) || ((ch & 0xff00) == 0x1100);
    473 //}
    474 //
    475 //
    476 //// we're not using Uniscribe's BiDi algorithm, since it is (a) not 100% Unicode compliant and
    477 //// (b) seems to work wrongly when trying to use it with a base level != 0.
    478 ////
    479 //// This function does uses Uniscribe to do the script analysis and creates items from this.
    480 //static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir)
    481 //{
    482 //    QScriptItemArray &items = engine->items;
    483 //    const QChar *text = engine->string.unicode();
    484 //
    485 //    if ( start > stop ) {
    486 //      // #### the algorithm is currently not really safe against this. Still needs fixing.
    487 ////    qWarning( "Bidi: appendItems() internal error" );
    488 //      return;
    489 //    }
    490 //
    491 //    int level = control.level();
    492 //
    493 //    if(dir != QChar::DirON) {
    494 //      // add level of run (cases I1 & I2)
    495 //      if( level % 2 ) {
    496 //          if(dir == QChar::DirL || dir == QChar::DirAN || dir == QChar::DirEN )
    497 //              level++;
    498 //      } else {
    499 //          if( dir == QChar::DirR )
    500 //              level++;
    501 //          else if( dir == QChar::DirAN || dir == QChar::DirEN )
    502 //              level += 2;
    503 //      }
    504 //    }
    505 //
    506 //    SCRIPT_ITEM s_items[256];
    507 //    SCRIPT_ITEM *usp_items = s_items;
    508 //
    509 //    int numItems;
    510 //    HRESULT res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, 255, 0, 0, usp_items, &numItems );
    511 //
    512 //    if ( res == E_OUTOFMEMORY ) {
    513 //      int alloc = 256;
    514 //      usp_items = 0;
    515 //      while( res == E_OUTOFMEMORY ) {
    516 //          alloc *= 2;
    517 //          usp_items = (SCRIPT_ITEM *)realloc( usp_items, alloc * sizeof( SCRIPT_ITEM ) );
    518 //          res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, alloc-1, 0, 0, usp_items, &numItems );
    519 //      }
    520 //    }
    521 //    items.resize( items.size() + numItems );
    522 //    int i;
    523 //    for( i = 0; i < numItems; i++ ) {
    524 //      QScriptItem item;
    525 //      item.analysis = usp_items[i].a;
    526 //      item.position = usp_items[i].iCharPos+start;
    527 //      item.analysis.bidiLevel = level;
    528 //      item.analysis.override = control.override();
    529 //
    530 //      int rstart = usp_items[i].iCharPos;
    531 //      int rstop = usp_items[i+1].iCharPos-1;
    532 //      bool b = TRUE;
    533 //      for ( int j = rstart; j <= rstop; j++ ) {
    534 //
    535 //          unsigned short uc = text[j+start].unicode();
    536 //          QChar::Category category = ::category( uc );
    537 //          if ( uc == 0xfffcU || uc == 0x2028U ) {
    538 //              item.analysis.script = usp_latin_script;
    539 //              item.isObject = TRUE;
    540 //              b = TRUE;
    541 //          } else if ((uc >= 9 && uc <=13) ||
    542 //                     (category >= QChar::Separator_Space && category <= QChar::Separator_Paragraph)) {
    543 //              item.analysis.script = usp_latin_script;
    544 //              item.isSpace = TRUE;
    545 //              item.isTab = (uc == '\t');
    546 //              if (item.isTab)
    547 //                  item.analysis.bidiLevel = control.baseLevel();
    548 //              b = TRUE;
    549 //          } else if (b) {
    550 //              b = FALSE;
    551 //          } else {
    552 //              continue;
    553 //          }
    554 //
    555 //          item.position = j+start;
    556 //          items.append( item );
    557 //          item.analysis = usp_items[i].a;
    558 //          item.analysis.bidiLevel = level;
    559 //          item.analysis.override = control.override();
    560 //          item.isSpace = item.isTab = item.isObject = FALSE;
    561 //      }
    562 //    }
    563 //
    564 //    if ( usp_items != s_items )
    565 //      free( usp_items );
    566 //
    567 //    ++stop;
    568 //    start = stop;
    569 //}
    570 
     480// This function does uses Uniscribe to do the script analysis and creates items from this.
     481static void uspAppendItems(QTextEngine *engine, int &start, int &stop, BidiControl &control, QChar::Direction dir)
     482{
     483    QScriptItemArray &items = engine->items;
     484    const QChar *text = engine->string.unicode();
     485
     486    if ( start > stop ) {
     487        // #### the algorithm is currently not really safe against this. Still needs fixing.
     488//      qWarning( "Bidi: appendItems() internal error" );
     489        return;
     490    }
     491
     492    int level = control.level();
     493
     494    if(dir != QChar::DirON) {
     495        // add level of run (cases I1 & I2)
     496        if( level % 2 ) {
     497            if(dir == QChar::DirL || dir == QChar::DirAN || dir == QChar::DirEN )
     498                level++;
     499        } else {
     500            if( dir == QChar::DirR )
     501                level++;
     502            else if( dir == QChar::DirAN || dir == QChar::DirEN )
     503                level += 2;
     504        }
     505    }
     506
     507    SCRIPT_ITEM s_items[256];
     508    SCRIPT_ITEM *usp_items = s_items;
     509
     510    int numItems;
     511    HRESULT res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, 255, 0, 0, usp_items, &numItems );
     512
     513    if ( res == E_OUTOFMEMORY ) {
     514        int alloc = 256;
     515        usp_items = 0;
     516        while( res == E_OUTOFMEMORY ) {
     517            alloc *= 2;
     518            usp_items = (SCRIPT_ITEM *)realloc( usp_items, alloc * sizeof( SCRIPT_ITEM ) );
     519            res = ScriptItemize( (WCHAR *)(text+start), stop-start+1, alloc-1, 0, 0, usp_items, &numItems );
     520        }
     521    }
     522    items.resize( items.size() + numItems );
     523    int i;
     524    for( i = 0; i < numItems; i++ ) {
     525        QScriptItem item;
     526        item.analysis = usp_items[i].a;
     527        item.position = usp_items[i].iCharPos+start;
     528        item.analysis.bidiLevel = level;
     529        item.analysis.override = control.override();
     530
     531        int rstart = usp_items[i].iCharPos;
     532        int rstop = usp_items[i+1].iCharPos-1;
     533        bool b = TRUE;
     534        for ( int j = rstart; j <= rstop; j++ ) {
     535
     536            unsigned short uc = text[j+start].unicode();
     537            QChar::Category category = ::category( uc );
     538            if ( uc == 0xfffcU || uc == 0x2028U ) {
     539                item.analysis.script = usp_latin_script;
     540                item.isObject = TRUE;
     541                b = TRUE;
     542            } else if ((uc >= 9 && uc <=13) ||
     543                       (category >= QChar::Separator_Space && category <= QChar::Separator_Paragraph)) {
     544                item.analysis.script = usp_latin_script;
     545                item.isSpace = TRUE;
     546                item.isTab = (uc == '\t');
     547                if (item.isTab)
     548                    item.analysis.bidiLevel = control.baseLevel();
     549                b = TRUE;
     550            } else if (b) {
     551                b = FALSE;
     552            } else {
     553                continue;
     554            }
     555
     556            item.position = j+start;
     557            items.append( item );
     558            item.analysis = usp_items[i].a;
     559            item.analysis.bidiLevel = level;
     560            item.analysis.override = control.override();
     561            item.isSpace = item.isTab = item.isObject = FALSE;
     562        }
     563    }
     564
     565    if ( usp_items != s_items )
     566        free( usp_items );
     567
     568    ++stop;
     569    start = stop;
     570}
     571#endif // if 0
    571572
    572573// -----------------------------------------------------------------------------------------------------
  • trunk/src/widgets/qsplitter.cpp

    r19 r20  
    514514    int hw = handleWidth();
    515515
    516     int p1, p2, op1, op2, tmp;
     516    int p1 = 0, p2 = 0, op1 = 0, op2 = 0, tmp = 0;
    517517    if ( p >= 0 ) {
    518518        p1 = p + hw / 2 - rBord;
Note: See TracChangeset for help on using the changeset viewer.