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

Fixed a bunch of compiler warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.