Changeset 174 for trunk/src/kernel/qfont_pm.cpp
- Timestamp:
- Nov 6, 2007, 11:27:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel/qfont_pm.cpp
r8 r174 58 58 { 59 59 switch( styleHint ) { 60 case QFont::Times: 61 return QString::fromLatin1("Times New Roman"); 62 case QFont::Courier: 63 return QString::fromLatin1("Courier"); 64 case QFont::Decorative: 65 return QString::fromLatin1("Times New Roman"); 66 case QFont::Helvetica: 67 return QString::fromLatin1("Helvetica"); 68 case QFont::System: 69 //@@TODO (dmik): check for OS/2 ver and return the appropriate system font 70 // (i.e. "System Proportional" for ver <= Warp 3) 71 return QString::fromLatin1("WarpSans"); 72 default: 60 case QFont::Times: 61 return QString::fromLatin1( "Times New Roman" ); 62 case QFont::Courier: 63 return QString::fromLatin1( "Courier" ); 64 case QFont::Decorative: 65 return QString::fromLatin1( "Times New Roman" ); 66 case QFont::Helvetica: 67 return QString::fromLatin1( "Helvetica" ); 68 case QFont::System: { 69 #ifndef QT_PM_NO_DEFAULTFONT_OVERRIDE 70 static ULONG ver[2] = {0}; 71 if ( ver[0] == ver[1] == 0 ) { 72 DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR, 73 &ver, sizeof(ver) ); 74 } 75 if ( ver[0] == 20 && ver[1] >= 40 ) 76 return QString::fromLatin1( "WarpSans" ); 77 else 78 #endif 79 return QString::fromLatin1( "System Proportional" ); 80 } 81 default: 73 82 // the family to be used when no StyleHint is set (in accordance 74 83 // with the font matching algorithm stated in QFont docs) 75 return QString::fromLatin1( "Helvetica");84 return QString::fromLatin1( "Helvetica" ); 76 85 } 77 86 //@@TODO (dmik): should we also add default font substitutions to … … 79 88 } 80 89 81 //@@TODO (dmik): remove82 //extern HDC shared_dc; // common dc for all fonts83 84 //@@TODO (dmik): remove?85 //// ### maybe move to qapplication_win86 //QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)87 //{88 // QString family = QT_WA_INLINE( QString::fromUcs2((ushort*)lf.lfFaceName),89 // QString::fromLocal8Bit((char*)lf.lfFaceName) );90 // QFont qf(family);91 // qf.setItalic(lf.lfItalic);92 // if (lf.lfWeight != FW_DONTCARE) {93 // int weight;94 // if ( lf.lfWeight < 400 )95 // weight = QFont::Light;96 // else if ( lf.lfWeight < 600 )97 // weight = QFont::Normal;98 // else if ( lf.lfWeight < 700 )99 // weight = QFont::DemiBold;100 // else if ( lf.lfWeight < 800 )101 // weight = QFont::Bold;102 // else103 // weight = QFont::Black;104 // qf.setWeight(weight);105 // }106 // int lfh = QABS( lf.lfHeight );107 // Q_ASSERT(shared_dc);108 // qf.setPointSizeFloat( lfh * 72.0 / GetDeviceCaps(shared_dc,LOGPIXELSY) );109 // qf.setUnderline(FALSE);110 // qf.setOverline(FALSE);111 // qf.setStrikeOut(FALSE);112 // return qf;113 //}114 115 116 //@@TODO (dmik): need these two funcs?117 //static inline float pixelSize( const QFontDef &request, QPaintDevice *paintdevice,118 // int )119 //{120 // float pSize;121 // if ( request.pointSize != -1 ) {122 // if ( paintdevice ) {123 // pSize = request.pointSize *124 // QPaintDeviceMetrics( paintdevice ).logicalDpiY() / 720.;125 // } else {126 // LONG dpi;127 // DevQueryCaps( GpiQueryDevice( qt_display_ps() ),128 // CAPS_VERTICAL_FONT_RES, 1, &val );129 // pSize = (request.pointSize*dpi + 360) / 720;130 // }131 // } else {132 // pSize = request.pixelSize;133 // }134 // return pSize;135 //}136 //137 //static inline float pointSize( const QFontDef &fd, QPaintDevice *paintdevice,138 // int )139 //{140 // float pSize;141 // if ( fd.pointSize == -1 ) {142 // if ( paintdevice ) {143 // pSize = fd.pixelSize * 720. /144 // QPaintDeviceMetrics( paintdevice ).logicalDpiY();145 // } else {146 // LONG dpi;147 // DevQueryCaps( GpiQueryDevice( qt_display_ps() ),148 // CAPS_VERTICAL_FONT_RES, 1, &val );149 // pSize = fd.pixelSize * 72.0 / dpi;150 // }151 // } else {152 // pSize = fd.pointSize;153 // }154 // return pSize;155 //}156 157 90 /***************************************************************************** 158 91 QFont member functions … … 165 98 if ( QFontCache::instance ) 166 99 return; 167 //@@TODO (dmik): remove168 // shared_dc = CreateCompatibleDC( qt_display_dc() );169 //#if defined(QT_CHECK_RANGE)170 // if ( !shared_dc )171 // qSystemWarning( "QFont::initialize() (qfont_win.cpp, 163): couldn't create device context" );172 //#endif173 100 new QFontCache(); 174 101 … … 180 107 { 181 108 delete QFontCache::instance; 182 //@@TODO (dmik): remove183 // DeleteDC( shared_dc );184 // shared_dc = 0;185 109 } 186 110 … … 194 118 // sanity checks 195 119 if (!QFontCache::instance) 196 120 qWarning("Must construct a QApplication before a QFont"); 197 121 Q_ASSERT( script >= 0 && script < QFont::LastPrivateScript ); 198 122 #endif // QT_CHECK_STATE … … 204 128 } else { 205 129 DevQueryCaps( GpiQueryDevice( qt_display_ps() ), 206 CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi );130 CAPS_VERTICAL_FONT_RES, 1, (PLONG) &dpi ); 207 131 } 208 132 if (req.pointSize != -1) … … 212 136 213 137 if ( ! engineData ) { 214 215 216 217 218 219 220 221 222 223 224 225 138 QFontCache::Key key( req, QFont::NoScript, (int)paintdevice ); 139 140 // look for the requested font in the engine data cache 141 engineData = QFontCache::instance->findEngineData( key ); 142 143 if ( ! engineData) { 144 // create a new one 145 engineData = new QFontEngineData; 146 QFontCache::instance->insertEngineData( key, engineData ); 147 } else { 148 engineData->ref(); 149 } 226 150 } 227 151 … … 239 163 240 164 if (!req.family.isEmpty()) { 241 242 243 244 245 246 247 248 165 family_list = QStringList::split( ',', req.family ); 166 167 // append the substitute list for each family in family_list 168 QStringList subs_list; 169 QStringList::ConstIterator it = family_list.begin(), end = family_list.end(); 170 for ( ; it != end; ++it ) 171 subs_list += QFont::substitutes( *it ); 172 family_list += subs_list; 249 173 250 174 //@@TODO (dmik): need something here? 251 252 175 // append the default fallback font for the specified script 176 // family_list << ... ; ########### 253 177 254 178 // add the family corresponding to font's styleHint 255 179 QString hintFamily = qt_pm_default_family( request.styleHint ); 256 180 if ( ! family_list.contains( hintFamily ) ) 257 181 family_list << hintFamily; 258 182 … … 262 186 // below added to the list. 263 187 264 265 266 267 268 269 270 271 188 // add the default family 189 QString defaultFamily = QApplication::font().family(); 190 if ( ! family_list.contains( defaultFamily ) ) 191 family_list << defaultFamily; 192 193 // add QFont::defaultFamily() to the list, for compatibility with 194 // previous versions 195 family_list << QApplication::font().defaultFamily(); 272 196 } 273 197 … … 277 201 QStringList::ConstIterator it = family_list.begin(), end = family_list.end(); 278 202 for ( ; ! engine && it != end; ++it ) { 279 280 281 282 283 284 285 286 287 288 289 290 203 req.family = *it; 204 205 engine = QFontDatabase::findFont( script, this, req ); 206 if ( engine ) { 207 if ( engine->type() != QFontEngine::Box ) 208 break; 209 210 if ( ! req.family.isEmpty() ) 211 engine = 0; 212 213 continue; 214 } 291 215 } 292 216 … … 343 267 QString QFont::lastResortFont() const 344 268 { 345 return QString::fromLatin1( "System Proportional");269 return QString::fromLatin1( "System Proportional" ); 346 270 } 347 271 … … 351 275 QFontMetrics member functions 352 276 *****************************************************************************/ 353 354 //@@TODO (dmik): remove355 //#define IS_TRUETYPE (QT_WA_INLINE( engine->tm.w.tmPitchAndFamily, engine->tm.a.tmPitchAndFamily ) & TMPF_TRUETYPE)356 //#define TMX engine->tm.w357 //#define TMW engine->tm.w358 //#define TMA engine->tm.a359 277 360 278 //@@TODO (dmik): do we need a separate (other than in qfont.cpp)
Note:
See TracChangeset
for help on using the changeset viewer.