42 #include <qplatformdefs.h> 48 #include <private/qt_x11_p.h> 59 #include <sys/types.h> 64 #include <private/qfontengine_x11_p.h> 66 #ifndef QT_NO_FONTCONFIG 68 #include FT_FREETYPE_H 70 #if FC_VERSION >= 20402 71 #include <fontconfig/fcfreetype.h> 103 #define make_tag( c1, c2, c3, c4 ) \ 104 ((((unsigned int)c1)<<24) | (((unsigned int)c2)<<16) | \ 105 (((unsigned int)c3)<<8) | ((unsigned int)c4)) 116 {
"iso8859-1", 0, 4,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'1') },
117 {
"iso8859-2", 1, 5,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'2') },
118 {
"iso8859-3", 2, 6,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'3') },
119 {
"iso8859-4", 3, 7,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'4') },
120 {
"iso8859-9", 4, 12,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'9') },
121 {
"iso8859-10", 5, 13,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'9',
'-',
'1',
'0') },
122 {
"iso8859-13", 6, 109,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'9',
'-',
'1',
'3') },
123 {
"iso8859-14", 7, 110,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'9',
'-',
'1',
'4') },
124 {
"iso8859-15", 8, 111,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'9',
'-',
'1',
'5') },
125 {
"hp-roman8", 9, 2004,
make_tag(
'h',
'p',
'-',
'r'),
make_tag(
'm',
'a',
'n',
'8') },
126 {
"iso8859-5", 10, 8,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'5') },
127 {
"*-cp1251", 11, 2251, 0,
make_tag(
'1',
'2',
'5',
'1') },
128 {
"koi8-ru", 12, 2084,
make_tag(
'k',
'o',
'i',
'8'),
make_tag(
'8',
'-',
'r',
'u') },
129 {
"koi8-u", 13, 2088,
make_tag(
'k',
'o',
'i',
'8'),
make_tag(
'i',
'8',
'-',
'u') },
130 {
"koi8-r", 14, 2084,
make_tag(
'k',
'o',
'i',
'8'),
make_tag(
'i',
'8',
'-',
'r') },
131 {
"iso8859-7", 15, 10,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'7') },
132 {
"iso8859-8", 16, 85,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'5',
'9',
'-',
'8') },
133 {
"gb18030-0", 17, -114,
make_tag(
'g',
'b',
'1',
'8'),
make_tag(
'3',
'0',
'-',
'0') },
134 {
"gb18030.2000-0", 18, -113,
make_tag(
'g',
'b',
'1',
'8'),
make_tag(
'0',
'0',
'-',
'0') },
135 {
"gbk-0", 19, -113,
make_tag(
'g',
'b',
'k',
'-'),
make_tag(
'b',
'k',
'-',
'0') },
136 {
"gb2312.*-0", 20, 57,
make_tag(
'g',
'b',
'2',
'3'), 0 },
137 {
"jisx0201*-0", 21, 15,
make_tag(
'j',
'i',
's',
'x'), 0 },
138 {
"jisx0208*-0", 22, 63,
make_tag(
'j',
'i',
's',
'x'), 0 },
139 {
"ksc5601*-*", 23, 36,
make_tag(
'k',
's',
'c',
'5'), 0 },
140 {
"big5hkscs-0", 24, -2101,
make_tag(
'b',
'i',
'g',
'5'),
make_tag(
'c',
's',
'-',
'0') },
141 {
"hkscs-1", 25, -2101,
make_tag(
'h',
'k',
's',
'c'),
make_tag(
'c',
's',
'-',
'1') },
142 {
"big5*-*", 26, -2026,
make_tag(
'b',
'i',
'g',
'5'), 0 },
143 {
"tscii-*", 27, 2028,
make_tag(
't',
's',
'c',
'i'), 0 },
144 {
"tis620*-*", 28, 2259,
make_tag(
't',
'i',
's',
'6'), 0 },
145 {
"iso8859-11", 29, 2259,
make_tag(
'i',
's',
'o',
'8'),
make_tag(
'9',
'-',
'1',
'1') },
146 {
"mulelao-1", 30, -4242,
make_tag(
'm',
'u',
'l',
'e'),
make_tag(
'a',
'o',
'-',
'1') },
147 {
"ethiopic-unicode", 31, 0,
make_tag(
'e',
't',
'h',
'i'),
make_tag(
'c',
'o',
'd',
'e') },
148 {
"iso10646-1", 32, 0,
make_tag(
'i',
's',
'o',
'1'),
make_tag(
'4',
'6',
'-',
'1') },
149 {
"unicode-*", 33, 0,
make_tag(
'u',
'n',
'i',
'c'), 0 },
150 {
"*-symbol", 34, 0, 0,
make_tag(
'm',
'b',
'o',
'l') },
151 {
"*-fontspecific", 35, 0, 0,
make_tag(
'i',
'f',
'i',
'c') },
152 {
"fontspecific-*", 36, 0,
make_tag(
'f',
'o',
'n',
't'), 0 },
158 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
183 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
188 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190 0, 0, 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,
295 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
298 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
299 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
303 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
304 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
305 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
308 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
309 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
310 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
313 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
315 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
318 { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
319 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
320 1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
323 { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
324 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
325 1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
328 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
329 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
330 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
333 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
334 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
338 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
353 int len = strlen(encoding);
356 unsigned int hash1 =
make_tag(encoding[0], encoding[1], encoding[2], encoding[3]);
357 const char *ch = encoding + len - 4;
361 for (; enc->
name; ++enc) {
367 const char *n = enc->
name;
368 const char *e = encoding;
386 while (*e && *e != *n)
397 if (
id != -1)
return xlfd_encoding[
id].
mib;
404 for (; enc->
name; ++enc) {
417 return xlfd_encoding[
id].
name;
441 if (! fontName || fontName[0] ==
'0' || fontName[0] !=
'-') {
448 for (i = 0; i <
NFontFields && fontName && fontName[0]; ++i) {
449 tokens[i] = fontName;
450 for (;; ++fontName) {
451 if (*fontName ==
'-')
459 if (fontName) *fontName++ =
'\0';
473 return (x[0] ==
'0' && x[1] == 0);
491 return (tokens[
Spacing][0] ==
'm' ||
528 char slant = tolower((
uchar) tokens[
Slant][0]);
531 fd->
fixedPitch = (fixed ==
'm' || fixed ==
'c');
558 if (!fs || !XGetFontProperty(fs, XA_FONT, &value))
573 char slant0 = tolower((
uchar) tokens[
Slant][0]);
576 if (tokens[Slant][1]) {
577 char slant1 = tolower((
uchar) tokens[Slant][1]);
581 else if (slant1 ==
'i')
584 }
else if (slant0 ==
'o')
586 else if (slant0 ==
'i')
593 }
else if (
qstrcmp(tokens[Width],
"semi condensed") == 0 ||
594 qstrcmp(tokens[Width],
"semicondensed") == 0) {
596 }
else if (
qstrcmp(tokens[Width],
"condensed") == 0) {
598 }
else if (
qstrcmp(tokens[Width],
"narrow") == 0) {
609 static void loadXlfds(
const char *reqFamily,
int encoding_id)
615 if ((encoding_id == -1 && xlfdsFullyLoaded)
616 || (encoding_id != -1 && encodingLoaded[encoding_id]))
624 xlfd_pattern += (reqFamily && reqFamily[0] !=
'\0') ? reqFamily :
"*";
625 xlfd_pattern +=
"-*-*-*-*-*-*-*-*-*-*-";
636 for(
int i = 0 ; i < fontCount ; i++) {
645 if (encoding_id == -1)
648 char *familyName = tokens[
Family];
650 char *foundryName = tokens[
Foundry];
654 bool smooth_scalable =
false;
655 bool bitmap_scalable =
false;
658 smooth_scalable =
true;
660 bitmap_scalable =
true;
669 if (avgwidth == 0 && pixelSize != 0) {
690 if (smooth_scalable) {
702 size->
encodingID(encoding_id, xpointSize, xres, yres, avgwidth,
true);
713 if (encoding_id == -1)
714 xlfdsFullyLoaded =
true;
716 encodingLoaded[encoding_id] =
true;
719 XFreeFontNames(fontList);
723 #ifndef QT_NO_FONTCONFIG 726 #define FC_WIDTH "width" 732 if (fc_weight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2)
734 else if (fc_weight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2)
736 else if (fc_weight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2)
738 else if (fc_weight <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2)
751 if (FcPatternGetString(pattern, FC_FAMILY, 0, &value) == FcResultMatch) {
756 if (FcPatternGetDouble(pattern, FC_DPI, 0, &dpi) != FcResultMatch) {
764 if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
776 if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) != FcResultMatch)
777 weight = FC_WEIGHT_MEDIUM;
781 if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant) != FcResultMatch)
782 slant = FC_SLANT_ROMAN;
783 fontDef.
style = (slant == FC_SLANT_ITALIC)
785 : ((slant == FC_SLANT_OBLIQUE)
791 if (FcPatternGetBool(pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch)
798 if (FcPatternGetInteger(pattern,
FC_WIDTH, 0, &width) == FcResultMatch)
805 if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) == FcResultMatch) {
1004 "A QApplication object needs to be constructed before FontConfig is used.");
1005 if (!
X11->has_fontconfig)
1009 "QFontDatabase",
"New scripts have been added.");
1011 "QFontDatabase",
"New scripts have been added.");
1013 "QFontDatabase",
"New writing systems have been added.");
1015 "QFontDatabase",
"New writing systems have been added.");
1017 "QFontDatabase",
"New writing systems have been added.");
1022 FcPattern *pattern = FcPatternCreate();
1023 FcDefaultSubstitute(pattern);
1025 if (FcPatternGetString(pattern, FC_LANG, 0, &lang) == FcResultMatch)
1027 FcPatternDestroy(pattern);
1034 FcChar8 *file_value;
1036 FcChar8 *foundry_value;
1037 FcChar8 *style_value;
1041 FcObjectSet *os = FcObjectSetCreate();
1042 FcPattern *pattern = FcPatternCreate();
1044 FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT,
1045 FC_SPACING, FC_FILE, FC_INDEX,
1046 FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
1048 #if FC_VERSION >= 20297 1055 FcObjectSetAdd(os, *p);
1058 fonts = FcFontList(0, pattern, os);
1059 FcObjectSetDestroy(os);
1060 FcPatternDestroy(pattern);
1063 for (
int i = 0; i < fonts->nfont; i++) {
1064 if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
1068 slant_value = FC_SLANT_ROMAN;
1069 weight_value = FC_WEIGHT_MEDIUM;
1070 spacing_value = FC_PROPORTIONAL;
1075 if (FcPatternGetInteger (fonts->fonts[i], FC_SLANT, 0, &slant_value) != FcResultMatch)
1076 slant_value = FC_SLANT_ROMAN;
1077 if (FcPatternGetInteger (fonts->fonts[i], FC_WEIGHT, 0, &weight_value) != FcResultMatch)
1078 weight_value = FC_WEIGHT_MEDIUM;
1079 if (FcPatternGetInteger (fonts->fonts[i], FC_SPACING, 0, &spacing_value) != FcResultMatch)
1080 spacing_value = FC_PROPORTIONAL;
1081 if (FcPatternGetString (fonts->fonts[i], FC_FILE, 0, &file_value) != FcResultMatch)
1083 if (FcPatternGetInteger (fonts->fonts[i], FC_INDEX, 0, &index_value) != FcResultMatch)
1085 if (FcPatternGetBool(fonts->fonts[i], FC_SCALABLE, 0, &scalable) != FcResultMatch)
1087 if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch)
1089 if (FcPatternGetString(fonts->fonts[i], FC_STYLE, 0, &style_value) != FcResultMatch)
1093 FcLangSet *langset = 0;
1094 FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset);
1095 if (res == FcResultMatch) {
1097 const FcChar8 *lang = (
const FcChar8*) languageForWritingSystem[i];
1101 FcLangResult langRes = FcLangSetHasLang(langset, lang);
1102 if (langRes != FcLangDifferentLang)
1120 res = FcPatternGetCharSet(fonts->fonts[i], FC_CHARSET, 0, &cs);
1121 if (res == FcResultMatch) {
1125 if (!sampleCharForWritingSystem[i])
1127 if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i]))
1132 #if FC_VERSION >= 20297 1136 res = FcPatternGetString (fonts->fonts[i], FC_CAPABILITY, 0, &cap);
1137 if (res != FcResultMatch || !strstr((
const char *)cap, openType[j]))
1149 styleKey.
style = (slant_value == FC_SLANT_ITALIC)
1151 : ((slant_value == FC_SLANT_OBLIQUE)
1157 FcPatternGetInteger (fonts->fonts[i],
FC_WIDTH, 0, &width);
1162 = family->
foundry(foundry_value ? QString::fromUtf8((
const char *)foundry_value) :
QString(),
true);
1165 if (spacing_value < FC_MONO)
1173 double pixel_size = 0;
1174 FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size);
1175 size = style->
pixelSize((
int)pixel_size,
true);
1178 enc->
pitch = (spacing_value >= FC_CHARCELL ?
'c' :
1179 (spacing_value >= FC_MONO ?
'm' :
'p'));
1182 FcFontSetDestroy (fonts);
1184 struct FcDefaultFont {
1186 const char *rawname;
1189 const FcDefaultFont defaults[] = {
1190 {
"Serif",
"serif",
false },
1191 {
"Sans Serif",
"sans-serif",
false },
1192 {
"Monospace",
"monospace",
true },
1195 const FcDefaultFont *f = defaults;
1212 for (
int i = 0; i < 4; ++i) {
1219 enc->
pitch = (f->fixed ?
'm' :
'p');
1224 #endif // QT_NO_FONTCONFIG 1230 if (
X11->has_fontconfig && !forceXLFD) {
1235 #ifdef QFONTDATABASE_DEBUG 1240 if (family.isNull() &&
script == -1) {
1243 if (family.isNull()) {
1262 #ifdef QFONTDATABASE_DEBUG 1263 FD_DEBUG(
"QFontDatabase: load(%s, %d) took %d ms",
1280 qWarning(
"checkSymbolFonts: Couldn't open face %s (%s/%d)",
1284 for (
int i = 0; i < f->
face->num_charmaps; ++i) {
1285 FT_CharMap cm = f->
face->charmaps[i];
1286 if (cm->encoding == FT_ENCODING_ADOBE_CUSTOM
1287 || cm->encoding == FT_ENCODING_MS_SYMBOL) {
1299 #ifndef QT_NO_FONTCONFIG 1302 if (family.isEmpty()) {
1303 for (
int i = 0; i < d->
count; ++i)
1316 if (!db || db->
count)
1322 #ifndef QT_NO_FONTCONFIG 1332 FD_DEBUG(
"QFontDatabase: loaded FontConfig: %d ms",
int(t.
elapsed()));
1337 #ifndef QT_NO_FONTCONFIG 1338 for (
int i = 0; i < db->
count; i++) {
1341 for (
int k = 0; k < foundry->
count; ++k) {
1346 if (! size)
continue;
1348 if (! enc)
continue;
1355 if (equiv)
continue;
1359 equiv = foundry->
style(key);
1360 if (equiv)
continue;
1378 #ifdef QFONTDATABASE_DEBUG 1379 #ifndef QT_NO_FONTCONFIG 1380 if (!
X11->has_fontconfig)
1386 for (
int f = 0; f < db->
count; f++) {
1395 "Unsupported" :
"Unknown"));
1398 for (
int fd = 0; fd < family->
count; fd++) {
1401 for (
int s = 0; s < foundry->
count; s++) {
1403 FD_DEBUG(
"\t\t\tstyle: style=%d weight=%d (%s)\n" 1404 "\t\t\tstretch=%d (%s)",
1409 FD_DEBUG(
"\t\t\t\tsmooth scalable");
1411 FD_DEBUG(
"\t\t\t\tbitmap scalable");
1414 for (
int z = 0; z < style->
count; ++z) {
1416 for (
int e = 0; e < size->
count; ++e) {
1417 FD_DEBUG(
"\t\t\t\t size %5d pitch %c encoding %s",
1427 #endif // QFONTDATABASE_DEBUG 1437 const char *stylehint = 0;
1440 stylehint =
"sans-serif";
1443 stylehint =
"serif";
1446 stylehint =
"monospace";
1450 stylehint =
"monospace";
1456 #ifndef QT_NO_FONTCONFIG 1461 FcPatternDel(pattern, FC_PIXEL_SIZE);
1462 FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
1465 FcPatternDel(pattern, FC_ANTIALIAS);
1467 FcPatternAddBool(pattern, FC_ANTIALIAS,
false);
1469 FcPatternDel(pattern, FC_ANTIALIAS);
1470 FcPatternAddBool(pattern, FC_ANTIALIAS,
1476 FcLangSet *ls = FcLangSetCreate();
1477 FcLangSetAdd(ls, (
const FcChar8*)specialLanguages[script]);
1478 FcPatternDel(pattern, FC_LANG);
1479 FcPatternAddLangSet(pattern, FC_LANG, ls);
1480 FcLangSetDestroy(ls);
1485 FcPatternAddString(pattern, FC_STYLE, (
const FcChar8 *) cs.
constData());
1489 int weight_value = FC_WEIGHT_BLACK;
1491 weight_value = FC_WEIGHT_MEDIUM;
1493 weight_value = FC_WEIGHT_LIGHT;
1495 weight_value = FC_WEIGHT_MEDIUM;
1497 weight_value = FC_WEIGHT_DEMIBOLD;
1499 weight_value = FC_WEIGHT_BOLD;
1500 FcPatternDel(pattern, FC_WEIGHT);
1501 FcPatternAddInteger(pattern, FC_WEIGHT, weight_value);
1503 int slant_value = FC_SLANT_ROMAN;
1505 slant_value = FC_SLANT_ITALIC;
1507 slant_value = FC_SLANT_OBLIQUE;
1508 FcPatternDel(pattern, FC_SLANT);
1509 FcPatternAddInteger(pattern, FC_SLANT, slant_value);
1511 int stretch = request.
stretch;
1515 FcPatternAddInteger(pattern,
FC_WIDTH, stretch);
1526 if (!
X11->has_fontconfig)
1529 FcPattern *pattern = FcPatternCreate();
1534 value.type = FcTypeString;
1538 for (
int i = 0; i < families_and_foundries.
size(); ++i) {
1543 value.u.s = (
const FcChar8 *)cs.
data();
1544 FcPatternAdd(pattern, FC_FAMILY, value, FcTrue);
1548 if (!foundry.isEmpty()) {
1550 value.u.s = (
const FcChar8 *)cs.
data();
1551 FcPatternAddWeak(pattern, FC_FOUNDRY, value, FcTrue);
1556 const char *stylehint =
styleHint(request);
1558 value.u.s = (
const FcChar8 *)stylehint;
1559 FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
1563 char pitch_value = FC_PROPORTIONAL;
1565 pitch_value = FC_MONO;
1566 FcPatternAddInteger(pattern, FC_SPACING, pitch_value);
1570 FcPatternAddBool(pattern, FC_SCALABLE,
true);
1574 FcConfigSubstitute(0, pattern, FcMatchPattern);
1575 FcDefaultSubstitute(pattern);
1583 value.u.s = (
const FcChar8 *)cs.
data();
1584 FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
1590 value.u.s = (
const FcChar8 *)cs.
data();
1591 FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
1596 cs = defaultFamily.
toUtf8();
1597 value.u.s = (
const FcChar8 *)cs.
data();
1598 FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
1607 FcPatternDestroy(fs->fonts[at]);
1608 int len = (--fs->nfont -
at) *
sizeof(FcPattern *);;
1610 memmove(fs->fonts + at, fs->fonts + at + 1, len);
1616 #ifdef FONT_MATCH_DEBUG 1618 FcPatternGetString(match, FC_FAMILY, 0, &fam);
1629 if (specialChars[script]) {
1632 if (FcPatternGetCharSet(match, FC_CHARSET, 0, &cs) != FcResultMatch)
1634 if (!FcCharSetHasChar(cs, specialChars[script]))
1636 }
else if (*specialLanguages[script] !=
'\0'){
1637 FcLangSet *langSet = 0;
1638 if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
1640 if (FcLangSetHasLang(langSet, (
const FcChar8*)specialLanguages[script]) != FcLangEqual)
1647 FcPatternDel(match, FC_ANTIALIAS);
1648 FcPatternAddBool(match, FC_ANTIALIAS,
false);
1658 if (!hbFace || !hbFace->supported_scripts[script]) {
1659 FM_DEBUG(
" OpenType support missing for script\n");
1671 FcFontSet *fs = FcFontSort(0, pattern, FcTrue, 0, &result);
1672 #ifdef FONT_MATCH_DEBUG 1673 FM_DEBUG(
"first font in fontset:\n");
1674 FcPatternPrint(fs->fonts[0]);
1680 if (forceScalable && fs) {
1681 for (
int i = 0; i < fs->nfont; ++i) {
1682 FcPattern *font = fs->fonts[i];
1685 res = FcPatternGetBool(font, FC_SCALABLE, 0, &scalable);
1686 if (res != FcResultMatch || !scalable) {
1688 #ifdef FONT_MATCH_DEBUG 1690 FcPatternPrint(font);
1697 FM_DEBUG(
"final pattern contains %d fonts\n", fs->nfont);
1705 FcPattern *pattern =
getFcPattern(fp, script, request);
1707 #ifdef FONT_MATCH_DEBUG 1708 FM_DEBUG(
"\n\nfinal FcPattern contains:\n");
1709 FcPatternPrint(pattern);
1714 FcPattern *
match = FcFontMatch(0, pattern, &res);
1720 FcPatternDestroy(match);
1725 for (
int i = 0; !fe && i < fs->nfont; ++i) {
1726 match = FcFontRenderPrepare(NULL, pattern, fs->fonts[i]);
1730 FcPatternDestroy(match);
1733 FcFontSetDestroy(fs);
1742 FcPatternDestroy(pattern);
1745 FcPatternDestroy(match);
1751 #if FC_VERSION < 20402 1753 return FcFreeTypeQuery(file,
id, blanks, count);
1756 return FcFreeTypeQuery(file,
id, blanks, count);
1761 FcPattern *pattern = 0;
1764 if (!FT_New_Memory_Face(lib, (
const FT_Byte *)data.
constData(), data.
size(),
id, &face)) {
1765 *count = face->num_faces;
1767 pattern = FcFreeTypeQueryFace(face, file,
id, blanks);
1775 #endif // QT_NO_FONTCONFIG 1804 const char *stylehint =
styleHint(request);
1807 families_and_foundries <<
QString();
1808 FM_DEBUG() <<
"loadXlfd: list is" << families_and_foundries;
1809 for (
int i = 0; i < families_and_foundries.
size(); ++i) {
1810 QString family, foundry;
1812 FM_DEBUG(
"loadXlfd: >>>>>>>>>>>>>>trying to match '%s' encoding=%d", family.
toLatin1().
data(), force_encoding_id);
1819 if (force_encoding_id != -1
1866 initFontDef(desc, request, &fe->
fontDef);
1883 for (
int i = 0; i < desc.
size->
count; ++i) {
1892 for (; enc->
name; ++enc) {
1898 #if defined(FONT_MATCH_DEBUG) 1899 FM_DEBUG(
" using MultiXLFD, encodings:");
1900 for (
int i = 0; i < encodings.
size(); ++i) {
1901 const int id = encodings.
at(i);
1902 FM_DEBUG(
" %2d: %s", xlfd_encoding[
id].
id, xlfd_encoding[
id].
name);
1911 #if (defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6)) && defined(Q_CC_GNU) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3) 1912 #define NEEDS_GCC_BUG_WORKAROUND 1915 #ifdef NEEDS_GCC_BUG_WORKAROUND 1916 static inline void gccBugWorkaround(
const QFontDef &req)
1919 snprintf(buffer, 8,
"%f", req.
pixelSize);
1941 #ifdef NEEDS_GCC_BUG_WORKAROUND 1943 gccBugWorkaround(req);
1968 if (!privateDb()->count)
1978 #ifndef QT_NO_FONTCONFIG 1979 }
else if (
X11->has_fontconfig) {
1980 fe =
loadFc(d, script, req);
1983 fe = loadXlfd(d->
screen, script, req);
2005 #ifndef FC_FAMILYLANG 2006 #define FC_FAMILYLANG "familylang" 2011 #if defined(QT_NO_FONTCONFIG) 2014 if (!
X11->has_fontconfig)
2017 FcConfig *config = FcConfigGetCurrent();
2021 FcFontSet *
set = FcConfigGetFonts(config, FcSetApplication);
2023 FcConfigAppFontAddFile(config, (
const FcChar8 *)
":/non-existent");
2024 set = FcConfigGetFonts(config, FcSetApplication);
2030 #if FC_VERSION < 20402 2043 FcBlanks *blanks = FcConfigGetBlanks(0);
2049 FcPattern *pattern = 0;
2052 fnt->
data,
id, blanks, &count);
2056 FcPatternDel(pattern, FC_FILE);
2058 FcPatternAddString(pattern, FC_FILE, (
const FcChar8 *) cs.
constData());
2060 FcChar8 *fam = 0, *familylang = 0;
2062 for (i = 0; ; i++) {
2063 if (FcPatternGetString(pattern,
FC_FAMILYLANG, i, &familylang) != FcResultMatch)
2072 if (FcPatternGetString(pattern, FC_FAMILY, n, &fam) == FcResultMatch) {
2077 if (!FcFontSetAdd(
set, pattern))
2081 }
while (pattern &&
id < count);
2089 #if defined(QT_NO_FONTCONFIG) 2098 FcConfigAppFontClear(0);
2110 #if defined(QT_NO_FONTCONFIG) 2119 FcConfigAppFontClear(0);
2128 #if defined(QT_NO_FONTCONFIG) 2131 return X11->has_fontconfig;
2137 #if defined(QT_NO_FONTCONFIG) 2140 FcPattern *pattern = FcPatternCreate();
2145 FcPatternAddString(pattern, FC_FAMILY, (
const FcChar8 *) cs.
constData());
2146 FcConfigSubstitute(0, pattern, FcMatchPattern);
2147 FcDefaultSubstitute(pattern);
2149 FcChar8 *familyAfterSubstitution;
2150 FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution);
2152 FcPatternDestroy(pattern);
static const char * openType[]
static QFreetypeFace * getFace(const QFontEngine::FaceId &face_id, const QByteArray &fontData=QByteArray())
static bool removeAllApplicationFonts()
Removes all application-local fonts previously added using addApplicationFont() and addApplicationFon...
static bool xlfdsFullyLoaded
static void loadFontConfig()
#define QT_END_NAMESPACE
This macro expands to.
Q_CORE_EXPORT QTextStream & ws(QTextStream &s)
static bool requiresOpenType(int writingSystem)
char * data()
Returns a pointer to the data stored in the byte array.
QtFontStyle * style(const QtFontStyle::Key &, const QString &=QString(), bool=false)
FcFontSet * qt_fontSetForPattern(FcPattern *pattern, const QFontDef &request)
QString qt_fallback_font_family(int script)
double qt_pointSize(double pixelSize, int dpi)
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
Q_GUI_EXPORT int qt_defaultDpiY()
QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
#define at(className, varName)
The QByteArray class provides an array of bytes.
static void initializeDb()
The QTemporaryFile class is an I/O device that operates on temporary files.
static bool isScalable(char **tokens)
void insertEngine(const Key &key, QFontEngine *engine)
static bool match(const uchar *found, const char *target, uint len)
static FcPattern * queryFont(const FcChar8 *file, const QByteArray &data, int id, FcBlanks *blanks, int *count)
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
QByteArray toLower() const
Returns a lowercase copy of the byte array.
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool ref()
Atomically increments the value of this QAtomicInt.
int qt_xlfd_encoding_id(const char *encoding)
#define make_tag(c1, c2, c3, c4)
The QString class provides a Unicode character string.
static void load(const QFontPrivate *d, int script)
Loads a QFontEngine for the specified script that matches the QFontDef request member variable...
The QElapsedTimer class provides a fast way to calculate elapsed times.
int qt_encoding_id_for_mib(int mib)
static void parseFontName(const QString &name, QString &foundry, QString &family)
This makes sense of the font family name:
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
static const char * languageForWritingSystem[]
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QFontCache * instance()
static QFont font()
Returns the default application font.
Q_CORE_EXPORT QTextStream & fixed(QTextStream &s)
Q_CORE_EXPORT void qDebug(const char *,...)
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
void append(const T &t)
Inserts value at the end of the list.
static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
struct FT_FaceRec_ * FT_Face
static void loadXlfds(const char *reqFamily, int encoding_id)
static QStringList familyList(const QFontDef &req)
QtFontEncoding * encoding
static float pixelSize(const QFontDef &request, int dpi)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static const char * xlfd_for_id(int id)
static const ushort specialChars[]
const T & at(int i) const
Returns the item at index position i in the list.
const char * setwidthName
The QStringList class provides a list of strings.
bool flush()
Flushes any buffered data to the file.
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc)
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
static bool supportsThreadedFontRendering()
Returns true if font rendering is supported outside the GUI thread, false otherwise.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static QString resolveFontFamilyAlias(const QString &family)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static int getFCWeight(int fc_weight)
static QFontEngine * tryPatternLoad(FcPattern *match, int screen, const QFontDef &request, int script)
QtFontFoundry ** foundries
static const char * styleHint(const QFontDef &request)
static void load(const QString &family=QString(), int script=-1, bool forceXLFD=false)
Style
This enum describes the different styles of glyphs that are used to display text. ...
static bool removeApplicationFont(int id)
Removes the previously loaded application font identified by id.
static bool parseXFontName(char *fontName, char **tokens)
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
static const XlfdEncoding xlfd_encoding[]
QtFontFamily * family(const QString &f, bool=false)
static QFontEngine * loadXlfd(int screen, int script, const QFontDef &request, int force_encoding_id=-1)
static int getFontWeight(const QString &weightString)
const char * constData() const
Returns a pointer to the data stored in the byte array.
static void checkSymbolFonts(const QString &family=QString())
uint qstrlen(const char *str)
#define Q_ASSERT_X(cond, where, what)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
int compare(const QString &s) const
static bool isSmoothlyScalable(char **tokens)
static bool scriptRequiresOpenType(int script)
unsigned char writingSystems[QFontDatabase::WritingSystemsCount]
QtFontSize * pixelSize(unsigned short size, bool=false)
void clear()
Clears the contents of the string and makes it empty.
Q_CORE_EXPORT char * qstrdup(const char *)
void release(const QFontEngine::FaceId &face_id)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QString family() const
Returns the requested font family name, i.e.
static void FcFontSetRemove(FcFontSet *fs, int at)
static QFontEngine * loadRaw(const QFontPrivate *fp, const QFontDef &request)
QString fileName() const
Returns the complete unique filename backing the QTemporaryFile object.
int size() const
Returns the number of items in the list.
static QtFontStyle::Key getStyle(char **tokens)
static void capitalize(char *s)
int size() const
Returns the number of bytes in this byte array.
static const QCssKnownValue properties[NumProperties - 1]
QtFontEncoding * encodingID(int id, uint xpoint=0, uint xres=0, uint yres=0, uint avgwidth=0, bool add=false)
static QString styleStringHelper(int weight, QFont::Style style)
QString defaultFamily() const
Returns the family name that corresponds to the current style hint.
static bool preferScalable(const QFontDef &request)
static void checkSymbolFont(QtFontFamily *family)
static const char * specialLanguages[]
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user's loca...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
int qstrcmp(const QByteArray &str1, const char *str2)
static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontDatabase::WritingSystemsCount]
QFontEngine * findEngine(const Key &key)
static FcPattern * getFcPattern(const QFontPrivate *fp, int script, const QFontDef &request)
FT_Library qt_getFreetype()
QtFontEncoding * encodings
static bool isZero(char *x)
static const int scriptForWritingSystem[]
QVector< ApplicationFont > applicationFonts
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
static unsigned char encodingLoaded[numEncodings]
QtFontFoundry * foundry(const QString &f, bool=false)
static QString writingSystemName(WritingSystem writingSystem)
Returns the names the writingSystem (e.g.
static QFontEngine * loadFc(const QFontPrivate *fp, int script, const QFontDef &request)
QFontEngineData * engineData
#define qPrintable(string)
void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontDef &request)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
void start()
Starts this timer.
static const ushort sampleCharForWritingSystem[]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static float pointSize(const QFontDef &fd, int dpi)
static bool isFixedPitch(char **tokens)
int qt_mib_for_xlfd_encoding(const char *encoding)
Q_DECL_CONSTEXPR int qRound(qreal d)
static Display * display()
Returns the default display for the application.
double qt_pixelSize(double pointSize, int dpi)
HB_Face harfbuzzFace() const
static int appDpiY(int screen=-1)
Returns the vertical resolution of the given screen in terms of the number of dots per inch...
bool ftWritingSystemCheck