src/gui/text/qfontdatabase_x11.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    49 #include "qx11info_x11.h"
    49 #include "qx11info_x11.h"
    50 #include <qdebug.h>
    50 #include <qdebug.h>
    51 #include <qfile.h>
    51 #include <qfile.h>
    52 #include <qtemporaryfile.h>
    52 #include <qtemporaryfile.h>
    53 #include <qabstractfileengine.h>
    53 #include <qabstractfileengine.h>
       
    54 #include <qmath.h>
    54 
    55 
    55 #include <ctype.h>
    56 #include <ctype.h>
    56 #include <stdlib.h>
    57 #include <stdlib.h>
    57 
    58 
    58 #include <sys/types.h>
    59 #include <sys/types.h>
   152 static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontDatabase::WritingSystemsCount] = {
   153 static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontDatabase::WritingSystemsCount] = {
   153     // iso8859-1
   154     // iso8859-1
   154     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   155     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   155       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   156       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   156       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   157       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   157       0 },
   158       0, 0 },
   158     // iso8859-2
   159     // iso8859-2
   159     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   160     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   160       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   161       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   161       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   162       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   162       0 },
   163       0, 0 },
   163     // iso8859-3
   164     // iso8859-3
   164     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   165     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   165       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   166       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   166       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   167       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   167       0 },
   168       0, 0 },
   168     // iso8859-4
   169     // iso8859-4
   169     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   170     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   170       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   171       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   171       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   172       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   172       0 },
   173       0, 0 },
   173     // iso8859-9
   174     // iso8859-9
   174     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   175     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   175       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   176       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   176       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   177       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   177       0 },
   178       0, 0 },
   178     // iso8859-10
   179     // iso8859-10
   179     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   180     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   180       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   181       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   181       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   182       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   182       0 },
   183       0, 0 },
   183     // iso8859-13
   184     // iso8859-13
   184     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   185     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   185       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   186       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   186       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   187       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   187       0 },
   188       0, 0 },
   188     // iso8859-14
   189     // iso8859-14
   189     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   190     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   190       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   191       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   191       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   192       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   192       0 },
   193       0, 0 },
   193     // iso8859-15
   194     // iso8859-15
   194     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   195     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   195       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   196       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   196       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   197       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   197       0 },
   198       0, 0 },
   198     // hp-roman8
   199     // hp-roman8
   199     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   200     { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   200       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   201       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   201       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   202       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   202       0 },
   203       0, 0 },
   203     // iso8859-5
   204     // iso8859-5
   204     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   205     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   205       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   206       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   206       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   207       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   207       0 },
   208       0, 0 },
   208     // *-cp1251
   209     // *-cp1251
   209     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   210     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   210       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   211       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   211       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   212       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   212       0 },
   213       0, 0 },
   213     // koi8-ru
   214     // koi8-ru
   214     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   215     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   215       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   216       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   216       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   217       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   217       0 },
   218       0, 0 },
   218     // koi8-u
   219     // koi8-u
   219     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   220     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   220       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   221       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   221       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   222       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   222       0 },
   223       0, 0 },
   223     // koi8-r
   224     // koi8-r
   224     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   225     { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   225       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   226       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   226       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   227       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   227       0 },
   228       0, 0 },
   228     // iso8859-7
   229     // iso8859-7
   229     { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
   230     { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
   230       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   231       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   231       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   232       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   232       0 },
   233       0, 0 },
   233     // iso8859-8
   234     // iso8859-8
   234     { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   235     { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   235       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   236       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   236       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   237       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   237       0 },
   238       0, 0 },
   238     // gb18030-0
   239     // gb18030-0
   239     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   240     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   240       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   241       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   241       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   242       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   242       0 },
   243       0, 0 },
   243     // gb18030.2000-0
   244     // gb18030.2000-0
   244     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   245     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   245       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   246       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   246       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   247       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   247       0 },
   248       0, 0 },
   248     // gbk-0
   249     // gbk-0
   249     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   250     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   250       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   251       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   251       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   252       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   252       0 },
   253       0, 0 },
   253     // gb2312.*-0
   254     // gb2312.*-0
   254     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   255     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   255       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   256       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   256       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   257       0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   257       0 },
   258       0, 0 },
   258     // jisx0201*-0
   259     // jisx0201*-0
   259     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   260     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   260       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   261       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   261       0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
   262       0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
   262       0 },
   263       0, 0 },
   263     // jisx0208*-0
   264     // jisx0208*-0
   264     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   265     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   265       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   266       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   266       0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
   267       0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
   267       0 },
   268       0, 0 },
   268     // ksc5601*-*
   269     // ksc5601*-*
   269     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   270     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   270       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   271       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   271       0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
   272       0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
   272       0 },
   273       0, 0 },
   273     // big5hkscs-0
   274     // big5hkscs-0
   274     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   275     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   275       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   276       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   276       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   277       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   277       0 },
   278       0, 0 },
   278     // hkscs-1
   279     // hkscs-1
   279     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   280     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   280       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   281       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   281       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   282       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   282       0 },
   283       0, 0 },
   283     // big5*-*
   284     // big5*-*
   284     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   285     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   285       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   286       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   286       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   287       0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   287       0 },
   288       0, 0 },
   288     // tscii-*
   289     // tscii-*
   289     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   290     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   290       0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
   291       0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
   291       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   292       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   292       0 },
   293       0, 0 },
   293     // tis620*-*
   294     // tis620*-*
   294     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   295     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   295       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   296       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   296       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   297       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   297       0 },
   298       0, 0 },
   298     // iso8859-11
   299     // iso8859-11
   299     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   300     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   300       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   301       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   301       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   302       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   302       0 },
   303       0, 0 },
   303     // mulelao-1
   304     // mulelao-1
   304     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   305     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   305       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   306       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   306       1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   307       1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   307       0 },
   308       0, 0 },
   308     // ethiopic-unicode
   309     // ethiopic-unicode
   309     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   310     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   310       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   311       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   311       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   312       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   312       0 },
   313       0, 0 },
   313     // iso10646-1
   314     // iso10646-1
   314     { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
   315     { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
   315       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   316       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   316       1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
   317       1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
   317       0 },
   318       0, 0 },
   318     // unicode-*
   319     // unicode-*
   319     { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
   320     { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0,
   320       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   321       0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
   321       1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
   322       1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
   322       0 },
   323       0, 0 },
   323     // *-symbol
   324     // *-symbol
   324     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   325     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   325       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   326       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   326       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   327       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   327       1 },
   328       1, 0 },
   328     // *-fontspecific
   329     // *-fontspecific
   329     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   330     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   330       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   331       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   331       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   332       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   332       1 },
   333       1, 0 },
   333     // fontspecific-*
   334     // fontspecific-*
   334     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   335     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   335       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   336       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   336       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   337       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   337       1 }
   338       1, 0 }
   338 
   339 
   339 };
   340 };
   340 
   341 
   341 // ----- end of generated code -----
   342 // ----- end of generated code -----
   342 
   343 
   755             dpi = qt_defaultDpiY();
   756             dpi = qt_defaultDpiY();
   756     }
   757     }
   757 
   758 
   758     double size;
   759     double size;
   759     if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
   760     if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
   760         fontDef.pixelSize = qRound(size);
   761         fontDef.pixelSize = size;
   761     else
   762     else
   762         fontDef.pixelSize = 12;
   763         fontDef.pixelSize = 12;
   763 
   764 
   764     fontDef.pointSize = qt_pointSize(fontDef.pixelSize, qRound(dpi));
   765     fontDef.pointSize = qt_pointSize(fontDef.pixelSize, qRound(dpi));
   765 
   766 
   832     "my", // Myanmar
   833     "my", // Myanmar
   833     "ka", // Georgian
   834     "ka", // Georgian
   834     "ko", // Hangul
   835     "ko", // Hangul
   835     "", // Ogham
   836     "", // Ogham
   836     "", // Runic
   837     "", // Runic
   837     "km" // Khmer
   838     "km", // Khmer
       
   839     "" // N'Ko
   838 };
   840 };
   839 enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
   841 enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
   840 
   842 
   841 static const ushort specialChars[] = {
   843 static const ushort specialChars[] = {
   842     0, // English
   844     0, // English
   863     0x1000, // Myanmar
   865     0x1000, // Myanmar
   864     0, // Georgian
   866     0, // Georgian
   865     0, // Hangul
   867     0, // Hangul
   866     0x1681, // Ogham
   868     0x1681, // Ogham
   867     0x16a0, // Runic
   869     0x16a0, // Runic
   868     0  // Khmer
   870     0,  // Khmer
       
   871     0x7ca // N'Ko
   869 };
   872 };
   870 enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
   873 enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
   871 
   874 
   872 // this could become a list of all languages used for each writing
   875 // this could become a list of all languages used for each writing
   873 // system, instead of using the single most common language.
   876 // system, instead of using the single most common language.
   902     "ja",  // Japanese
   905     "ja",  // Japanese
   903     "ko",  // Korean
   906     "ko",  // Korean
   904     "vi",  // Vietnamese
   907     "vi",  // Vietnamese
   905     0, // Symbol
   908     0, // Symbol
   906     0, // Ogham
   909     0, // Ogham
   907     0 // Runic
   910     0, // Runic
       
   911     0 // N'Ko
   908 };
   912 };
   909 enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
   913 enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
   910 
   914 
   911 // Unfortunately FontConfig doesn't know about some languages. We have to test these through the
   915 // Unfortunately FontConfig doesn't know about some languages. We have to test these through the
   912 // charset. The lists below contain the systems where we need to do this.
   916 // charset. The lists below contain the systems where we need to do this.
   941     0,  // Japanese
   945     0,  // Japanese
   942     0,  // Korean
   946     0,  // Korean
   943     0,  // Vietnamese
   947     0,  // Vietnamese
   944     0, // Symbol
   948     0, // Symbol
   945     0x1681, // Ogham
   949     0x1681, // Ogham
   946     0x16a0 // Runic
   950     0x16a0, // Runic
       
   951     0x7ca // N'Ko
   947 };
   952 };
   948 enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
   953 enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
   949 
   954 
   950 // Newer FontConfig let's us sort out fonts that contain certain glyphs, but no
   955 // Newer FontConfig let's us sort out fonts that contain certain glyphs, but no
   951 // open type tables for is directly. Do this so we don't pick some strange
   956 // open type tables for is directly. Do this so we don't pick some strange
   981     0,  // Japanese
   986     0,  // Japanese
   982     0,  // Korean
   987     0,  // Korean
   983     0,  // Vietnamese
   988     0,  // Vietnamese
   984     0, // Symbol
   989     0, // Symbol
   985     0, // Ogham
   990     0, // Ogham
   986     0 // Runic
   991     0, // Runic
       
   992     "nko " // N'Ko
   987 };
   993 };
   988 enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) };
   994 enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) };
   989 
   995 
   990 
   996 
   991 static void loadFontConfig()
   997 static void loadFontConfig()
  1453         slant_value = FC_SLANT_ITALIC;
  1459         slant_value = FC_SLANT_ITALIC;
  1454     else if (request.style == QFont::StyleOblique)
  1460     else if (request.style == QFont::StyleOblique)
  1455         slant_value = FC_SLANT_OBLIQUE;
  1461         slant_value = FC_SLANT_OBLIQUE;
  1456     FcPatternAddInteger(pattern, FC_SLANT, slant_value);
  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     FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
  1465     FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
  1460 
  1466 
  1461     int stretch = request.stretch;
  1467     int stretch = request.stretch;
  1462     if (!stretch)
  1468     if (!stretch)
  1463         stretch = 100;
  1469         stretch = 100;
  1469     } else if (request.styleStrategy & (QFont::PreferAntialias|QFont::NoAntialias)) {
  1475     } else if (request.styleStrategy & (QFont::PreferAntialias|QFont::NoAntialias)) {
  1470         FcPatternAddBool(pattern, FC_ANTIALIAS,
  1476         FcPatternAddBool(pattern, FC_ANTIALIAS,
  1471                          !(request.styleStrategy & QFont::NoAntialias));
  1477                          !(request.styleStrategy & QFont::NoAntialias));
  1472     }
  1478     }
  1473 
  1479 
  1474     if (script != QUnicodeTables::Common) {
  1480     if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
  1475         Q_ASSERT(script < QUnicodeTables::ScriptCount);
  1481         Q_ASSERT(script < QUnicodeTables::ScriptCount);
  1476         FcLangSet *ls = FcLangSetCreate();
  1482         FcLangSet *ls = FcLangSetCreate();
  1477         FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
  1483         FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
  1478         FcPatternAddLangSet(pattern, FC_LANG, ls);
  1484         FcPatternAddLangSet(pattern, FC_LANG, ls);
  1479         FcLangSetDestroy(ls);
  1485         FcLangSetDestroy(ls);
  1612             FcCharSet *cs;
  1618             FcCharSet *cs;
  1613             if (FcPatternGetCharSet(match, FC_CHARSET, 0, &cs) != FcResultMatch)
  1619             if (FcPatternGetCharSet(match, FC_CHARSET, 0, &cs) != FcResultMatch)
  1614                 goto done;
  1620                 goto done;
  1615             if (!FcCharSetHasChar(cs, specialChars[script]))
  1621             if (!FcCharSetHasChar(cs, specialChars[script]))
  1616                 goto done;
  1622                 goto done;
  1617         } else {
  1623         } else if (*specialLanguages[script] != '\0'){
  1618             FcLangSet *langSet = 0;
  1624             FcLangSet *langSet = 0;
  1619             if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
  1625             if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch)
  1620                 goto done;
  1626                 goto done;
  1621             if (FcLangSetHasLang(langSet, (const FcChar8*)specialLanguages[script]) != FcLangEqual)
  1627             if (FcLangSetHasLang(langSet, (const FcChar8*)specialLanguages[script]) != FcLangEqual)
  1622                 goto done;
  1628                 goto done;
  1891     Q_ASSERT(script >= 0 && script < QUnicodeTables::ScriptCount);
  1897     Q_ASSERT(script >= 0 && script < QUnicodeTables::ScriptCount);
  1892 
  1898 
  1893     // normalize the request to get better caching
  1899     // normalize the request to get better caching
  1894     QFontDef req = d->request;
  1900     QFontDef req = d->request;
  1895     if (req.pixelSize <= 0)
  1901     if (req.pixelSize <= 0)
  1896         req.pixelSize = qRound(qt_pixelSize(req.pointSize, d->dpi));
  1902         req.pixelSize = floor(qt_pixelSize(req.pointSize, d->dpi) * 100 + 0.5) / 100;
  1897     req.pointSize = 0;
  1903     if (req.pixelSize < 1)
       
  1904         req.pixelSize = 1;
  1898     if (req.weight == 0)
  1905     if (req.weight == 0)
  1899         req.weight = QFont::Normal;
  1906         req.weight = QFont::Normal;
  1900     if (req.stretch == 0)
  1907     if (req.stretch == 0)
  1901         req.stretch = 100;
  1908         req.stretch = 100;
  1902 
  1909 
  1907     // the cached engineData could have already loaded the engine we want
  1914     // the cached engineData could have already loaded the engine we want
  1908     if (d->engineData->engines[script])
  1915     if (d->engineData->engines[script])
  1909         return;
  1916         return;
  1910 
  1917 
  1911     // set it to the actual pointsize, so QFontInfo will do the right thing
  1918     // set it to the actual pointsize, so QFontInfo will do the right thing
  1912     req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
  1919     if (req.pointSize < 0)
       
  1920         req.pointSize = qt_pointSize(req.pixelSize, d->dpi);
       
  1921 
  1913 
  1922 
  1914     QFontEngine *fe = QFontCache::instance()->findEngine(key);
  1923     QFontEngine *fe = QFontCache::instance()->findEngine(key);
  1915 
  1924 
  1916     if (!fe) {
  1925     if (!fe) {
  1917         QMutexLocker locker(fontDatabaseMutex());
  1926         QMutexLocker locker(fontDatabaseMutex());