| 1 | /**************************************************************************** | 
|---|
| 2 | ** $Id: qfontdatabase_pm.cpp 8 2005-11-16 19:36:46Z dmik $ | 
|---|
| 3 | ** | 
|---|
| 4 | ** Implementation of QFontDatabase class for OS/2 | 
|---|
| 5 | ** | 
|---|
| 6 | ** Copyright (C) 1997-2002 Trolltech AS.  All rights reserved. | 
|---|
| 7 | ** Copyright (C) 2004 Norman ASA.  Initial OS/2 Port. | 
|---|
| 8 | ** Copyright (C) 2005 netlabs.org.  Further OS/2 Development. | 
|---|
| 9 | ** | 
|---|
| 10 | ** This file is part of the kernel module of the Qt GUI Toolkit. | 
|---|
| 11 | ** | 
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file | 
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 15 | ** | 
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 19 | ** packaging of this file. | 
|---|
| 20 | ** | 
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License | 
|---|
| 23 | ** Agreement provided with the Software. | 
|---|
| 24 | ** | 
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 27 | ** | 
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 29 | **   information about Qt Commercial License Agreements. | 
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 32 | ** | 
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 34 | ** not clear to you. | 
|---|
| 35 | ** | 
|---|
| 36 | **********************************************************************/ | 
|---|
| 37 |  | 
|---|
| 38 | #include "qt_os2.h" | 
|---|
| 39 | #include "qapplication_p.h" | 
|---|
| 40 | #include "qfontdata_p.h" | 
|---|
| 41 | #include "qfontengine_p.h" | 
|---|
| 42 | #include "qpaintdevicemetrics.h" | 
|---|
| 43 |  | 
|---|
| 44 | //@@TODO (dmik): remove | 
|---|
| 45 | //extern HDC   shared_dc;               // common dc for all fonts | 
|---|
| 46 | //static HFONT stock_sysfont  = 0; | 
|---|
| 47 |  | 
|---|
| 48 | //@@TODO (dmik): remove | 
|---|
| 49 | //// see the Unicode subset bitfields in the MSDN docs | 
|---|
| 50 | //static int requiredUnicodeBits[QFont::NScripts][2] = { | 
|---|
| 51 | //    //Latin, | 
|---|
| 52 | //    { 0, 1 }, | 
|---|
| 53 | //    //Greek, | 
|---|
| 54 | //    { 7, 127 }, | 
|---|
| 55 | //    //Cyrillic, | 
|---|
| 56 | //    { 9, 127 }, | 
|---|
| 57 | //    //Armenian, | 
|---|
| 58 | //    { 10, 127 }, | 
|---|
| 59 | //    //Georgian, | 
|---|
| 60 | //    { 26, 127 }, | 
|---|
| 61 | //    //Runic, | 
|---|
| 62 | //    { 79, 127 }, | 
|---|
| 63 | //    //Ogham, | 
|---|
| 64 | //    { 78, 127 }, | 
|---|
| 65 | //    //SpacingModifiers, | 
|---|
| 66 | //    { 5, 127 }, | 
|---|
| 67 | //    //CombiningMarks, | 
|---|
| 68 | //    { 6, 127 }, | 
|---|
| 69 | // | 
|---|
| 70 | //    // Middle Eastern Scripts | 
|---|
| 71 | //    //Hebrew, | 
|---|
| 72 | //    { 11, 127 }, | 
|---|
| 73 | //    //Arabic, | 
|---|
| 74 | //    { 13, 67 }, | 
|---|
| 75 | //    //Syriac, | 
|---|
| 76 | //    { 71, 127 }, | 
|---|
| 77 | //    //Thaana, | 
|---|
| 78 | //    { 72, 127 }, | 
|---|
| 79 | // | 
|---|
| 80 | //    // South and Southeast Asian Scripts | 
|---|
| 81 | //    //Devanagari, | 
|---|
| 82 | //    { 15, 127 }, | 
|---|
| 83 | //    //Bengali, | 
|---|
| 84 | //    { 16, 127 }, | 
|---|
| 85 | //    //Gurmukhi, | 
|---|
| 86 | //    { 17, 127 }, | 
|---|
| 87 | //    //Gujarati, | 
|---|
| 88 | //    { 18, 127 }, | 
|---|
| 89 | //    //Oriya, | 
|---|
| 90 | //    { 19, 127 }, | 
|---|
| 91 | //    //Tamil, | 
|---|
| 92 | //    { 20, 127 }, | 
|---|
| 93 | //    //Telugu, | 
|---|
| 94 | //    { 21, 127 }, | 
|---|
| 95 | //    //Kannada, | 
|---|
| 96 | //    { 22, 127 }, | 
|---|
| 97 | //    //Malayalam, | 
|---|
| 98 | //    { 23, 127 }, | 
|---|
| 99 | //    //Sinhala, | 
|---|
| 100 | //    { 73, 127 }, | 
|---|
| 101 | //    //Thai, | 
|---|
| 102 | //    { 24, 127 }, | 
|---|
| 103 | //    //Lao, | 
|---|
| 104 | //    { 25, 127 }, | 
|---|
| 105 | //    //Tibetan, | 
|---|
| 106 | //    { 70, 127 }, | 
|---|
| 107 | //    //Myanmar, | 
|---|
| 108 | //    { 74, 127 }, | 
|---|
| 109 | //    //Khmer, | 
|---|
| 110 | //    { 80, 127 }, | 
|---|
| 111 | // | 
|---|
| 112 | //    // East Asian Scripts | 
|---|
| 113 | //    //Han, | 
|---|
| 114 | //    { 59, 127 }, | 
|---|
| 115 | //    //Hiragana, | 
|---|
| 116 | //    { 49, 127 }, | 
|---|
| 117 | //    //Katakana, | 
|---|
| 118 | //    { 50, 127 }, | 
|---|
| 119 | //    //Hangul, | 
|---|
| 120 | //    { 56, 127 }, | 
|---|
| 121 | //    //Bopomofo, | 
|---|
| 122 | //    { 51, 127 }, | 
|---|
| 123 | //    //Yi, | 
|---|
| 124 | //    { 83, 127 }, | 
|---|
| 125 | // | 
|---|
| 126 | //    // Additional Scripts | 
|---|
| 127 | //    //Ethiopic, | 
|---|
| 128 | //    { 75, 127 }, | 
|---|
| 129 | //    //Cherokee, | 
|---|
| 130 | //    { 76, 127 }, | 
|---|
| 131 | //    //CanadianAboriginal, | 
|---|
| 132 | //    { 77, 127 }, | 
|---|
| 133 | //    //Mongolian, | 
|---|
| 134 | //    { 81, 127 }, | 
|---|
| 135 | // | 
|---|
| 136 | //    // Symbols | 
|---|
| 137 | //    //CurrencySymbols, | 
|---|
| 138 | //    { 33, 127 }, | 
|---|
| 139 | //    //LetterlikeSymbols, | 
|---|
| 140 | //    { 35, 127 }, | 
|---|
| 141 | //    //NumberForms, | 
|---|
| 142 | //    { 36, 127 }, | 
|---|
| 143 | //    //MathematicalOperators, | 
|---|
| 144 | //    { 38, 127 }, | 
|---|
| 145 | //    //TechnicalSymbols, | 
|---|
| 146 | //    { 39, 127 }, | 
|---|
| 147 | //    //GeometricSymbols, | 
|---|
| 148 | //    { 43, 127 }, | 
|---|
| 149 | //    //MiscellaneousSymbols, | 
|---|
| 150 | //    { 46, 127 }, | 
|---|
| 151 | //    //EnclosedAndSquare, | 
|---|
| 152 | //    { 42, 127 }, | 
|---|
| 153 | //    //Braille, | 
|---|
| 154 | //    { 82, 127 }, | 
|---|
| 155 | // | 
|---|
| 156 | //    //Unicode, | 
|---|
| 157 | //    { 126, 126 }, | 
|---|
| 158 | // | 
|---|
| 159 | //    // some scripts added in Unicode 3.2 | 
|---|
| 160 | //    //Tagalog, | 
|---|
| 161 | //    { 84, 127 }, | 
|---|
| 162 | //    //Hanunoo, | 
|---|
| 163 | //    { 84, 127 }, | 
|---|
| 164 | //    //Buhid, | 
|---|
| 165 | //    { 84, 127 }, | 
|---|
| 166 | //    //Tagbanwa, | 
|---|
| 167 | //    { 84, 127 } | 
|---|
| 168 | //}; | 
|---|
| 169 | // | 
|---|
| 170 | // | 
|---|
| 171 | //#define SimplifiedChineseCsbBit 18 | 
|---|
| 172 | //#define TraditionalChineseCsbBit 20 | 
|---|
| 173 | //#define JapaneseCsbBit 17 | 
|---|
| 174 | //#define KoreanCsbBit 21 | 
|---|
| 175 |  | 
|---|
| 176 | //@@TODO (dmik): remove | 
|---|
| 177 | //static | 
|---|
| 178 | //int CALLBACK | 
|---|
| 179 | //#ifndef Q_OS_TEMP | 
|---|
| 180 | //storeFont( ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, int type, LPARAM /*p*/ ) | 
|---|
| 181 | //#else | 
|---|
| 182 | //storeFont( ENUMLOGFONTEX* f, NEWTEXTMETRIC *textmetric, int type, LPARAM /*p*/ ) | 
|---|
| 183 | //#endif | 
|---|
| 184 | //{ | 
|---|
| 185 | //    const int script = QFont::Unicode; | 
|---|
| 186 | //    const QString foundryName; | 
|---|
| 187 | //    const bool smoothScalable = TRUE; | 
|---|
| 188 | //    const bool oblique = FALSE; | 
|---|
| 189 | //    Q_UNUSED( script ); | 
|---|
| 190 | //    Q_UNUSED( smoothScalable ); | 
|---|
| 191 | // | 
|---|
| 192 | //    bool italic = FALSE; | 
|---|
| 193 | //    QString familyName; | 
|---|
| 194 | //    int weight; | 
|---|
| 195 | //    bool fixed; | 
|---|
| 196 | // | 
|---|
| 197 | //    // ### make non scalable fonts work | 
|---|
| 198 | // | 
|---|
| 199 | //    QT_WA( { | 
|---|
| 200 | //      familyName = QString::fromUcs2( (ushort*)f->elfLogFont.lfFaceName ); | 
|---|
| 201 | //      italic = f->elfLogFont.lfItalic; | 
|---|
| 202 | //      weight = f->elfLogFont.lfWeight; | 
|---|
| 203 | //      TEXTMETRIC *tm = (TEXTMETRIC *)textmetric; | 
|---|
| 204 | //      fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH); | 
|---|
| 205 | //    } , { | 
|---|
| 206 | //      ENUMLOGFONTEXA* fa = (ENUMLOGFONTEXA *)f; | 
|---|
| 207 | //      familyName = QString::fromLocal8Bit( fa->elfLogFont.lfFaceName ); | 
|---|
| 208 | //      italic = fa->elfLogFont.lfItalic; | 
|---|
| 209 | //      weight = fa->elfLogFont.lfWeight; | 
|---|
| 210 | //      TEXTMETRICA *tm = (TEXTMETRICA *)textmetric; | 
|---|
| 211 | //      fixed = !(tm->tmPitchAndFamily & TMPF_FIXED_PITCH); | 
|---|
| 212 | //    } ); | 
|---|
| 213 | //    // the "@family" fonts are just the same as "family". Ignore them. | 
|---|
| 214 | //    if ( familyName[0] != '@' ) { | 
|---|
| 215 | //      QtFontStyle::Key styleKey; | 
|---|
| 216 | //      styleKey.italic = italic; | 
|---|
| 217 | //      styleKey.oblique = oblique; | 
|---|
| 218 | //      if ( weight < 400 ) | 
|---|
| 219 | //          styleKey.weight = QFont::Light; | 
|---|
| 220 | //      else if ( weight < 600 ) | 
|---|
| 221 | //          styleKey.weight = QFont::Normal; | 
|---|
| 222 | //      else if ( weight < 700 ) | 
|---|
| 223 | //          styleKey.weight = QFont::DemiBold; | 
|---|
| 224 | //      else if ( weight < 800 ) | 
|---|
| 225 | //          styleKey.weight = QFont::Bold; | 
|---|
| 226 | //      else | 
|---|
| 227 | //          styleKey.weight = QFont::Black; | 
|---|
| 228 | // | 
|---|
| 229 | //      QString rawName = familyName; | 
|---|
| 230 | //      familyName.replace('-', ' '); | 
|---|
| 231 | //      QtFontFamily *family = db->family( familyName, TRUE ); | 
|---|
| 232 | //      family->rawName = rawName; | 
|---|
| 233 | // | 
|---|
| 234 | //      QtFontFoundry *foundry = family->foundry( foundryName,  TRUE ); | 
|---|
| 235 | //      QtFontStyle *style = foundry->style( styleKey,  TRUE ); | 
|---|
| 236 | //      style->smoothScalable = TRUE; | 
|---|
| 237 | //      style->pixelSize( SMOOTH_SCALABLE, TRUE ); | 
|---|
| 238 | // | 
|---|
| 239 | //      // add fonts windows can generate for us: | 
|---|
| 240 | //      if ( styleKey.weight <= QFont::DemiBold ) { | 
|---|
| 241 | //          QtFontStyle::Key key( styleKey ); | 
|---|
| 242 | //          key.weight = QFont::Bold; | 
|---|
| 243 | //          QtFontStyle *style = foundry->style( key,  TRUE ); | 
|---|
| 244 | //          style->smoothScalable = TRUE; | 
|---|
| 245 | //          style->pixelSize( SMOOTH_SCALABLE, TRUE ); | 
|---|
| 246 | //      } | 
|---|
| 247 | //      if ( !styleKey.italic ) { | 
|---|
| 248 | //          QtFontStyle::Key key( styleKey ); | 
|---|
| 249 | //          key.italic = TRUE; | 
|---|
| 250 | //          QtFontStyle *style = foundry->style( key,  TRUE ); | 
|---|
| 251 | //          style->smoothScalable = TRUE; | 
|---|
| 252 | //          style->pixelSize( SMOOTH_SCALABLE, TRUE ); | 
|---|
| 253 | //      } | 
|---|
| 254 | //      if ( styleKey.weight <= QFont::DemiBold && !styleKey.italic ) { | 
|---|
| 255 | //          QtFontStyle::Key key( styleKey ); | 
|---|
| 256 | //          key.weight = QFont::Bold; | 
|---|
| 257 | //          key.italic = TRUE; | 
|---|
| 258 | //          QtFontStyle *style = foundry->style( key,  TRUE ); | 
|---|
| 259 | //          style->smoothScalable = TRUE; | 
|---|
| 260 | //          style->pixelSize( SMOOTH_SCALABLE, TRUE ); | 
|---|
| 261 | //      } | 
|---|
| 262 | // | 
|---|
| 263 | //      family->fixedPitch = fixed; | 
|---|
| 264 | // | 
|---|
| 265 | //      if ( !family->scriptCheck && type & TRUETYPE_FONTTYPE ) { | 
|---|
| 266 | //          bool hasScript = false; | 
|---|
| 267 | //          FONTSIGNATURE signature; | 
|---|
| 268 | //#ifndef Q_OS_TEMP | 
|---|
| 269 | //          QT_WA( { | 
|---|
| 270 | //              signature = textmetric->ntmFontSig; | 
|---|
| 271 | //          }, { | 
|---|
| 272 | //              // the textmetric structure we get from EnumFontFamiliesEx on Win9x has | 
|---|
| 273 | //              // a FONTSIGNATURE, but that one is uninitialized and doesn't work. Have to go | 
|---|
| 274 | //              // the hard way and load the font to find out. | 
|---|
| 275 | //              HDC hdc = GetDC( 0 ); | 
|---|
| 276 | //              LOGFONTA lf; | 
|---|
| 277 | //              memset( &lf, 0, sizeof( LOGFONTA ) ); | 
|---|
| 278 | //              QCString lfam = familyName.local8Bit(); | 
|---|
| 279 | //              memcpy( lf.lfFaceName, familyName.local8Bit(), QMIN( LF_FACESIZE, familyName.local8Bit().length() ) ); | 
|---|
| 280 | //              HFONT hfont = CreateFontIndirectA( &lf ); | 
|---|
| 281 | //              HGDIOBJ oldobj = SelectObject( hdc, hfont ); | 
|---|
| 282 | //              GetTextCharsetInfo( hdc, &signature, 0 ); | 
|---|
| 283 | //              SelectObject( hdc, oldobj ); | 
|---|
| 284 | //              DeleteObject( hfont ); | 
|---|
| 285 | //              ReleaseDC( 0, hdc ); | 
|---|
| 286 | //          } ); | 
|---|
| 287 | //#else | 
|---|
| 288 | //          CHARSETINFO csi; | 
|---|
| 289 | //          DWORD charset = textmetric->tmCharSet; | 
|---|
| 290 | //          TranslateCharsetInfo( &charset, &csi, TCI_SRCCHARSET); | 
|---|
| 291 | //          signature = csi.fs; | 
|---|
| 292 | //#endif | 
|---|
| 293 | // | 
|---|
| 294 | //          int i; | 
|---|
| 295 | //          for( i = 0; i < QFont::Unicode; i++ ) { | 
|---|
| 296 | //              int bit = requiredUnicodeBits[i][0]; | 
|---|
| 297 | //              int index = bit/32; | 
|---|
| 298 | //              int flag =  1 << (bit&31); | 
|---|
| 299 | //              if ( bit != 126 && signature.fsUsb[index] & flag ) { | 
|---|
| 300 | //                  bit = requiredUnicodeBits[i][1]; | 
|---|
| 301 | //                  index = bit/32; | 
|---|
| 302 | // | 
|---|
| 303 | //                  flag =  1 << (bit&31); | 
|---|
| 304 | //                  if ( bit == 127 || signature.fsUsb[index] & flag ) { | 
|---|
| 305 | //                      family->scripts[i] = TRUE; | 
|---|
| 306 | //                      hasScript = TRUE; | 
|---|
| 307 | //                      // qDebug( "font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i ); | 
|---|
| 308 | //                  } | 
|---|
| 309 | //              } | 
|---|
| 310 | //          } | 
|---|
| 311 | //          // ### until we do language detection, it's going to be | 
|---|
| 312 | //          // ### hard to figure out which Han_* variant to | 
|---|
| 313 | //          // ### use... simply mark all Han_* variants as supporting | 
|---|
| 314 | //          // ### Han (like X11) | 
|---|
| 315 | //          if( signature.fsCsb[0] & (1 << SimplifiedChineseCsbBit) ) { | 
|---|
| 316 | //              family->scripts[QFont::Han_SimplifiedChinese] = TRUE; | 
|---|
| 317 | //              family->scripts[QFont::Han] = TRUE; | 
|---|
| 318 | //              hasScript = TRUE; | 
|---|
| 319 | //              //qDebug("font %s supports Simplified Chinese", familyName.latin1() ); | 
|---|
| 320 | //          } | 
|---|
| 321 | //          if( signature.fsCsb[0] & (1 << TraditionalChineseCsbBit) ) { | 
|---|
| 322 | //              family->scripts[QFont::Han_TraditionalChinese] = TRUE; | 
|---|
| 323 | //              family->scripts[QFont::Han] = TRUE; | 
|---|
| 324 | //              hasScript = TRUE; | 
|---|
| 325 | //              //qDebug("font %s supports Traditional Chinese", familyName.latin1() ); | 
|---|
| 326 | //          } | 
|---|
| 327 | //          if( signature.fsCsb[0] & (1 << JapaneseCsbBit) ) { | 
|---|
| 328 | //              family->scripts[QFont::Han_Japanese] = TRUE; | 
|---|
| 329 | //              family->scripts[QFont::Hiragana] = TRUE; | 
|---|
| 330 | //              family->scripts[QFont::Katakana] = TRUE; | 
|---|
| 331 | //              family->scripts[QFont::Han] = TRUE; | 
|---|
| 332 | //              hasScript = TRUE; | 
|---|
| 333 | //              //qDebug("font %s supports Japanese", familyName.latin1() ); | 
|---|
| 334 | //          } | 
|---|
| 335 | //          if( signature.fsCsb[0] & (1 << KoreanCsbBit) ) { | 
|---|
| 336 | //              family->scripts[QFont::Han_Korean] = TRUE; | 
|---|
| 337 | //              family->scripts[QFont::Hangul] = TRUE; | 
|---|
| 338 | //              family->scripts[QFont::Han] = TRUE; | 
|---|
| 339 | //              hasScript = TRUE; | 
|---|
| 340 | //              //qDebug("font %s supports Korean", familyName.latin1() ); | 
|---|
| 341 | //          } | 
|---|
| 342 | // | 
|---|
| 343 | //#ifdef Q_OS_TEMP | 
|---|
| 344 | //          // ##### FIXME | 
|---|
| 345 | //          family->scripts[QFont::Latin] = TRUE; | 
|---|
| 346 | //#endif | 
|---|
| 347 | //          family->scripts[QFont::Unicode] = !hasScript; | 
|---|
| 348 | //          family->scriptCheck = true; | 
|---|
| 349 | //          // qDebug( "usb=%08x %08x csb=%08x for %s", signature.fsUsb[0], signature.fsUsb[1], signature.fsCsb[0], familyName.latin1() ); | 
|---|
| 350 | //      } else if (!family->scriptCheck) { | 
|---|
| 351 | //          family->scripts[QFont::Unicode] = TRUE; | 
|---|
| 352 | //      } | 
|---|
| 353 | //    } | 
|---|
| 354 | // | 
|---|
| 355 | //    // keep on enumerating | 
|---|
| 356 | //    return 1; | 
|---|
| 357 | //} | 
|---|
| 358 |  | 
|---|
| 359 | //@@TODO (dmik): remove | 
|---|
| 360 | //static | 
|---|
| 361 | //void populate_database(const QString& fam) | 
|---|
| 362 | //{ | 
|---|
| 363 | //    HDC dummy = GetDC(0); | 
|---|
| 364 | // | 
|---|
| 365 | //#ifndef Q_OS_TEMP | 
|---|
| 366 | //    QT_WA( { | 
|---|
| 367 | //        LOGFONT lf; | 
|---|
| 368 | //        lf.lfCharSet = DEFAULT_CHARSET; | 
|---|
| 369 | //        if ( fam.isNull() ) { | 
|---|
| 370 | //            lf.lfFaceName[0] = 0; | 
|---|
| 371 | //        } else { | 
|---|
| 372 | //            memcpy( lf.lfFaceName, fam.ucs2(), sizeof(TCHAR)*QMIN(fam.length()+1,32));  // 32 = Windows hard-coded | 
|---|
| 373 | //        } | 
|---|
| 374 | //        lf.lfPitchAndFamily = 0; | 
|---|
| 375 | // | 
|---|
| 376 | //        EnumFontFamiliesEx( dummy, &lf, | 
|---|
| 377 | //            (FONTENUMPROC)storeFont, (LPARAM)db, 0 ); | 
|---|
| 378 | //    } , { | 
|---|
| 379 | //        LOGFONTA lf; | 
|---|
| 380 | //        lf.lfCharSet = DEFAULT_CHARSET; | 
|---|
| 381 | //        if ( fam.isNull() ) { | 
|---|
| 382 | //            lf.lfFaceName[0] = 0; | 
|---|
| 383 | //        } else { | 
|---|
| 384 | //            QCString lname = fam.local8Bit(); | 
|---|
| 385 | //            memcpy(lf.lfFaceName,lname.data(), | 
|---|
| 386 | //                QMIN(lname.length()+1,32));  // 32 = Windows hard-coded | 
|---|
| 387 | //        } | 
|---|
| 388 | //        lf.lfPitchAndFamily = 0; | 
|---|
| 389 | // | 
|---|
| 390 | //      EnumFontFamiliesExA( dummy, &lf, | 
|---|
| 391 | //            (FONTENUMPROCA)storeFont, (LPARAM)db, 0 ); | 
|---|
| 392 | //    } ); | 
|---|
| 393 | //#else | 
|---|
| 394 | //        LOGFONT lf; | 
|---|
| 395 | //        lf.lfCharSet = DEFAULT_CHARSET; | 
|---|
| 396 | //        if ( fam.isNull() ) { | 
|---|
| 397 | //            lf.lfFaceName[0] = 0; | 
|---|
| 398 | //        } else { | 
|---|
| 399 | //            memcpy( lf.lfFaceName, fam.ucs2(), sizeof(TCHAR)*QMIN(fam.length()+1,32));  // 32 = Windows hard-coded | 
|---|
| 400 | //        } | 
|---|
| 401 | //        lf.lfPitchAndFamily = 0; | 
|---|
| 402 | // | 
|---|
| 403 | //        EnumFontFamilies( dummy, lf.lfFaceName, | 
|---|
| 404 | //            (FONTENUMPROC)storeFont, (LPARAM)db ); | 
|---|
| 405 | //#endif | 
|---|
| 406 | // | 
|---|
| 407 | // | 
|---|
| 408 | //    ReleaseDC(0, dummy); | 
|---|
| 409 | //} | 
|---|
| 410 |  | 
|---|
| 411 | //@@TODO (dmik): remove | 
|---|
| 412 | //static void initializeDb() | 
|---|
| 413 | //{ | 
|---|
| 414 | //    if ( db ) return; | 
|---|
| 415 | // | 
|---|
| 416 | //    db = new QFontDatabasePrivate; | 
|---|
| 417 | //    qfontdatabase_cleanup.set(&db); | 
|---|
| 418 | // | 
|---|
| 419 | ////@@TODO (dmik): remove | 
|---|
| 420 | ////    populate_database( QString::null ); | 
|---|
| 421 | // | 
|---|
| 422 | //#ifdef QFONTDATABASE_DEBUG | 
|---|
| 423 | //    // print the database | 
|---|
| 424 | //    for ( int f = 0; f < db->count; f++ ) { | 
|---|
| 425 | //      QtFontFamily *family = db->families[f]; | 
|---|
| 426 | //      qDebug("    %s: %p", family->name.latin1(), family ); | 
|---|
| 427 | //      populate_database( family->name ); | 
|---|
| 428 | // | 
|---|
| 429 | //      qDebug("        scripts supported:"); | 
|---|
| 430 | //        for ( int i = 0; i < QFont::NScripts; i++ ) | 
|---|
| 431 | //          if(family->scripts[i] & QtFontFamily::Supported) | 
|---|
| 432 | //              qDebug("            %d", i ); | 
|---|
| 433 | //      for ( int fd = 0; fd < family->count; fd++ ) { | 
|---|
| 434 | //          QtFontFoundry *foundry = family->foundries[fd]; | 
|---|
| 435 | //          qDebug("        %s", foundry->name.latin1() ); | 
|---|
| 436 | //          for ( int s = 0; s < foundry->count; s++ ) { | 
|---|
| 437 | //              QtFontStyle *style = foundry->styles[s]; | 
|---|
| 438 | //              qDebug("            style: italic=%d oblique=%d weight=%d",  style->key.italic, | 
|---|
| 439 | //                     style->key.oblique, style->key.weight ); | 
|---|
| 440 | //          } | 
|---|
| 441 | //      } | 
|---|
| 442 | //    } | 
|---|
| 443 | //#endif // QFONTDATABASE_DEBUG | 
|---|
| 444 | // | 
|---|
| 445 | //} | 
|---|
| 446 | // | 
|---|
| 447 | //void QFontDatabase::createDatabase() | 
|---|
| 448 | //{ | 
|---|
| 449 | //    initializeDb(); | 
|---|
| 450 | //} | 
|---|
| 451 |  | 
|---|
| 452 | //@@TODO (dmik): remove | 
|---|
| 453 | //static inline void load(const QString &/*family*/ = QString::null,  int = -1 ) | 
|---|
| 454 | //{ | 
|---|
| 455 | //    populate_database( family ); | 
|---|
| 456 | //} | 
|---|
| 457 |  | 
|---|
| 458 | void QFontDatabasePrivate::reload() { | 
|---|
| 459 | cleanup(); | 
|---|
| 460 |  | 
|---|
| 461 | // empty foundry | 
|---|
| 462 | const QString foundryName; | 
|---|
| 463 |  | 
|---|
| 464 | int hps = qt_display_ps(); | 
|---|
| 465 |  | 
|---|
| 466 | LONG cFonts = 0; | 
|---|
| 467 | cFonts = GpiQueryFonts( hps, QF_PUBLIC, NULL, &cFonts, 0, NULL ); | 
|---|
| 468 | PFONTMETRICS afm = new FONTMETRICS [cFonts]; | 
|---|
| 469 | GpiQueryFonts( hps, QF_PUBLIC, NULL, &cFonts, sizeof(FONTMETRICS), afm ); | 
|---|
| 470 |  | 
|---|
| 471 | LONG info [2]; | 
|---|
| 472 | DevQueryCaps( GpiQueryDevice( hps ), CAPS_HORIZONTAL_FONT_RES, 2, info ); | 
|---|
| 473 | LONG xRes = info [0], yRes = info [1]; | 
|---|
| 474 |  | 
|---|
| 475 | for ( PFONTMETRICS fm = afm ; cFonts ; cFonts--, fm++ ) { | 
|---|
| 476 |  | 
|---|
| 477 | // ignore the default (lMatch = 0) GPI font, since it is always | 
|---|
| 478 | // present with non-zero lMatch in the list | 
|---|
| 479 | if ( !fm->lMatch ) | 
|---|
| 480 | continue; | 
|---|
| 481 |  | 
|---|
| 482 | QString familyName = QString::fromLocal8Bit( fm->szFamilyname ); | 
|---|
| 483 | bool italic = fm->fsSelection & FM_SEL_ITALIC; | 
|---|
| 484 | bool fixed = fm->fsType & FM_TYPE_FIXED; | 
|---|
| 485 | bool scalable = fm->fsDefn & FM_DEFN_OUTLINE; | 
|---|
| 486 | USHORT weight = fm->usWeightClass; | 
|---|
| 487 | USHORT width = fm->usWidthClass; | 
|---|
| 488 |  | 
|---|
| 489 | // ignore bitmap fonts that do not match the current device resolution | 
|---|
| 490 | if ( !scalable && (fm->sXDeviceRes != xRes || fm->sYDeviceRes != yRes) ) | 
|---|
| 491 | continue; | 
|---|
| 492 |  | 
|---|
| 493 | //@@TODO (dmik): is the below correct? | 
|---|
| 494 | // the "@family" fonts are the same as "family", but for some Bidi | 
|---|
| 495 | // purposes (?) (and normally used by PM automatically as required). | 
|---|
| 496 | // Ignore them. | 
|---|
| 497 | if ( familyName[0] == '@' ) | 
|---|
| 498 | continue; | 
|---|
| 499 |  | 
|---|
| 500 | QtFontStyle::Key styleKey; | 
|---|
| 501 | styleKey.italic = italic; | 
|---|
| 502 | styleKey.oblique = FALSE; | 
|---|
| 503 |  | 
|---|
| 504 | if ( weight < 4 ) | 
|---|
| 505 | styleKey.weight = QFont::Light; | 
|---|
| 506 | else if ( weight < 6 ) | 
|---|
| 507 | styleKey.weight = QFont::Normal; | 
|---|
| 508 | else if ( weight < 7 ) | 
|---|
| 509 | styleKey.weight = QFont::DemiBold; | 
|---|
| 510 | else if ( weight < 8 ) | 
|---|
| 511 | styleKey.weight = QFont::Bold; | 
|---|
| 512 | else | 
|---|
| 513 | styleKey.weight = QFont::Black; | 
|---|
| 514 |  | 
|---|
| 515 | switch ( width ) { | 
|---|
| 516 | case 1: styleKey.stretch = QFont::UltraCondensed; break; | 
|---|
| 517 | case 2: styleKey.stretch = QFont::ExtraCondensed; break; | 
|---|
| 518 | case 3: styleKey.stretch = QFont::Condensed; break; | 
|---|
| 519 | case 4: styleKey.stretch = QFont::SemiCondensed; break; | 
|---|
| 520 | case 5: styleKey.stretch = QFont::Unstretched; break; | 
|---|
| 521 | case 6: styleKey.stretch = QFont::SemiExpanded; break; | 
|---|
| 522 | case 7: styleKey.stretch = QFont::Expanded; break; | 
|---|
| 523 | case 8: styleKey.stretch = QFont::ExtraExpanded; break; | 
|---|
| 524 | case 9: styleKey.stretch = QFont::UltraExpanded; break; | 
|---|
| 525 | default: styleKey.stretch = QFont::Unstretched; break; | 
|---|
| 526 | } | 
|---|
| 527 |  | 
|---|
| 528 | familyName.replace( '-', ' ' ); | 
|---|
| 529 | QtFontFamily *family = this->family( familyName, TRUE ); | 
|---|
| 530 | //@@TODO (dmik): is it possible that the same family is both fixed and not? | 
|---|
| 531 | family->fixedPitch = fixed; | 
|---|
| 532 |  | 
|---|
| 533 | QtFontFoundry *foundry = family->foundry( foundryName, TRUE ); | 
|---|
| 534 | QtFontStyle *style = foundry->style( styleKey, TRUE ); | 
|---|
| 535 |  | 
|---|
| 536 | // add new scalable style only if it hasn't been already added -- | 
|---|
| 537 | // the first one of two duplicate (in Qt terms) non-bitmap font | 
|---|
| 538 | // styles wins. | 
|---|
| 539 | if ( scalable && style->smoothScalable ) | 
|---|
| 540 | continue; | 
|---|
| 541 |  | 
|---|
| 542 | if ( style->szFacename[0] ) { | 
|---|
| 543 | // if a duplicate (having the same style in Qt terms) bitmap | 
|---|
| 544 | // font is encountered but it has the different facename, ignore | 
|---|
| 545 | // it (we have only one facename field per style -- it should be | 
|---|
| 546 | // the same for all sizes otherwise we will not be able to create | 
|---|
| 547 | // a font with some sizes later). | 
|---|
| 548 | if ( strcmp( style->szFacename, fm->szFacename ) ) | 
|---|
| 549 | continue; | 
|---|
| 550 | } else { | 
|---|
| 551 | strcpy( style->szFacename, fm->szFacename ); | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 | if ( scalable ) { | 
|---|
| 555 | style->smoothScalable = TRUE; | 
|---|
| 556 | QtFontSize *size = | 
|---|
| 557 | style->pixelSize( SMOOTH_SCALABLE, TRUE, fm->sNominalPointSize ); | 
|---|
| 558 | size->lMatch = fm->lMatch; | 
|---|
| 559 | } else { | 
|---|
| 560 | QtFontSize *size = | 
|---|
| 561 | style->pixelSize( fm->lEmHeight, TRUE, fm->sNominalPointSize ); | 
|---|
| 562 | // the first bitmap style with a given pixel and point size wins | 
|---|
| 563 | if ( size->lMatch ) | 
|---|
| 564 | continue; | 
|---|
| 565 | size->lMatch = fm->lMatch; | 
|---|
| 566 | } | 
|---|
| 567 |  | 
|---|
| 568 | } | 
|---|
| 569 |  | 
|---|
| 570 | delete [] afm; | 
|---|
| 571 |  | 
|---|
| 572 | #ifdef QFONTDATABASE_DEBUG | 
|---|
| 573 | // print the database | 
|---|
| 574 | for ( int f = 0; f < count; f++ ) { | 
|---|
| 575 | QtFontFamily *family = families[f]; | 
|---|
| 576 | qDebug("    %s: %p", family->name.latin1(), family ); | 
|---|
| 577 | for ( int fd = 0; fd < family->count; fd++ ) { | 
|---|
| 578 | QtFontFoundry *foundry = family->foundries[fd]; | 
|---|
| 579 | qDebug("        %s", foundry->name.latin1() ); | 
|---|
| 580 | for ( int s = 0; s < foundry->count; s++ ) { | 
|---|
| 581 | QtFontStyle *style = foundry->styles[s]; | 
|---|
| 582 | qDebug("            style: italic=%d oblique=%d weight=%d face=%s", | 
|---|
| 583 | style->key.italic, | 
|---|
| 584 | style->key.oblique, style->key.weight, | 
|---|
| 585 | style->szFacename | 
|---|
| 586 | ); | 
|---|
| 587 | for ( int sz = 0; sz < style->count; sz++ ) { | 
|---|
| 588 | QtFontSize size = style->pixelSizes[sz]; | 
|---|
| 589 | qDebug("                size: px=%d, pt=%d, lMatch=%ld", | 
|---|
| 590 | size.pixelSize, size.pointSize, | 
|---|
| 591 | size.lMatch | 
|---|
| 592 | ); | 
|---|
| 593 | } | 
|---|
| 594 | } | 
|---|
| 595 | } | 
|---|
| 596 | } | 
|---|
| 597 | #endif // QFONTDATABASE_DEBUG | 
|---|
| 598 | } | 
|---|
| 599 |  | 
|---|
| 600 |  | 
|---|
| 601 |  | 
|---|
| 602 | // -------------------------------------------------------------------------------------- | 
|---|
| 603 | // font loader | 
|---|
| 604 | // -------------------------------------------------------------------------------------- | 
|---|
| 605 |  | 
|---|
| 606 |  | 
|---|
| 607 | //@@TODO (dmik): remove | 
|---|
| 608 | //#if 0 | 
|---|
| 609 | //void QFontPrivate::initFontInfo() | 
|---|
| 610 | //{ | 
|---|
| 611 | //    lineWidth = 1; | 
|---|
| 612 | //    actual = request;                         // most settings are equal | 
|---|
| 613 | //    QT_WA( { | 
|---|
| 614 | //      TCHAR n[64]; | 
|---|
| 615 | //      GetTextFaceW( fin->dc(), 64, n ); | 
|---|
| 616 | //      actual.family = QString::fromUcs2((ushort*)n); | 
|---|
| 617 | //      actual.fixedPitch = !(fin->tm.w.tmPitchAndFamily & TMPF_FIXED_PITCH); | 
|---|
| 618 | //    } , { | 
|---|
| 619 | //      char an[64]; | 
|---|
| 620 | //      GetTextFaceA( fin->dc(), 64, an ); | 
|---|
| 621 | //      actual.family = QString::fromLocal8Bit(an); | 
|---|
| 622 | //      actual.fixedPitch = !(fin->tm.a.tmPitchAndFamily & TMPF_FIXED_PITCH); | 
|---|
| 623 | //    } ); | 
|---|
| 624 | //    if ( actual.pointSize == -1 ) { | 
|---|
| 625 | //      if ( paintdevice ) | 
|---|
| 626 | //          actual.pointSize = actual.pixelSize * 720 / QPaintDeviceMetrics( paintdevice ).logicalDpiY(); | 
|---|
| 627 | //      else { | 
|---|
| 628 | //          actual.pointSize = actual.pixelSize * 720 / GetDeviceCaps( fin->dc(), LOGPIXELSY ); | 
|---|
| 629 | //      } | 
|---|
| 630 | //    } else if ( actual.pixelSize == -1 ) { | 
|---|
| 631 | //      if ( paintdevice ) | 
|---|
| 632 | //          actual.pixelSize = actual.pointSize * QPaintDeviceMetrics( paintdevice ).logicalDpiY() / 720; | 
|---|
| 633 | //      else | 
|---|
| 634 | //          actual.pixelSize = actual.pointSize * GetDeviceCaps( fin->dc(), LOGPIXELSY ) / 720; | 
|---|
| 635 | //    } | 
|---|
| 636 | // | 
|---|
| 637 | //    actual.dirty = FALSE; | 
|---|
| 638 | //    exactMatch = ( actual.family == request.family && | 
|---|
| 639 | //                 ( request.pointSize == -1 || ( actual.pointSize == request.pointSize ) ) && | 
|---|
| 640 | //                 ( request.pixelSize == -1 || ( actual.pixelSize == request.pixelSize ) ) && | 
|---|
| 641 | //                 actual.fixedPitch == request.fixedPitch ); | 
|---|
| 642 | //} | 
|---|
| 643 | // | 
|---|
| 644 | //#endif | 
|---|
| 645 |  | 
|---|
| 646 |  | 
|---|
| 647 | //@@TODO (dmik): remove | 
|---|
| 648 | //static inline HFONT systemFont() | 
|---|
| 649 | //{ | 
|---|
| 650 | //    if ( stock_sysfont == 0 ) | 
|---|
| 651 | //      stock_sysfont = (HFONT)GetStockObject(SYSTEM_FONT); | 
|---|
| 652 | //    return stock_sysfont; | 
|---|
| 653 | //} | 
|---|
| 654 | // | 
|---|
| 655 | //#if !defined(DEFAULT_GUI_FONT) | 
|---|
| 656 | //#define DEFAULT_GUI_FONT 17 | 
|---|
| 657 | //#endif | 
|---|
| 658 |  | 
|---|
| 659 |  | 
|---|
| 660 | QFontEngine *loadEngine( | 
|---|
| 661 | QFont::Script script, const QFontPrivate *fp, const QFontDef &request, | 
|---|
| 662 | QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, | 
|---|
| 663 | QtFontSize *size | 
|---|
| 664 | ) { | 
|---|
| 665 | Q_UNUSED( script ); | 
|---|
| 666 | Q_UNUSED( request ); | 
|---|
| 667 | Q_UNUSED( family ); | 
|---|
| 668 | Q_UNUSED( foundry ); | 
|---|
| 669 |  | 
|---|
| 670 | FATTRS fa; | 
|---|
| 671 | memset( &fa, 0, sizeof(FATTRS) ); | 
|---|
| 672 |  | 
|---|
| 673 | QPaintDevice *paintdevice = fp->paintdevice; | 
|---|
| 674 |  | 
|---|
| 675 | HPS hps = 0; | 
|---|
| 676 | if ( paintdevice ) | 
|---|
| 677 | hps = paintdevice->handle(); | 
|---|
| 678 |  | 
|---|
| 679 | fa.usRecordLength = sizeof(FATTRS); | 
|---|
| 680 | strcpy( fa.szFacename, style->szFacename ); | 
|---|
| 681 | fa.lMatch = size->lMatch; | 
|---|
| 682 |  | 
|---|
| 683 | int pixelSize = size->pixelSize; | 
|---|
| 684 | int pointSize = size->pointSize; | 
|---|
| 685 | if ( pixelSize == SMOOTH_SCALABLE ) { | 
|---|
| 686 | fa.fsFontUse = FATTR_FONTUSE_OUTLINE; | 
|---|
| 687 | int dpi; | 
|---|
| 688 | if ( fp->paintdevice ) { | 
|---|
| 689 | dpi = QPaintDeviceMetrics( fp->paintdevice ).logicalDpiY(); | 
|---|
| 690 | } else { | 
|---|
| 691 | DevQueryCaps( GpiQueryDevice( qt_display_ps() ), | 
|---|
| 692 | CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi ); | 
|---|
| 693 | } | 
|---|
| 694 | if (request.pointSize) { | 
|---|
| 695 | pixelSize = (request.pointSize * dpi + 360) / 720; | 
|---|
| 696 | pointSize = request.pointSize; | 
|---|
| 697 | } else { | 
|---|
| 698 | // if pointSize is zero, then the user has specified the font size | 
|---|
| 699 | // in pixels (see QFontPrivate::load()) | 
|---|
| 700 | pixelSize = request.pixelSize; | 
|---|
| 701 | pointSize = (request.pixelSize * 720 + dpi / 2) / dpi; | 
|---|
| 702 | } | 
|---|
| 703 | } | 
|---|
| 704 |  | 
|---|
| 705 | return new QFontEnginePM( hps, &fa, pixelSize, pointSize ); | 
|---|
| 706 | } | 
|---|
| 707 |  | 
|---|
| 708 | //@@TODO (dmik): remove | 
|---|
| 709 | //static | 
|---|
| 710 | //QFontEngine *loadEngine( QFont::Script script, const QFontPrivate *fp, | 
|---|
| 711 | //                       const QFontDef &request, | 
|---|
| 712 | //                       QtFontFamily *family, QtFontFoundry *foundry, | 
|---|
| 713 | //                       QtFontStyle *style ) | 
|---|
| 714 | //{ | 
|---|
| 715 | //    Q_UNUSED( script ); | 
|---|
| 716 | //    Q_UNUSED( foundry ); | 
|---|
| 717 | //    Q_UNUSED( style ); | 
|---|
| 718 | // | 
|---|
| 719 | //    LOGFONT lf; | 
|---|
| 720 | //    memset( &lf, 0, sizeof(LOGFONT) ); | 
|---|
| 721 | // | 
|---|
| 722 | //    QPaintDevice *paintdevice = fp->paintdevice; | 
|---|
| 723 | // | 
|---|
| 724 | //    HDC hdc; | 
|---|
| 725 | //    if ( paintdevice ) { | 
|---|
| 726 | //      hdc = paintdevice->handle(); | 
|---|
| 727 | //    } else if ( qt_winver & Qt::WV_NT_based ) { | 
|---|
| 728 | //      hdc = GetDC( 0 ); | 
|---|
| 729 | //    } else { | 
|---|
| 730 | //      hdc = shared_dc; | 
|---|
| 731 | //    } | 
|---|
| 732 | // | 
|---|
| 733 | //    bool stockFont = FALSE; | 
|---|
| 734 | // | 
|---|
| 735 | //    HFONT hfont = 0; | 
|---|
| 736 | // | 
|---|
| 737 | //    if ( fp->rawMode ) {                      // will choose a stock font | 
|---|
| 738 | //      int f, deffnt; | 
|---|
| 739 | //      // ### why different? | 
|---|
| 740 | //      if ( (qt_winver & Qt::WV_NT_based) || qt_winver == Qt::WV_32s ) | 
|---|
| 741 | //          deffnt = SYSTEM_FONT; | 
|---|
| 742 | //      else | 
|---|
| 743 | //          deffnt = DEFAULT_GUI_FONT; | 
|---|
| 744 | //      QString fam = family->rawName.lower(); | 
|---|
| 745 | //      if ( fam == "default" ) | 
|---|
| 746 | //          f = deffnt; | 
|---|
| 747 | //      else if ( fam == "system" ) | 
|---|
| 748 | //          f = SYSTEM_FONT; | 
|---|
| 749 | //#ifndef Q_OS_TEMP | 
|---|
| 750 | //      else if ( fam == "system_fixed" ) | 
|---|
| 751 | //          f = SYSTEM_FIXED_FONT; | 
|---|
| 752 | //      else if ( fam == "ansi_fixed" ) | 
|---|
| 753 | //          f = ANSI_FIXED_FONT; | 
|---|
| 754 | //      else if ( fam == "ansi_var" ) | 
|---|
| 755 | //          f = ANSI_VAR_FONT; | 
|---|
| 756 | //      else if ( fam == "device_default" ) | 
|---|
| 757 | //          f = DEVICE_DEFAULT_FONT; | 
|---|
| 758 | //      else if ( fam == "oem_fixed" ) | 
|---|
| 759 | //          f = OEM_FIXED_FONT; | 
|---|
| 760 | //#endif | 
|---|
| 761 | //      else if ( fam[0] == '#' ) | 
|---|
| 762 | //          f = fam.right(fam.length()-1).toInt(); | 
|---|
| 763 | //      else | 
|---|
| 764 | //          f = deffnt; | 
|---|
| 765 | //      hfont = (HFONT)GetStockObject( f ); | 
|---|
| 766 | //      if ( !hfont ) { | 
|---|
| 767 | //#ifndef QT_NO_DEBUG | 
|---|
| 768 | //          qSystemWarning( "GetStockObject failed" ); | 
|---|
| 769 | //#endif | 
|---|
| 770 | //          hfont = systemFont(); | 
|---|
| 771 | //      } | 
|---|
| 772 | //      stockFont = TRUE; | 
|---|
| 773 | //    } else { | 
|---|
| 774 | // | 
|---|
| 775 | //      int hint = FF_DONTCARE; | 
|---|
| 776 | //      switch ( request.styleHint ) { | 
|---|
| 777 | //          case QFont::Helvetica: | 
|---|
| 778 | //              hint = FF_SWISS; | 
|---|
| 779 | //              break; | 
|---|
| 780 | //          case QFont::Times: | 
|---|
| 781 | //              hint = FF_ROMAN; | 
|---|
| 782 | //              break; | 
|---|
| 783 | //          case QFont::Courier: | 
|---|
| 784 | //              hint = FF_MODERN; | 
|---|
| 785 | //              break; | 
|---|
| 786 | //          case QFont::OldEnglish: | 
|---|
| 787 | //              hint = FF_DECORATIVE; | 
|---|
| 788 | //              break; | 
|---|
| 789 | //          case QFont::System: | 
|---|
| 790 | //              hint = FF_MODERN; | 
|---|
| 791 | //              break; | 
|---|
| 792 | //          default: | 
|---|
| 793 | //              break; | 
|---|
| 794 | //      } | 
|---|
| 795 | // | 
|---|
| 796 | //      lf.lfHeight = -request.pixelSize; | 
|---|
| 797 | //#ifdef Q_OS_TEMP | 
|---|
| 798 | //      lf.lfHeight             += 3; | 
|---|
| 799 | //#endif | 
|---|
| 800 | //      lf.lfWidth              = 0; | 
|---|
| 801 | //      lf.lfEscapement = 0; | 
|---|
| 802 | //      lf.lfOrientation        = 0; | 
|---|
| 803 | //      if ( style->key.weight == 50 ) | 
|---|
| 804 | //          lf.lfWeight = FW_DONTCARE; | 
|---|
| 805 | //      else | 
|---|
| 806 | //          lf.lfWeight = (style->key.weight*900)/99; | 
|---|
| 807 | //      lf.lfItalic             = (style->key.italic || style->key.oblique); | 
|---|
| 808 | //      lf.lfCharSet    = DEFAULT_CHARSET; | 
|---|
| 809 | // | 
|---|
| 810 | //      int strat = OUT_DEFAULT_PRECIS; | 
|---|
| 811 | //      if (  request.styleStrategy & QFont::PreferBitmap ) { | 
|---|
| 812 | //          strat = OUT_RASTER_PRECIS; | 
|---|
| 813 | //#ifndef Q_OS_TEMP | 
|---|
| 814 | //      } else if ( request.styleStrategy & QFont::PreferDevice ) { | 
|---|
| 815 | //          strat = OUT_DEVICE_PRECIS; | 
|---|
| 816 | //      } else if ( request.styleStrategy & QFont::PreferOutline ) { | 
|---|
| 817 | //          QT_WA( { | 
|---|
| 818 | //              strat = OUT_OUTLINE_PRECIS; | 
|---|
| 819 | //          } , { | 
|---|
| 820 | //              strat = OUT_TT_PRECIS; | 
|---|
| 821 | //          } ); | 
|---|
| 822 | //      } else if ( request.styleStrategy & QFont::ForceOutline ) { | 
|---|
| 823 | //          strat = OUT_TT_ONLY_PRECIS; | 
|---|
| 824 | //#endif | 
|---|
| 825 | //      } | 
|---|
| 826 | // | 
|---|
| 827 | //      lf.lfOutPrecision   = strat; | 
|---|
| 828 | // | 
|---|
| 829 | //      int qual = DEFAULT_QUALITY; | 
|---|
| 830 | // | 
|---|
| 831 | //      if ( request.styleStrategy & QFont::PreferMatch ) | 
|---|
| 832 | //          qual = DRAFT_QUALITY; | 
|---|
| 833 | //#ifndef Q_OS_TEMP | 
|---|
| 834 | //      else if ( request.styleStrategy & QFont::PreferQuality ) | 
|---|
| 835 | //          qual = PROOF_QUALITY; | 
|---|
| 836 | //#endif | 
|---|
| 837 | // | 
|---|
| 838 | //      if ( request.styleStrategy & QFont::PreferAntialias ) { | 
|---|
| 839 | //          if ( qt_winver >= Qt::WV_XP ) | 
|---|
| 840 | //              qual = 5; // == CLEARTYPE_QUALITY; | 
|---|
| 841 | //          else | 
|---|
| 842 | //              qual = ANTIALIASED_QUALITY; | 
|---|
| 843 | //      } else if ( request.styleStrategy & QFont::NoAntialias ) { | 
|---|
| 844 | //          qual = NONANTIALIASED_QUALITY; | 
|---|
| 845 | //      } | 
|---|
| 846 | // | 
|---|
| 847 | //      lf.lfQuality    = qual; | 
|---|
| 848 | // | 
|---|
| 849 | //      lf.lfClipPrecision  = CLIP_DEFAULT_PRECIS; | 
|---|
| 850 | //      lf.lfPitchAndFamily = DEFAULT_PITCH | hint; | 
|---|
| 851 | // | 
|---|
| 852 | //      QString fam = family->rawName; | 
|---|
| 853 | //      if ( (fam == "MS Sans Serif") && (request.italic || (-lf.lfHeight > 18 && -lf.lfHeight != 24)) ) | 
|---|
| 854 | //          fam = "Arial"; // MS Sans Serif has bearing problems in italic, and does not scale | 
|---|
| 855 | // | 
|---|
| 856 | //      QT_WA( { | 
|---|
| 857 | //          memcpy(lf.lfFaceName, fam.ucs2(), sizeof(TCHAR)*QMIN(fam.length()+1,32));  // 32 = Windows hard-coded | 
|---|
| 858 | //          hfont = CreateFontIndirect( &lf ); | 
|---|
| 859 | //      } , { | 
|---|
| 860 | //          // LOGFONTA and LOGFONTW are binary compatible | 
|---|
| 861 | //          QCString lname = fam.local8Bit(); | 
|---|
| 862 | //          memcpy(lf.lfFaceName,lname.data(), | 
|---|
| 863 | //              QMIN(lname.length()+1,32));  // 32 = Windows hard-coded | 
|---|
| 864 | //          hfont = CreateFontIndirectA( (LOGFONTA*)&lf ); | 
|---|
| 865 | //      } ); | 
|---|
| 866 | //#ifndef QT_NO_DEBUG | 
|---|
| 867 | //      if ( !hfont ) | 
|---|
| 868 | //          qSystemWarning( "CreateFontIndirect failed" ); | 
|---|
| 869 | //#endif | 
|---|
| 870 | // | 
|---|
| 871 | //      stockFont = (hfont == 0); | 
|---|
| 872 | // | 
|---|
| 873 | //      if ( hfont && request.stretch != 100 ) { | 
|---|
| 874 | //          HGDIOBJ oldObj = SelectObject( hdc, hfont ); | 
|---|
| 875 | //          BOOL res; | 
|---|
| 876 | //          int avWidth = 0; | 
|---|
| 877 | //          QT_WA( { | 
|---|
| 878 | //              TEXTMETRICW tm; | 
|---|
| 879 | //              res = GetTextMetricsW( hdc, &tm ); | 
|---|
| 880 | //              avWidth = tm.tmAveCharWidth; | 
|---|
| 881 | //          } , { | 
|---|
| 882 | //              TEXTMETRICA tm; | 
|---|
| 883 | //              res = GetTextMetricsA( hdc, &tm); | 
|---|
| 884 | //              avWidth = tm.tmAveCharWidth; | 
|---|
| 885 | //          } ); | 
|---|
| 886 | //#ifndef QT_NO_DEBUG | 
|---|
| 887 | //          if ( !res ) | 
|---|
| 888 | //              qSystemWarning( "QFontPrivate: GetTextMetrics failed" ); | 
|---|
| 889 | //#endif | 
|---|
| 890 | // | 
|---|
| 891 | //          SelectObject( hdc, oldObj ); | 
|---|
| 892 | //          DeleteObject( hfont ); | 
|---|
| 893 | // | 
|---|
| 894 | //          lf.lfWidth = avWidth * request.stretch/100; | 
|---|
| 895 | //          QT_WA( { | 
|---|
| 896 | //              hfont = CreateFontIndirect( &lf ); | 
|---|
| 897 | //          } , { | 
|---|
| 898 | //              hfont = CreateFontIndirectA( (LOGFONTA*)&lf ); | 
|---|
| 899 | //          } ); | 
|---|
| 900 | //#ifndef QT_NO_DEBUG | 
|---|
| 901 | //          if ( !hfont ) | 
|---|
| 902 | //              qSystemWarning( "CreateFontIndirect with stretch failed" ); | 
|---|
| 903 | //#endif | 
|---|
| 904 | //      } | 
|---|
| 905 | // | 
|---|
| 906 | //#ifndef Q_OS_TEMP | 
|---|
| 907 | //      if ( hfont == 0 ) { | 
|---|
| 908 | //          hfont = (HFONT)GetStockObject( ANSI_VAR_FONT ); | 
|---|
| 909 | //          stockFont = TRUE; | 
|---|
| 910 | //      } | 
|---|
| 911 | //#endif | 
|---|
| 912 | // | 
|---|
| 913 | //    } | 
|---|
| 914 | //    if( !paintdevice && (qt_winver & Qt::WV_DOS_based) ) | 
|---|
| 915 | //      hdc = 0; | 
|---|
| 916 | //    QFontEngine *fe = new QFontEngineWin( family->name, hdc, hfont, stockFont, lf ); | 
|---|
| 917 | //    if ( paintdevice ) | 
|---|
| 918 | //      fe->paintDevice = TRUE; | 
|---|
| 919 | //    return fe; | 
|---|
| 920 | //} | 
|---|