1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
|
diff -u qt-x11-free-3.1.2/src-orig/kernel/qapplication_x11.cpp qt-x11-free-3.1.2/src/kernel/qapplication_x11.cpp
--- qt-x11-free-3.1.2/src-orig/kernel/qapplication_x11.cpp Sat Mar 8 20:37:50 2003
+++ qt-x11-free-3.1.2/src/kernel/qapplication_x11.cpp Mon Apr 21 21:28:22 2003
@@ -979,7 +979,7 @@
QString fam, skey;
QStringList::Iterator it = fontsubs.begin();
while (it != fontsubs.end()) {
- fam = (*it++).latin1();
+ fam = *it++;
skey = "/qt/Font Substitutions/" + fam;
subs = settings.readListEntry(skey);
QFont::insertSubstitutions(fam, subs);
@@ -1007,7 +1007,10 @@
xftDone = TRUE;
qt_has_xft = FALSE;
qt_use_antialiasing = FALSE;
- if (qt_use_xrender &&
+ if (
+#ifndef QT_XFT2
+ qt_use_xrender &&
+#endif // QT_XFT2
XftInit(0) && XftInitFtLibrary()) {
qt_has_xft = settings.readBoolEntry( "/qt/enableXft", TRUE );
qt_use_antialiasing = settings.readBoolEntry( "/qt/useXft", TRUE );
diff -u qt-x11-free-3.1.2/src-orig/kernel/qfont.cpp qt-x11-free-3.1.2/src/kernel/qfont.cpp
--- qt-x11-free-3.1.2/src-orig/kernel/qfont.cpp Mon Feb 24 17:30:09 2003
+++ qt-x11-free-3.1.2/src/kernel/qfont.cpp Thu Apr 17 22:51:07 2003
@@ -2951,8 +2951,13 @@
#endif //Q_WS_QWS
#ifdef Q_WS_X11
+static QFont::Script x11ProperScript( QFontPrivate *priv, const QChar &c );
+
#define SCRIPT_FOR_CHAR( script, c, priv ) \
do { \
+ script = x11ProperScript( priv, c ); \
+ if ( script != QFont::UnknownScript ) \
+ break; \
unsigned short _uc = (c).unicode(); \
if ( _uc < 0x100 ) { \
script = QFont::LatinBasic; \
diff -u qt-x11-free-3.1.2/src-orig/kernel/qfont_x11.cpp qt-x11-free-3.1.2/src/kernel/qfont_x11.cpp
--- qt-x11-free-3.1.2/src-orig/kernel/qfont_x11.cpp Mon Feb 24 17:30:15 2003
+++ qt-x11-free-3.1.2/src/kernel/qfont_x11.cpp Mon Apr 21 21:27:06 2003
@@ -1199,7 +1199,7 @@
} else {
overall->ascent = QMAX(overall->ascent, xgi->y*scale);
overall->descent = QMAX(overall->descent, (xgi->height - xgi->y)*scale);
- overall->lbearing = QMIN(overall->lbearing, -xgi->x*scale);
+ overall->lbearing = QMIN(overall->lbearing, overall->width - xgi->x*scale);
overall->rbearing = QMAX(overall->rbearing, overall->width +
(xgi->width - xgi->x)*scale);
overall->width += xgi->xOff;
@@ -1417,22 +1417,47 @@
#ifndef QT_NO_XFTFREETYPE
-static XftPattern *checkXftFont( XftPattern *match, const QString &familyName, const QChar &sample )
+static XftPattern *checkXftFont( XftPattern *match,
+ const QString &familyName, const QString &foundryName,
+ const QChar &sample, const QChar *sample2 = 0 )
{
-#ifndef QT_XFT2
- char * family_value;
- XftPatternGetString (match, XFT_FAMILY, 0, &family_value);
- QString fam = family_value;
- //qDebug("got family %s for request %s", fam.latin1(), familyName.latin1() );
+ bool mismatch = TRUE;
+ if ( familyName.isEmpty() )
+ mismatch = FALSE;
+ else
+ {
+ char * family_value;
+ XftPatternGetString (match, XFT_FAMILY, 0, &family_value);
+ QString fam = QString::fromUtf8( family_value ).lower();
+ //qDebug("got family %s foundry %s for request %s / %s",
+ // fam.local8Bit().data(), fnd.latin1(),
+ // familyName.local8Bit().data(), foundryName.latin1() );
+
+ if ( !foundryName.isNull() ) {
+ char * foundry_value;
+ QString fnd = QString::null;
+ if ( XftPatternGetString( match, XFT_FOUNDRY,
+ 0, &foundry_value ) == XftResultMatch )
+ fnd = QString( foundry_value ).lower();
+
+ if ( fnd == foundryName.lower() && fam == familyName.lower() ) {
+ mismatch = FALSE;
+ } else {
+ QString fullName = foundryName + "-" + familyName;
+
+ if ( fam == fullName.lower() )
+ mismatch = FALSE;
+ }
+ }
+ else if ( fam == familyName.lower() )
+ mismatch = FALSE;
+ }
- if ( fam.lower() != familyName.lower() ) {
+ if ( mismatch ) {
//qDebug("pattern don't match");
XftPatternDestroy(match);
match = 0;
}
-#else
- Q_UNUSED( familyName );
-#endif
if (match && sample.unicode() != 0 ) {
// check if the character is actually in the font - this does result in
@@ -1441,7 +1466,8 @@
#ifdef QT_XFT2
FcCharSet *c;
if (FcPatternGetCharSet(match, FC_CHARSET, 0, &c) == FcResultMatch) {
- if (!FcCharSetHasChar(c, sample.unicode())) {
+ if (!FcCharSetHasChar(c, sample.unicode()) &&
+ (!sample2 || !FcCharSetHasChar(c, sample2->unicode()))) {
XftPatternDestroy(match);
match = 0;
}
@@ -1452,8 +1478,11 @@
if (xftfs) {
if ( ! XftFreeTypeGlyphExists(QPaintDevice::x11AppDisplay(), xftfs,
sample.unicode())) {
- XftPatternDestroy(match);
- match = 0;
+ if (!sample2 || !XftFreeTypeGlyphExists(QPaintDevice::x11AppDisplay(),
+ xftfs, sample2->unicode())) {
+ XftPatternDestroy(match);
+ match = 0;
+ }
}
XftFreeTypeClose(QPaintDevice::x11AppDisplay(), xftfs);
@@ -1468,17 +1497,28 @@
// be found
XftPattern *QFontPrivate::findXftFont(const QChar &sample, bool *exact, double *scale) const
{
+ return findXftFont(sample, exact, scale, 0, FALSE);
+}
+
+XftPattern *QFontPrivate::findXftFont(const QChar &sample, bool *exact, double *scale,
+ const QChar *sample2, bool onlySubst) const
+{
// look for foundry/family
QString familyName;
QString foundryName;
- QFontDatabase::parseFontName(request.family, foundryName, familyName);
- XftPattern *match = bestXftPattern(familyName, foundryName, sample, scale);
+ QChar ch(0);
- if ( match )
- match = checkXftFont( match, familyName, sample );
+ XftPattern *match = 0;
+ if (!onlySubst) {
+ QFontDatabase::parseFontName(request.family, foundryName, familyName);
+ match = bestXftPattern(familyName, foundryName, ch, scale);
- *exact = TRUE;
+ if ( match )
+ match = checkXftFont( match, familyName, foundryName, sample, sample2 );
+
+ *exact = TRUE;
+ }
if (match)
return match;
@@ -1494,13 +1534,24 @@
if (request.family != familyName) {
QFontDatabase::parseFontName(familyName, foundryName, familyName);
- match = bestXftPattern(familyName, foundryName, sample, scale);
+ match = bestXftPattern(familyName, foundryName, ch, scale);
if ( match )
- match = checkXftFont( match, familyName, sample );
+ match = checkXftFont( match, familyName, foundryName, sample, sample2 );
}
}
+ if (match)
+ return match;
+
+ if (!onlySubst) {
+ QFontDatabase::parseFontName(request.family, foundryName, familyName);
+ match = bestXftPattern(familyName, foundryName, sample, scale);
+
+ if ( match )
+ match = checkXftFont( match, QString::null, QString::null, sample, sample2 );
+ }
+
return match;
}
@@ -1575,6 +1626,8 @@
XftResult res;
XftPattern *pattern = 0, *result = 0;
+ bool hasFoundry = ( !foundryName.isNull() && foundryName.lower() != "xft" );
+ QString fullName = foundryName + "-" + familyName;
pattern = XftPatternCreate();
if ( ! pattern ) return 0;
@@ -1582,10 +1635,12 @@
#ifndef QT_XFT2
XftPatternAddString (pattern, XFT_ENCODING, "iso10646-1");
#endif
- if (! foundryName.isNull())
+ if ( hasFoundry )
XftPatternAddString (pattern, XFT_FOUNDRY, foundryName.latin1());
if (! familyName.isNull())
- XftPatternAddString (pattern, XFT_FAMILY, familyName.latin1());
+ XftPatternAddString (pattern, XFT_FAMILY, familyName.utf8().data());
+ if ( hasFoundry && !familyName.isNull() )
+ XftPatternAddString( pattern, XFT_FAMILY, fullName.utf8().data() );
XftPatternAddString (pattern, XFT_FAMILY, generic_value.data());
if (mono_value >= XFT_MONO)
@@ -1618,6 +1673,32 @@
result = XftFontMatch(QPaintDevice::x11AppDisplay(),
x11Screen, pattern, &res);
+
+#ifdef QT_XFT2
+ if ( result && hasFoundry ) {
+ char *family_value;
+ XftPatternGetString( result, XFT_FAMILY, 0, &family_value );
+ QString fam = QString::fromUtf8( family_value ).lower();
+
+ if ( fam != familyName.lower() && fam != fullName.lower() ) {
+ XftPatternDel( pattern, XFT_FOUNDRY );
+ XftPattern *result2 = XftFontMatch(QPaintDevice::x11AppDisplay(),
+ x11Screen, pattern, &res);
+ if ( result2 ) {
+ XftPatternGetString( result2, XFT_FAMILY, 0, &family_value );
+ fam = QString::fromUtf8( family_value ).lower();
+
+ if ( fam == familyName.lower() || fam == fullName.lower() ) {
+ XftPatternDestroy( result );
+ result = result2;
+ } else {
+ XftPatternDestroy( result2 );
+ }
+ }
+ }
+ }
+#endif
+
XftPatternDestroy(pattern);
return result;
@@ -1646,6 +1727,7 @@
{
*scale = 1.;
QString familyName = request.family;
+ bool need_exact = *exact;
// assume exact match
*exact = TRUE;
@@ -1686,7 +1768,7 @@
if ( score < exactScore )
*exact = FALSE;
- if (! bestName.isNull())
+ if (! bestName.isNull() || need_exact)
return bestName;
// try substitution
@@ -2221,7 +2303,7 @@
else
weight_value = QFont::Normal;
- actual.family = family_value;
+ actual.family = QString::fromUtf8(family_value);
actual.weight = weight_value;
actual.italic = (slant_value != XFT_SLANT_ROMAN);
actual.fixedPitch = (spacing_value >= XFT_MONO);
@@ -2339,6 +2421,39 @@
return QFont::Han;
}
+static QFont::Script x11ProperScript( QFontPrivate *priv, const QChar &c )
+{
+ if ( QFontPrivate::defaultScript == QFont::UnknownScript )
+ return QFont::UnknownScript;
+
+ priv->load( QFontPrivate::defaultScript );
+
+#ifndef QT_NO_XFTFREETYPE
+ QFontStruct *qfs = priv->x11data.fontstruct[QFont::Unicode];
+ if ( qfs && qfs != (QFontStruct *) -1 ) {
+ if ( qfs->xfthandle ) {
+ if ( XftGlyphExists(QPaintDevice::x11AppDisplay(),
+ (XftFont *) qfs->xfthandle, c.unicode()) )
+ return QFont::Unicode;
+ else
+ return QFont::UnknownScript;
+ }
+ }
+#endif // QT_NO_XFTFREETYPE
+
+ qfs = priv->x11data.fontstruct[QFontPrivate::defaultScript];
+ if ( qfs != (QFontStruct *) -1 ) {
+ Q_ASSERT( qfs != 0 );
+ if ( !qfs->xfthandle && qfs->codec && qfs->codec->canEncode ( c ) ) {
+ XCharStruct *xcs = getCharStruct(qfs, QString(c), 0);
+ if ( ! charNonExistent(xcs) )
+ return QFontPrivate::defaultScript;
+ }
+ }
+
+ return QFont::UnknownScript;
+}
+
// Loads the font for the specified script
static inline int maxIndex(XFontStruct *f) {
@@ -2348,13 +2463,13 @@
}
// returns a sample unicode character for the specified script
-static QChar sampleCharacter(QFont::Script script)
+static QChar sampleCharacter(QFont::Script script, QChar& sample2)
{
- ushort ch;
+ ushort ch, ch2 = 0;
switch (script) {
case QFont::Latin: ch = 0x0030; break;
- case QFont::Greek: ch = 0x0390; break;
+ case QFont::Greek: ch = 0x0390; ch2 = 0x0391; break;
case QFont::Cyrillic: ch = 0x0410; break;
case QFont::Armenian: ch = 0x0540; break;
case QFont::Georgian: ch = 0x10a0; break;
@@ -2396,12 +2511,12 @@
case QFont::Mongolian: ch = 0x1800; break;
case QFont::CurrencySymbols: ch = 0x20aa; break;
- case QFont::LetterlikeSymbols: ch = 0x2122; break;
- case QFont::NumberForms: ch = 0x215b; break;
+ case QFont::LetterlikeSymbols: ch = 0x2122; ch2 = 0x2116; break;
+ case QFont::NumberForms: ch = 0x215b; ch2 = 0x2160; break;
case QFont::MathematicalOperators: ch = 0x222b; break;
- case QFont::TechnicalSymbols: ch = 0x2440; break;
+ case QFont::TechnicalSymbols: ch = 0x2440; ch2 = 0x2312; break;
case QFont::GeometricSymbols: ch = 0x2500; break;
- case QFont::MiscellaneousSymbols: ch = 0x2600; break;
+ case QFont::MiscellaneousSymbols: ch = 0x2600; ch2 = 0x2640; break;
case QFont::EnclosedAndSquare: ch = 0x2460; break;
case QFont::Braille: ch = 0x2800; break;
@@ -2411,16 +2526,26 @@
case QFont::LatinExtendedA_14: ch = 0x0174; break;
case QFont::LatinExtendedA_15: ch = 0x0152; break;
+ case QFont::KatakanaHalfWidth: ch = 0xff71; break;
+
+
default:
ch = 0;
}
+ sample2.unicode() = ch2;
+
return QChar(ch);
}
bool QFontPrivate::loadUnicode(QFont::Script script, const QChar &sample)
{
+ return loadUnicode(script, sample, 0);
+}
+
+bool QFontPrivate::loadUnicode(QFont::Script script, const QChar &sample, const QChar* sample2)
+{
bool hasChar = FALSE;
QFontStruct *qfs = x11data.fontstruct[QFont::Unicode];
@@ -2471,6 +2596,10 @@
hasChar = XftGlyphExists(QPaintDevice::x11AppDisplay(),
(XftFont *) qfs->xfthandle,
sample.unicode());
+ if (!hasChar && sample2)
+ hasChar = XftGlyphExists(QPaintDevice::x11AppDisplay(),
+ (XftFont *) qfs->xfthandle,
+ sample2->unicode());
}
#endif // QT_NO_XFTFREETYPE
@@ -2494,6 +2623,11 @@
void QFontPrivate::load(QFont::Script script, bool tryUnicode)
{
+ load(script, tryUnicode, FALSE);
+}
+
+void QFontPrivate::load(QFont::Script script, bool tryUnicode, bool onlySubstXft)
+{
// Make sure fontCache is initialized
if (! fontCache) {
#ifdef QT_CHECK_STATE
@@ -2537,12 +2671,31 @@
actual.dirty = TRUE;
}
- QChar sample = sampleCharacter(script);
+ QChar sample2;
+ QChar sample = sampleCharacter(script, sample2);
// look for a unicode font first, and see if it has the script that we want...
- if (tryUnicode && loadUnicode(script, sample)) {
+ if (tryUnicode && !onlySubstXft &&
+ loadUnicode(script, sample, (sample2.unicode() != 0)? &sample2 : 0)) {
request.dirty = FALSE;
+ if (script != QFont::Unicode && script != defaultScript) {
+ QFontStruct *qfs_uni = x11data.fontstruct[script];
+ x11data.fontstruct[script] = 0;
+ load(script, FALSE, TRUE);
+ QFontStruct *qfs = x11data.fontstruct[script];
+ if (qfs && qfs != (QFontStruct *) -1)
+ qfs_uni->deref();
+ else
+ x11data.fontstruct[script] = qfs_uni;
+ }
return;
}
+ else if (tryUnicode && !onlySubstXft && script != QFont::Unicode && script != defaultScript) {
+ QFontStruct *qfs = x11data.fontstruct[QFont::Unicode];
+ if (qfs && qfs != (QFontStruct *) -1) {
+ load(script, FALSE, TRUE);
+ return;
+ }
+ }
QFontStruct *qfs = 0;
QCString fontname;
@@ -2568,7 +2721,7 @@
// if we don't find the name in the dict, we need to find a font name
#ifdef QFONTLOADER_DEBUG_VERBOSE
- qDebug("QFontLoader: getting font name for family %s", request.family.latin1());
+ qDebug("QFontLoader: getting font name for family %s", request.family.local8Bit().data());
#endif
QString name;
@@ -2578,16 +2731,26 @@
#ifndef QT_NO_XFTFREETYPE
if (qt_has_xft && ! (request.styleStrategy & QFont::PreferBitmap) &&
! request.rawMode ) {
- xftmatch = findXftFont(sample, &match, &scale);
+ xftmatch = findXftFont(sample, &match, &scale,
+ (sample2.unicode() != 0)? &sample2 : 0, onlySubstXft);
if (xftmatch) {
- use_core = FALSE;
+ if (match)
+ use_core = FALSE;
+
+ XftPattern *pat = XftPatternDuplicate(xftmatch);
+#ifdef QT_XFT2
+ XftPatternDel(pat, FC_CHARSET);
+ XftPatternDel(pat, FC_LANG);
+ XftPatternDel(pat, FC_MATRIX);
+#endif
char fn[1024];
- XftNameUnparse(xftmatch, fn, sizeof(fn));
+ XftNameUnparse(pat, fn, sizeof(fn));
+ XftPatternDestroy(pat);
fn[1023] = '\0'; // just in case
- name = fn;
+ name = QString::fromUtf8(fn);
}
}
#endif // QT_NO_XFTFREETYPE
@@ -2602,7 +2765,18 @@
else if ( script != QFontPrivate::defaultScript )
name = QString::null;
} else {
- name = findFont(script, &match, &scale);
+ match = (xftmatch && script != QFont::Unicode);
+ QString xlfdname = findFont(script, &match, &scale);
+ // Select xft font if not exact match
+ if (!match && xftmatch && script != QFont::Unicode) {
+ match = TRUE;
+ use_core = FALSE;
+ } else {
+ if (xftmatch)
+ XftPatternDestroy(xftmatch);
+ xftmatch = 0;
+ name = xlfdname;
+ }
}
}
@@ -2617,12 +2791,12 @@
}
#ifdef QFONTLOADER_DEBUG_VERBOSE
- qDebug("QFontLoader: putting '%s' (%d) into name dict", name.latin1(),
+ qDebug("QFontLoader: putting '%s' (%d) into name dict", name.data(),
name.length());
#endif
// Put font name into fontNameDict
- qxfn = new QXFontName(name.latin1(), match, use_core);
+ qxfn = new QXFontName(name.utf8(), match, use_core);
Q_CHECK_PTR(qxfn);
fontNameDict->insert(k, qxfn);
@@ -2667,9 +2841,10 @@
if (! qxfn->useCore) {
if (! xftmatch) {
XftResult res;
- xftmatch = XftNameParse(qxfn->name.data());
+ XftPattern *pat = XftNameParse(qxfn->name.data());
xftmatch = XftFontMatch(QPaintDevice::x11AppDisplay(),
- x11Screen, xftmatch, &res);
+ x11Screen, pat, &res);
+ XftPatternDestroy(pat);
}
#ifdef QFONTLOADER_DEBUG
diff -u qt-x11-free-3.1.2/src-orig/kernel/qfontdata_p.h qt-x11-free-3.1.2/src/kernel/qfontdata_p.h
--- qt-x11-free-3.1.2/src-orig/kernel/qfontdata_p.h Mon Feb 24 17:30:10 2003
+++ qt-x11-free-3.1.2/src/kernel/qfontdata_p.h Thu Apr 17 22:51:07 2003
@@ -387,7 +387,13 @@
GC gc, const QColor &pen, Qt::BGMode, const QColor &bgcolor,
int x, int y, const TextRun *cache, int pdWidth );
bool inFont( const QChar &ch );
+private:
+ XftPattern *findXftFont(const QChar &, bool *, double *scale,
+ const QChar *sample2, bool onlySubst) const;
+ void load(QFont::Script, bool, bool onlySubstXft);
+ bool loadUnicode(QFont::Script, const QChar &, const QChar *sample2);
+public:
QFontX11Data x11data;
static QFont::Script defaultScript;
int x11Screen;
diff -u qt-x11-free-3.1.2/src-orig/kernel/qfontdatabase.cpp qt-x11-free-3.1.2/src/kernel/qfontdatabase.cpp
--- qt-x11-free-3.1.2/src-orig/kernel/qfontdatabase.cpp Mon Feb 24 17:30:13 2003
+++ qt-x11-free-3.1.2/src/kernel/qfontdatabase.cpp Thu Apr 17 22:51:07 2003
@@ -57,6 +57,15 @@
bool italic, bool lesserItalic, int weight );
#endif
+static QString qt_fontname_toLower( const QString &fontName )
+{
+#if defined( Q_WS_X11 )
+ return QString::fromUtf8( fontName.utf8().lower() );
+#else
+ return fontName.lower();
+#endif
+}
+
class QtFontStyle
{
public:
@@ -259,7 +268,7 @@
bool namesDirty;
- void addFamily( QtFontFamily *f ) { familyDict.insert( f->name().lower(), f ); }
+ void addFamily( QtFontFamily *f ) { familyDict.insert( qt_fontname_toLower(f->name()), f ); }
friend void QFontDatabase::createDatabase();
@@ -659,7 +668,7 @@
const QtFontFamily *bitmapScalable = 0;
for( ; (fndry = iter.current()) ; ++iter ) {
- fam = fndry->family( name.lower() );
+ fam = fndry->family( qt_fontname_toLower( name ) );
if ( fam ) {
if ( fam->isSmoothlyScalable() ) {
@@ -1605,7 +1614,7 @@
if ( name.contains('-') ) {
int i = name.find('-');
foundry = name.left( i ).lower();
- family = name.right( name.length() - i - 1 ).lower();
+ family = qt_fontname_toLower( name.right( name.length() - i - 1 ) );
} else if ( name.contains('[') && name.contains(']')) {
int i = name.find('[');
int li = name.findRev(']');
@@ -1614,13 +1623,11 @@
foundry = name.mid(i + 1, li - i - 1).lower();
if (name[i - 1] == ' ')
i--;
- family = name.left(i).lower();
+ family = qt_fontname_toLower( name.left(i) );
}
} else {
foundry = QString::null;
- family = name.lower();
+ family = qt_fontname_toLower( name );
}
}
-
-
#endif // QT_NO_FONTDATABASE
diff -u qt-x11-free-3.1.2/src-orig/kernel/qfontdatabase_x11.cpp qt-x11-free-3.1.2/src/kernel/qfontdatabase_x11.cpp
--- qt-x11-free-3.1.2/src-orig/kernel/qfontdatabase_x11.cpp Mon Feb 24 17:30:10 2003
+++ qt-x11-free-3.1.2/src/kernel/qfontdatabase_x11.cpp Thu Apr 17 22:51:07 2003
@@ -247,6 +247,9 @@
int spacing_value;
bool created_foundry = FALSE;
bool created_family = FALSE;
+#ifdef QT_XFT2
+ const QString style_string[3] = { "Bold", "Oblique", "Bold Oblique" };
+#endif
foundries = XftListFonts (QPaintDevice::x11AppDisplay(),
QPaintDevice::x11AppScreen(),
@@ -284,19 +287,25 @@
XftListFonts(QPaintDevice::x11AppDisplay(),
QPaintDevice::x11AppScreen(),
(const char *)0,
- XFT_FAMILY, (const char *)0);
+ XFT_FOUNDRY, XFT_FAMILY, (const char *)0);
for (int f = 0; f < families->nfont; f++) {
created_family = FALSE;
+ if (!hasFoundries)
+ if (XftPatternGetString(families->fonts[f],
+ XFT_FOUNDRY, 0, &value) == XftResultMatch)
+ continue;
+
if (XftPatternGetString(families->fonts[f],
XFT_FAMILY, 0, &value) == XftResultMatch) {
familyName = value;
+ QString fam = QString::fromUtf8(value);
QtFontFamily *family =
- foundry->familyDict.find( familyName.lower() );
+ foundry->familyDict.find( qt_fontname_toLower( fam ) );
if ( ! family ) {
- family = new QtFontFamily ( foundry, familyName.lower() );
+ family = new QtFontFamily ( foundry, fam );
Q_CHECK_PTR (family);
created_family = TRUE;
}
@@ -319,6 +328,10 @@
XFT_STYLE, XFT_WEIGHT, XFT_SLANT, XFT_SPACING,
(const char *)0);
+#ifdef QT_XFT2
+ bool styles_check[8] = { FALSE, FALSE, FALSE, FALSE,
+ FALSE, FALSE, FALSE, FALSE };
+#endif
for (int s = 0; s < styles->nfont; s++) {
if (XftPatternGetString (styles->fonts[s],
XFT_STYLE, 0, &value) ==
@@ -345,8 +358,34 @@
style->setFixedPitch();
style->setSmoothlyScalable();
family->addStyle (style);
+#ifdef QT_XFT2
+ int sty_id = ((weight_value > XFT_WEIGHT_MEDIUM)? 1 : 0) +
+ ((slant_value > XFT_SLANT_ROMAN)? 2 : 0) +
+ ((spacing_value >= XFT_MONO)? 4 : 0);
+ styles_check[sty_id] = TRUE;
+#endif
+ }
+ }
+
+#ifdef QT_XFT2
+ for (int i = 0; i <= 4; i += 4) {
+ if (!styles_check[i] && !styles_check[i + 1] && !styles_check[i + 2])
+ continue;
+ for (int j = 1; j < 4; j++) {
+ if (styles_check[i + j])
+ continue;
+ QtFontStyle *style = new QtFontStyle (family, style_string[j - 1]);
+ style->ital = (j >= 2);
+ style->lesserItal = FALSE;
+ weight_value = (j % 2)? XFT_WEIGHT_BOLD : XFT_WEIGHT_MEDIUM;
+ style->weightString = getXftWeightString(weight_value);
+ if (i > 0)
+ style->setFixedPitch();
+ style->setSmoothlyScalable();
+ family->addStyle (style);
}
}
+#endif
if ( created_family ) {
if ( created_foundry ) {
|