Changeset 561 for trunk/src/gui/text/qfontdatabase_x11.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qfontdatabase_x11.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 52 52 #include <qtemporaryfile.h> 53 53 #include <qabstractfileengine.h> 54 #include <qmath.h> 54 55 55 56 #include <ctype.h> … … 155 156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156 157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157 0 },158 0, 0 }, 158 159 // iso8859-2 159 160 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 160 161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 161 162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162 0 },163 0, 0 }, 163 164 // iso8859-3 164 165 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 165 166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166 167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167 0 },168 0, 0 }, 168 169 // iso8859-4 169 170 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 170 171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 171 172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172 0 },173 0, 0 }, 173 174 // iso8859-9 174 175 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 175 176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 176 177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177 0 },178 0, 0 }, 178 179 // iso8859-10 179 180 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 180 181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 181 182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 182 0 },183 0, 0 }, 183 184 // iso8859-13 184 185 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 185 186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186 187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 187 0 },188 0, 0 }, 188 189 // iso8859-14 189 190 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 190 191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191 192 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192 0 },193 0, 0 }, 193 194 // iso8859-15 194 195 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 195 196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196 197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 197 0 },198 0, 0 }, 198 199 // hp-roman8 199 200 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 200 201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201 202 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202 0 },203 0, 0 }, 203 204 // iso8859-5 204 205 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 205 206 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206 207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 207 0 },208 0, 0 }, 208 209 // *-cp1251 209 210 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 210 211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 211 212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212 0 },213 0, 0 }, 213 214 // koi8-ru 214 215 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 215 216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216 217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217 0 },218 0, 0 }, 218 219 // koi8-u 219 220 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 220 221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221 222 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222 0 },223 0, 0 }, 223 224 // koi8-r 224 225 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 225 226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226 227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227 0 },228 0, 0 }, 228 229 // iso8859-7 229 230 { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 230 231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 231 232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232 0 },233 0, 0 }, 233 234 // iso8859-8 234 235 { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 235 236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 236 237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 237 0 },238 0, 0 }, 238 239 // gb18030-0 239 240 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240 241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241 242 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 242 0 },243 0, 0 }, 243 244 // gb18030.2000-0 244 245 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245 246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 246 247 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 247 0 },248 0, 0 }, 248 249 // gbk-0 249 250 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250 251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251 252 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 252 0 },253 0, 0 }, 253 254 // gb2312.*-0 254 255 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 257 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 257 0 },258 0, 0 }, 258 259 // jisx0201*-0 259 260 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 260 261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 261 262 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 262 0 },263 0, 0 }, 263 264 // jisx0208*-0 264 265 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 265 266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 266 267 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 267 0 },268 0, 0 }, 268 269 // ksc5601*-* 269 270 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 270 271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 271 272 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 272 0 },273 0, 0 }, 273 274 // big5hkscs-0 274 275 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 275 276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 276 277 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 277 0 },278 0, 0 }, 278 279 // hkscs-1 279 280 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 280 281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 281 282 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 282 0 },283 0, 0 }, 283 284 // big5*-* 284 285 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285 286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 286 287 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 287 0 },288 0, 0 }, 288 289 // tscii-* 289 290 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 290 291 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 291 292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 292 0 },293 0, 0 }, 293 294 // tis620*-* 294 295 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 295 296 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 296 297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 297 0 },298 0, 0 }, 298 299 // iso8859-11 299 300 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 300 301 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 301 302 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 302 0 },303 0, 0 }, 303 304 // mulelao-1 304 305 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 305 306 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 306 307 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 307 0 },308 0, 0 }, 308 309 // ethiopic-unicode 309 310 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 310 311 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 311 312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 312 0 },313 0, 0 }, 313 314 // iso10646-1 314 315 { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 315 316 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 316 317 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 317 0 },318 0, 0 }, 318 319 // unicode-* 319 320 { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 320 321 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 321 322 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 322 0 },323 0, 0 }, 323 324 // *-symbol 324 325 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 325 326 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 326 327 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 327 1 },328 1, 0 }, 328 329 // *-fontspecific 329 330 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 330 331 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 331 332 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 332 1 },333 1, 0 }, 333 334 // fontspecific-* 334 335 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 335 336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 336 337 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 337 1 }338 1, 0 } 338 339 339 340 }; … … 393 394 if (id != -1) return xlfd_encoding[id].mib; 394 395 return 0; 395 } ;396 } 396 397 397 398 int qt_encoding_id_for_mib(int mib) … … 495 496 Description). 496 497 497 Returns true if the thegiven xlfd is valid.498 Returns true if the given xlfd is valid. 498 499 */ 499 500 bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc) … … 510 511 fd->family = QString::fromLatin1(tokens[Family]); 511 512 QString foundry = QString::fromLatin1(tokens[Foundry]); 512 if (! foundry.isEmpty() && foundry != Q String::fromLatin1("*") && (!desc || desc->family->count > 1))513 if (! foundry.isEmpty() && foundry != QLatin1String("*") && (!desc || desc->family->count > 1)) 513 514 fd->family += 514 Q String::fromLatin1(" [") + foundry + QString::fromLatin1("]");515 QLatin1String(" [") + foundry + QLatin1Char(']'); 515 516 516 517 if (qstrlen(tokens[AddStyle]) > 0) … … 753 754 dpi = QX11Info::appDpiY(); 754 755 else 755 dpi = 96; // ####756 dpi = qt_defaultDpiY(); 756 757 } 757 758 758 759 double size; 759 760 if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch) 760 fontDef.pixelSize = qRound(size);761 fontDef.pixelSize = size; 761 762 else 762 763 fontDef.pixelSize = 12; … … 835 836 "", // Ogham 836 837 "", // Runic 837 "km" // Khmer 838 "km", // Khmer 839 "" // N'Ko 838 840 }; 839 841 enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) }; … … 866 868 0x1681, // Ogham 867 869 0x16a0, // Runic 868 0 // Khmer 870 0, // Khmer 871 0x7ca // N'Ko 869 872 }; 870 873 enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) }; … … 905 908 0, // Symbol 906 909 0, // Ogham 907 0 // Runic 910 0, // Runic 911 0 // N'Ko 908 912 }; 909 913 enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; … … 944 948 0, // Symbol 945 949 0x1681, // Ogham 946 0x16a0 // Runic 950 0x16a0, // Runic 951 0x7ca // N'Ko 947 952 }; 948 953 enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) }; … … 984 989 0, // Symbol 985 990 0, // Ogham 986 0 // Runic 991 0, // Runic 992 "nko " // N'Ko 987 993 }; 988 994 enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) }; … … 1205 1211 static void initializeDb(); 1206 1212 1207 static void load(const QString &family = QString(), int script = -1 )1208 { 1209 if (X11->has_fontconfig ) {1213 static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false) 1214 { 1215 if (X11->has_fontconfig && !forceXLFD) { 1210 1216 initializeDb(); 1211 1217 return; … … 1456 1462 FcPatternAddInteger(pattern, FC_SLANT, slant_value); 1457 1463 1458 double size_value = qMax( 1, request.pixelSize);1464 double size_value = qMax(qreal(1.), request.pixelSize); 1459 1465 FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); 1460 1466 … … 1472 1478 } 1473 1479 1474 if (script != QUnicodeTables::Common ) {1480 if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') { 1475 1481 Q_ASSERT(script < QUnicodeTables::ScriptCount); 1476 1482 FcLangSet *ls = FcLangSetCreate(); … … 1615 1621 if (!FcCharSetHasChar(cs, specialChars[script])) 1616 1622 goto done; 1617 } else {1623 } else if (*specialLanguages[script] != '\0'){ 1618 1624 FcLangSet *langSet = 0; 1619 1625 if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch) … … 1785 1791 QT_PREPEND_NAMESPACE(parseFontName)(families_and_foundries.at(i), foundry, family); 1786 1792 FM_DEBUG("loadXlfd: >>>>>>>>>>>>>>trying to match '%s' encoding=%d", family.toLatin1().data(), force_encoding_id); 1787 QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc );1793 QT_PREPEND_NAMESPACE(match)(script, request, family, foundry, force_encoding_id, &desc, QList<int>(), true); 1788 1794 if (desc.family) 1789 1795 break; … … 1803 1809 QByteArray xlfd("-"); 1804 1810 xlfd += desc.foundry->name.isEmpty() ? QByteArray("*") : desc.foundry->name.toLatin1(); 1805 xlfd += "-";1811 xlfd += '-'; 1806 1812 xlfd += desc.family->name.isEmpty() ? QByteArray("*") : desc.family->name.toLatin1(); 1807 xlfd += "-";1813 xlfd += '-'; 1808 1814 xlfd += desc.style->weightName ? desc.style->weightName : "*"; 1809 xlfd += "-";1815 xlfd += '-'; 1810 1816 xlfd += (desc.style->key.style == QFont::StyleItalic 1811 ? "i"1812 : (desc.style->key.style == QFont::StyleOblique ? "o" : "r"));1813 xlfd += "-";1817 ? 'i' 1818 : (desc.style->key.style == QFont::StyleOblique ? 'o' : 'r')); 1819 xlfd += '-'; 1814 1820 xlfd += desc.style->setwidthName ? desc.style->setwidthName : "*"; 1815 1821 // ### handle add-style 1816 1822 xlfd += "-*-"; 1817 1823 xlfd += QByteArray::number(px); 1818 xlfd += "-";1824 xlfd += '-'; 1819 1825 xlfd += QByteArray::number(desc.encoding->xpoint); 1820 xlfd += "-";1826 xlfd += '-'; 1821 1827 xlfd += QByteArray::number(desc.encoding->xres); 1822 xlfd += "-";1828 xlfd += '-'; 1823 1829 xlfd += QByteArray::number(desc.encoding->yres); 1824 xlfd += "-";1830 xlfd += '-'; 1825 1831 xlfd += desc.encoding->pitch; 1826 xlfd += "-";1832 xlfd += '-'; 1827 1833 xlfd += QByteArray::number(desc.encoding->avgwidth); 1828 xlfd += "-";1834 xlfd += '-'; 1829 1835 xlfd += xlfd_for_id(desc.encoding->encoding); 1830 1836 … … 1848 1854 } else { 1849 1855 QList<int> encodings; 1850 if (desc.encoding) 1851 encodings.append(int(desc.encoding->encoding)); 1856 if (desc.encoding) { 1857 if (desc.encoding->encoding >= 0) 1858 encodings.append(int(desc.encoding->encoding)); 1859 } 1852 1860 1853 1861 if (desc.size) { … … 1855 1863 for (int i = 0; i < desc.size->count; ++i) { 1856 1864 QtFontEncoding *e = desc.size->encodings + i; 1857 if (e == desc.encoding )1858 continue; 1865 if (e == desc.encoding || e->encoding < 0) 1866 continue; 1859 1867 encodings.append(int(e->encoding)); 1860 1868 } … … 1863 1871 const XlfdEncoding *enc = xlfd_encoding; 1864 1872 for (; enc->name; ++enc) { 1865 if (!encodings.contains(enc->id) )1873 if (!encodings.contains(enc->id) && enc->id >= 0) { 1866 1874 encodings.append(enc->id); 1875 } 1867 1876 } 1868 1877 … … 1891 1900 QFontDef req = d->request; 1892 1901 if (req.pixelSize <= 0) 1893 req.pixelSize = qRound(qt_pixelSize(req.pointSize, d->dpi)); 1894 req.pointSize = 0; 1902 req.pixelSize = floor(qt_pixelSize(req.pointSize, d->dpi) * 100 + 0.5) / 100; 1903 if (req.pixelSize < 1) 1904 req.pixelSize = 1; 1895 1905 if (req.weight == 0) 1896 1906 req.weight = QFont::Normal; … … 1907 1917 1908 1918 // set it to the actual pointsize, so QFontInfo will do the right thing 1909 req.pointSize = qt_pointSize(req.pixelSize, d->dpi); 1919 if (req.pointSize < 0) 1920 req.pointSize = qt_pointSize(req.pixelSize, d->dpi); 1921 1910 1922 1911 1923 QFontEngine *fe = QFontCache::instance()->findEngine(key); … … 1926 1938 } else if (X11->has_fontconfig) { 1927 1939 fe = loadFc(d, script, req); 1940 1941 if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) { 1942 delete fe; 1943 fe = loadXlfd(d->screen, script, req); 1944 } 1945 1946 1928 1947 #endif 1929 1948 } else if (mainThread) {
Note:
See TracChangeset
for help on using the changeset viewer.