Changeset 371 for trunk


Ignore:
Timestamp:
Dec 2, 2009, 2:27:41 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Improved font handling (patch by komh):

  • Read national face names from font files instead of always taking the Latin name.
  • Use the PM_AssociateFont registry key to select a fallback font for missing glyphs (important on DBCS systems).
Location:
trunk/src/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r364 r371  
    223223                    default: f.setStretch(QFont::Unstretched); break;
    224224                }
    225                 f.setFamily(fm.szFamilyname);
     225                f.setFamily();
    226226                f.setPointSize(height);
    227227            }
  • trunk/src/gui/text/qfont_pm.cpp

    r226 r371  
    4242****************************************************************************/
    4343
     44
    4445#include "qfont.h"
    4546#include "qfont_p.h"
     
    6970        break;
    7071    case QFont::AnyStyle:
    71         if (request.fixedPitch)
     72    default:
     73        static char szFontName[FACESIZE + 1] = {0,};
     74
     75        // already queried ?
     76        if (szFontName[0] != ';') {
     77            szFontName[0] = ';';
     78            // query the associated font
     79            if (PrfQueryProfileString(HINI_USERPROFILE,
     80                                      "PM_SystemFonts", "PM_AssociateFont", 0,
     81                                      szFontName, sizeof(szFontName))) {
     82                szFontName[FACESIZE] = '\0';
     83
     84                // the format of the associated font is face_name;point_size
     85                // so remove ';' and later
     86                for (PSZ pch = szFontName; *pch; pch++)
     87                    if (*pch == ';') {
     88                        *pch = '\0';
     89                        break;
     90                    }
     91            }
     92        }
     93
     94        // is the associated font available ?
     95        if (szFontName[0] != '\0' && szFontName[0] != ';')
     96            family = szFontName;
     97        else if (request.fixedPitch)
    7298            family = "Courier";
    7399        else
     
    103129QString QFont::defaultFamily() const
    104130{
    105     return QLatin1String(qt_fontFamilyFromStyleHint(d->request));
     131    return Q(qt_fontFamilyFromStyleHint(d->request));
    106132}
    107133
  • trunk/src/gui/text/qfontdatabase_pm.cpp

    r319 r371  
    4242****************************************************************************/
    4343
     44
     45
    4446#include "qabstractfileengine.h"
    45 
    46 #include "qfontengine_pm_p.h"
    47 
    4847#include "qsettings.h"
    4948#include "qfileinfo.h"
    5049#include "qdatetime.h"
    5150#include "qhash.h"
     51
    5252
    5353#include <ft2build.h>
     
    5656#include FT_TRUETYPE_TABLES_H
    5757#include FT_LCD_FILTER_H
     58
     59
    5860
    5961QT_BEGIN_NAMESPACE
     
    119121static FontFileHash knownFontFiles;
    120122static bool knownFontFilesInitialized = false;
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
    121288
    122289static void populateDatabase(const QString& fam)
     
    270437
    271438                cached.index = idx;
    272                 cached.familyName = QString::fromLatin1(face->family_name);
     439
     440                if (!lookupFamilyName(face, cached.familyName))
     441                    cached.familyName = QString::fromLocal8Bit(face->family_name);
    273442
    274443                // familyName may contain extra spaces (at least this is true for
Note: See TracChangeset for help on using the changeset viewer.