diff options
Diffstat (limited to 'fontconfig')
-rw-r--r-- | fontconfig/configure.ac | 10 | ||||
-rw-r--r-- | fontconfig/doc/Makefile.am | 1 | ||||
-rw-r--r-- | fontconfig/doc/fcweight.fncs | 47 | ||||
-rw-r--r-- | fontconfig/doc/fontconfig-user.sgml | 2 | ||||
-rw-r--r-- | fontconfig/fontconfig/fontconfig.h | 9 | ||||
-rw-r--r-- | fontconfig/src/Makefile.am | 1 | ||||
-rw-r--r-- | fontconfig/src/fccfg.c | 28 | ||||
-rw-r--r-- | fontconfig/src/fccompat.c | 4 | ||||
-rw-r--r-- | fontconfig/src/fcfreetype.c | 193 | ||||
-rw-r--r-- | fontconfig/src/fcint.h | 6 | ||||
-rw-r--r-- | fontconfig/src/fcmatch.c | 45 | ||||
-rw-r--r-- | fontconfig/src/fcname.c | 2 | ||||
-rw-r--r-- | fontconfig/src/fcrange.c | 4 | ||||
-rw-r--r-- | fontconfig/src/fcstat.c | 4 | ||||
-rw-r--r-- | fontconfig/src/fcstr.c | 52 | ||||
-rw-r--r-- | fontconfig/src/fcweight.c | 88 | ||||
-rw-r--r-- | fontconfig/src/fcwindows.h | 7 | ||||
-rwxr-xr-x | fontconfig/src/makefile | 1 |
18 files changed, 391 insertions, 113 deletions
diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac index ce468b89e..a366853e2 100644 --- a/fontconfig/configure.ac +++ b/fontconfig/configure.ac @@ -138,7 +138,7 @@ dnl ========================================================================== # Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([fcntl.h regex.h stdlib.h string.h unistd.h sys/statvfs.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h]) +AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h sys/statvfs.h sys/vfs.h sys/statfs.h sys/param.h sys/mount.h]) AX_CREATE_STDINT_H([src/fcstdint.h]) # Checks for typedefs, structures, and compiler characteristics. @@ -150,7 +150,7 @@ AC_TYPE_PID_T # Checks for library functions. AC_FUNC_VPRINTF AC_FUNC_MMAP -AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink regcomp regerror regexec regfree fstatvfs fstatfs lstat]) +AC_CHECK_FUNCS([link mkstemp mkostemp _mktemp_s mkdtemp getopt getopt_long getprogname getexecname rand random lrand48 random_r rand_r readlink fstatvfs fstatfs lstat]) dnl AC_CHECK_FUNCS doesn't check for header files. dnl posix_fadvise() may be not available in older libc. @@ -211,12 +211,6 @@ if test "x$ac_cv_func_fstatfs" = "xyes"; then fi AC_CHECK_MEMBERS([struct dirent.d_type],,, [#include <dirent.h>]) -# -# regex -# -if test "x$ac_cv_func_regcomp" = "xyes" -a "x$ac_cv_func_regerror" = "xyes" -a "x$ac_cv_func_regexec" = "xyes" -a "x$ac_cv_func_regfree"; then - AC_DEFINE(USE_REGEX,,[Use regex]) -fi # # Checks for iconv diff --git a/fontconfig/doc/Makefile.am b/fontconfig/doc/Makefile.am index 7503219b8..9141ab236 100644 --- a/fontconfig/doc/Makefile.am +++ b/fontconfig/doc/Makefile.am @@ -85,6 +85,7 @@ DOC_FUNCS_FNCS = \ fcstring.fncs \ fcstrset.fncs \ fcvalue.fncs \ + fcweight.fncs \ $(NULL) SGML_FILES = \ fontconfig-user.sgml \ diff --git a/fontconfig/doc/fcweight.fncs b/fontconfig/doc/fcweight.fncs new file mode 100644 index 000000000..2872dd66c --- /dev/null +++ b/fontconfig/doc/fcweight.fncs @@ -0,0 +1,47 @@ +/* + * fontconfig/doc/fcweight.fncs + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +@RET@ int +@FUNC@ FcWeightFromOpenType +@TYPE1@ int @ARG1@ ot_weight +@PURPOSE@ Convert from OpenType weight values to fontconfig ones +@DESC@ +<function>FcWeightFromOpenType</function> returns an integer value +to use with FC_WEIGHT, from an integer in the 1..1000 range, resembling +the numbers from OpenType specification's OS/2 usWeight numbers, which +are also similar to CSS font-weight numbers. If input is negative, +zero, or greater than 1000, returns -1. This function linearly interpolates +between various FC_WEIGHT_* constants. As such, the returned value does not +necessarily match any of the predefined constants. +@SINCE@ 2.11.91 +@@ + +@RET@ int +@FUNC@ FcWeightToOpenType +@TYPE1@ int @ARG1@ ot_weight +@PURPOSE@ Convert from fontconfig weight values to OpenType ones +@DESC@ +<function>FcWeightToOpenType</function> is the inverse of +<function>FcWeightFromOpenType</function>. If the input is less than +FC_WEIGHT_THIN or greater than FC_WEIGHT_EXTRABLACK, returns -1. Otherwise +returns a number in the range 1 to 1000. +@SINCE@ 2.11.91 +@@ diff --git a/fontconfig/doc/fontconfig-user.sgml b/fontconfig/doc/fontconfig-user.sgml index 775d1f725..482b45331 100644 --- a/fontconfig/doc/fontconfig-user.sgml +++ b/fontconfig/doc/fontconfig-user.sgml @@ -473,6 +473,8 @@ symbolic names for common font values: extralight weight 40 ultralight weight 40 light weight 50 + demilight weight 55 + semilight weight 55 book weight 75 regular weight 80 normal weight 80 diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h index 8575cc4d3..e5b09591b 100644 --- a/fontconfig/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig/fontconfig.h @@ -131,6 +131,8 @@ typedef int FcBool; #define FC_WEIGHT_EXTRALIGHT 40 #define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT #define FC_WEIGHT_LIGHT 50 +#define FC_WEIGHT_DEMILIGHT 55 +#define FC_WEIGHT_SEMILIGHT FC_WEIGHT_DEMILIGHT #define FC_WEIGHT_BOOK 75 #define FC_WEIGHT_REGULAR 80 #define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR @@ -906,6 +908,13 @@ FcRangeDestroy (FcRange *range); FcPublic FcRange * FcRangeCopy (const FcRange *r); +/* fcweight.c */ + +FcPublic int +FcWeightFromOpenType (int ot_weight); + +FcPublic int +FcWeightToOpenType (int fc_weight); /* fcstr.c */ diff --git a/fontconfig/src/Makefile.am b/fontconfig/src/Makefile.am index c1991b284..3757cf8f3 100644 --- a/fontconfig/src/Makefile.am +++ b/fontconfig/src/Makefile.am @@ -154,6 +154,7 @@ libfontconfig_la_SOURCES = \ fcserialize.c \ fcstat.c \ fcstr.c \ + fcweight.c \ fcwindows.h \ fcxml.c \ ftglue.h \ diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index 6d3259513..f8ee8d20e 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -1546,10 +1546,38 @@ FcConfigSubstituteWithPat (FcConfig *config, FcStrSetDestroy (strs); while (l && (lang = FcStrListNext (l))) { + FcPatternElt *e = FcPatternObjectFindElt (p, FC_LANG_OBJECT); + + if (e) + { + FcValueListPtr ll; + + for (ll = FcPatternEltValues (e); ll; ll = FcValueListNext (ll)) + { + FcValue vv = FcValueCanonicalize (&ll->value); + + if (vv.type == FcTypeLangSet) + { + FcLangSet *ls = FcLangSetCreate (); + FcBool b; + + FcLangSetAdd (ls, lang); + b = FcLangSetContains (vv.u.l, ls); + FcLangSetDestroy (ls); + if (b) + goto bail_lang; + } + else + if (FcStrCmpIgnoreCase (vv.u.s, lang) == 0) + goto bail_lang; + } + } v.type = FcTypeString; v.u.s = lang; + FcPatternObjectAddWithBinding (p, FC_LANG_OBJECT, v, FcValueBindingWeak, FcTrue); } + bail_lang: FcStrListDone (l); } if (FcPatternObjectGet (p, FC_PRGNAME_OBJECT, 0, &v) == FcResultNoMatch) diff --git a/fontconfig/src/fccompat.c b/fontconfig/src/fccompat.c index 19b1ecdc0..f0efa571b 100644 --- a/fontconfig/src/fccompat.c +++ b/fontconfig/src/fccompat.c @@ -255,3 +255,7 @@ FcMakeDirectory (const FcChar8 *dir) FcStrFree (parent); return ret; } + +#define __fccompat__ +#include "fcaliastail.h" +#undef __fccompat__ diff --git a/fontconfig/src/fcfreetype.c b/fontconfig/src/fcfreetype.c index 3eb409160..f356f27dc 100644 --- a/fontconfig/src/fcfreetype.c +++ b/fontconfig/src/fcfreetype.c @@ -558,6 +558,139 @@ FcFontCapabilities(FT_Face face); #define NUM_FC_MAC_ROMAN_FAKE (int) (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0])) + +/* From http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT */ +static const FcChar16 fcMacRomanNonASCIIToUnicode[128] = { + /*0x80*/ 0x00C4, /* LATIN CAPITAL LETTER A WITH DIAERESIS */ + /*0x81*/ 0x00C5, /* LATIN CAPITAL LETTER A WITH RING ABOVE */ + /*0x82*/ 0x00C7, /* LATIN CAPITAL LETTER C WITH CEDILLA */ + /*0x83*/ 0x00C9, /* LATIN CAPITAL LETTER E WITH ACUTE */ + /*0x84*/ 0x00D1, /* LATIN CAPITAL LETTER N WITH TILDE */ + /*0x85*/ 0x00D6, /* LATIN CAPITAL LETTER O WITH DIAERESIS */ + /*0x86*/ 0x00DC, /* LATIN CAPITAL LETTER U WITH DIAERESIS */ + /*0x87*/ 0x00E1, /* LATIN SMALL LETTER A WITH ACUTE */ + /*0x88*/ 0x00E0, /* LATIN SMALL LETTER A WITH GRAVE */ + /*0x89*/ 0x00E2, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */ + /*0x8A*/ 0x00E4, /* LATIN SMALL LETTER A WITH DIAERESIS */ + /*0x8B*/ 0x00E3, /* LATIN SMALL LETTER A WITH TILDE */ + /*0x8C*/ 0x00E5, /* LATIN SMALL LETTER A WITH RING ABOVE */ + /*0x8D*/ 0x00E7, /* LATIN SMALL LETTER C WITH CEDILLA */ + /*0x8E*/ 0x00E9, /* LATIN SMALL LETTER E WITH ACUTE */ + /*0x8F*/ 0x00E8, /* LATIN SMALL LETTER E WITH GRAVE */ + /*0x90*/ 0x00EA, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */ + /*0x91*/ 0x00EB, /* LATIN SMALL LETTER E WITH DIAERESIS */ + /*0x92*/ 0x00ED, /* LATIN SMALL LETTER I WITH ACUTE */ + /*0x93*/ 0x00EC, /* LATIN SMALL LETTER I WITH GRAVE */ + /*0x94*/ 0x00EE, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */ + /*0x95*/ 0x00EF, /* LATIN SMALL LETTER I WITH DIAERESIS */ + /*0x96*/ 0x00F1, /* LATIN SMALL LETTER N WITH TILDE */ + /*0x97*/ 0x00F3, /* LATIN SMALL LETTER O WITH ACUTE */ + /*0x98*/ 0x00F2, /* LATIN SMALL LETTER O WITH GRAVE */ + /*0x99*/ 0x00F4, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */ + /*0x9A*/ 0x00F6, /* LATIN SMALL LETTER O WITH DIAERESIS */ + /*0x9B*/ 0x00F5, /* LATIN SMALL LETTER O WITH TILDE */ + /*0x9C*/ 0x00FA, /* LATIN SMALL LETTER U WITH ACUTE */ + /*0x9D*/ 0x00F9, /* LATIN SMALL LETTER U WITH GRAVE */ + /*0x9E*/ 0x00FB, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */ + /*0x9F*/ 0x00FC, /* LATIN SMALL LETTER U WITH DIAERESIS */ + /*0xA0*/ 0x2020, /* DAGGER */ + /*0xA1*/ 0x00B0, /* DEGREE SIGN */ + /*0xA2*/ 0x00A2, /* CENT SIGN */ + /*0xA3*/ 0x00A3, /* POUND SIGN */ + /*0xA4*/ 0x00A7, /* SECTION SIGN */ + /*0xA5*/ 0x2022, /* BULLET */ + /*0xA6*/ 0x00B6, /* PILCROW SIGN */ + /*0xA7*/ 0x00DF, /* LATIN SMALL LETTER SHARP S */ + /*0xA8*/ 0x00AE, /* REGISTERED SIGN */ + /*0xA9*/ 0x00A9, /* COPYRIGHT SIGN */ + /*0xAA*/ 0x2122, /* TRADE MARK SIGN */ + /*0xAB*/ 0x00B4, /* ACUTE ACCENT */ + /*0xAC*/ 0x00A8, /* DIAERESIS */ + /*0xAD*/ 0x2260, /* NOT EQUAL TO */ + /*0xAE*/ 0x00C6, /* LATIN CAPITAL LETTER AE */ + /*0xAF*/ 0x00D8, /* LATIN CAPITAL LETTER O WITH STROKE */ + /*0xB0*/ 0x221E, /* INFINITY */ + /*0xB1*/ 0x00B1, /* PLUS-MINUS SIGN */ + /*0xB2*/ 0x2264, /* LESS-THAN OR EQUAL TO */ + /*0xB3*/ 0x2265, /* GREATER-THAN OR EQUAL TO */ + /*0xB4*/ 0x00A5, /* YEN SIGN */ + /*0xB5*/ 0x00B5, /* MICRO SIGN */ + /*0xB6*/ 0x2202, /* PARTIAL DIFFERENTIAL */ + /*0xB7*/ 0x2211, /* N-ARY SUMMATION */ + /*0xB8*/ 0x220F, /* N-ARY PRODUCT */ + /*0xB9*/ 0x03C0, /* GREEK SMALL LETTER PI */ + /*0xBA*/ 0x222B, /* INTEGRAL */ + /*0xBB*/ 0x00AA, /* FEMININE ORDINAL INDICATOR */ + /*0xBC*/ 0x00BA, /* MASCULINE ORDINAL INDICATOR */ + /*0xBD*/ 0x03A9, /* GREEK CAPITAL LETTER OMEGA */ + /*0xBE*/ 0x00E6, /* LATIN SMALL LETTER AE */ + /*0xBF*/ 0x00F8, /* LATIN SMALL LETTER O WITH STROKE */ + /*0xC0*/ 0x00BF, /* INVERTED QUESTION MARK */ + /*0xC1*/ 0x00A1, /* INVERTED EXCLAMATION MARK */ + /*0xC2*/ 0x00AC, /* NOT SIGN */ + /*0xC3*/ 0x221A, /* SQUARE ROOT */ + /*0xC4*/ 0x0192, /* LATIN SMALL LETTER F WITH HOOK */ + /*0xC5*/ 0x2248, /* ALMOST EQUAL TO */ + /*0xC6*/ 0x2206, /* INCREMENT */ + /*0xC7*/ 0x00AB, /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ + /*0xC8*/ 0x00BB, /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ + /*0xC9*/ 0x2026, /* HORIZONTAL ELLIPSIS */ + /*0xCA*/ 0x00A0, /* NO-BREAK SPACE */ + /*0xCB*/ 0x00C0, /* LATIN CAPITAL LETTER A WITH GRAVE */ + /*0xCC*/ 0x00C3, /* LATIN CAPITAL LETTER A WITH TILDE */ + /*0xCD*/ 0x00D5, /* LATIN CAPITAL LETTER O WITH TILDE */ + /*0xCE*/ 0x0152, /* LATIN CAPITAL LIGATURE OE */ + /*0xCF*/ 0x0153, /* LATIN SMALL LIGATURE OE */ + /*0xD0*/ 0x2013, /* EN DASH */ + /*0xD1*/ 0x2014, /* EM DASH */ + /*0xD2*/ 0x201C, /* LEFT DOUBLE QUOTATION MARK */ + /*0xD3*/ 0x201D, /* RIGHT DOUBLE QUOTATION MARK */ + /*0xD4*/ 0x2018, /* LEFT SINGLE QUOTATION MARK */ + /*0xD5*/ 0x2019, /* RIGHT SINGLE QUOTATION MARK */ + /*0xD6*/ 0x00F7, /* DIVISION SIGN */ + /*0xD7*/ 0x25CA, /* LOZENGE */ + /*0xD8*/ 0x00FF, /* LATIN SMALL LETTER Y WITH DIAERESIS */ + /*0xD9*/ 0x0178, /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ + /*0xDA*/ 0x2044, /* FRACTION SLASH */ + /*0xDB*/ 0x20AC, /* EURO SIGN */ + /*0xDC*/ 0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */ + /*0xDD*/ 0x203A, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */ + /*0xDE*/ 0xFB01, /* LATIN SMALL LIGATURE FI */ + /*0xDF*/ 0xFB02, /* LATIN SMALL LIGATURE FL */ + /*0xE0*/ 0x2021, /* DOUBLE DAGGER */ + /*0xE1*/ 0x00B7, /* MIDDLE DOT */ + /*0xE2*/ 0x201A, /* SINGLE LOW-9 QUOTATION MARK */ + /*0xE3*/ 0x201E, /* DOUBLE LOW-9 QUOTATION MARK */ + /*0xE4*/ 0x2030, /* PER MILLE SIGN */ + /*0xE5*/ 0x00C2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ + /*0xE6*/ 0x00CA, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ + /*0xE7*/ 0x00C1, /* LATIN CAPITAL LETTER A WITH ACUTE */ + /*0xE8*/ 0x00CB, /* LATIN CAPITAL LETTER E WITH DIAERESIS */ + /*0xE9*/ 0x00C8, /* LATIN CAPITAL LETTER E WITH GRAVE */ + /*0xEA*/ 0x00CD, /* LATIN CAPITAL LETTER I WITH ACUTE */ + /*0xEB*/ 0x00CE, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ + /*0xEC*/ 0x00CF, /* LATIN CAPITAL LETTER I WITH DIAERESIS */ + /*0xED*/ 0x00CC, /* LATIN CAPITAL LETTER I WITH GRAVE */ + /*0xEE*/ 0x00D3, /* LATIN CAPITAL LETTER O WITH ACUTE */ + /*0xEF*/ 0x00D4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ + /*0xF0*/ 0xF8FF, /* Apple logo */ + /*0xF1*/ 0x00D2, /* LATIN CAPITAL LETTER O WITH GRAVE */ + /*0xF2*/ 0x00DA, /* LATIN CAPITAL LETTER U WITH ACUTE */ + /*0xF3*/ 0x00DB, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ + /*0xF4*/ 0x00D9, /* LATIN CAPITAL LETTER U WITH GRAVE */ + /*0xF5*/ 0x0131, /* LATIN SMALL LETTER DOTLESS I */ + /*0xF6*/ 0x02C6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */ + /*0xF7*/ 0x02DC, /* SMALL TILDE */ + /*0xF8*/ 0x00AF, /* MACRON */ + /*0xF9*/ 0x02D8, /* BREVE */ + /*0xFA*/ 0x02D9, /* DOT ABOVE */ + /*0xFB*/ 0x02DA, /* RING ABOVE */ + /*0xFC*/ 0x00B8, /* CEDILLA */ + /*0xFD*/ 0x02DD, /* DOUBLE ACUTE ACCENT */ + /*0xFE*/ 0x02DB, /* OGONEK */ + /*0xFF*/ 0x02C7, /* CARON */ +}; + #if USE_ICONV #include <iconv.h> #endif @@ -696,6 +829,35 @@ FcSfntNameTranscode (FT_SfntName *sname) *u8 = '\0'; goto done; } + if (!strcmp (fromcode, FC_ENCODING_MAC_ROMAN)) + { + FcChar8 *src = sname->string; + int src_len = sname->string_len; + int olen; + FcChar8 *u8; + FcChar32 ucs4; + + /* + * Convert Latin1 to Utf8. Freed below + */ + utf8 = malloc (src_len * 3 + 1); + if (!utf8) + return 0; + + u8 = utf8; + while (src_len > 0) + { + ucs4 = *src++; + if (ucs4 >= 128) + ucs4 = fcMacRomanNonASCIIToUnicode[ucs4 - 128]; + src_len--; + olen = FcUcs4ToUtf8 (ucs4, u8); + u8 += olen; + } + *u8 = '\0'; + goto done; + } + #if USE_ICONV cd = iconv_open ("UTF-8", fromcode); if (cd && cd != (iconv_t) (-1)) @@ -933,6 +1095,8 @@ static const FcStringConst weightConsts[] = { { (FC8) "thin", FC_WEIGHT_THIN }, { (FC8) "extralight", FC_WEIGHT_EXTRALIGHT }, { (FC8) "ultralight", FC_WEIGHT_ULTRALIGHT }, + { (FC8) "demilight", FC_WEIGHT_DEMILIGHT }, + { (FC8) "semilight", FC_WEIGHT_SEMILIGHT }, { (FC8) "light", FC_WEIGHT_LIGHT }, { (FC8) "book", FC_WEIGHT_BOOK }, { (FC8) "regular", FC_WEIGHT_REGULAR }, @@ -1107,6 +1271,8 @@ FcFreeTypeQueryFace (const FT_Face face, FcRange *r = NULL; double lower_size = 0.0L, upper_size = DBL_MAX; + FcInitDebug (); /* We might be called with no initizalization whatsoever. */ + pat = FcPatternCreate (); if (!pat) goto bail0; @@ -1282,10 +1448,10 @@ FcFreeTypeQueryFace (const FT_Face face, free (utf8); if (lang) { - /* pad lang list with 'xx' to line up with elt */ + /* pad lang list with 'und' to line up with elt */ while (*nlangp < *np) { - if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "xx")) + if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "und")) goto bail1; ++*nlangp; } @@ -1462,28 +1628,7 @@ FcFreeTypeQueryFace (const FT_Face face, if (os2 && os2->version != 0xffff) { - if (os2->usWeightClass == 0) - ; - else if (os2->usWeightClass < 150) - weight = FC_WEIGHT_THIN; - else if (os2->usWeightClass < 250) - weight = FC_WEIGHT_EXTRALIGHT; - else if (os2->usWeightClass < 350) - weight = FC_WEIGHT_LIGHT; - else if (os2->usWeightClass < 450) - weight = FC_WEIGHT_REGULAR; - else if (os2->usWeightClass < 550) - weight = FC_WEIGHT_MEDIUM; - else if (os2->usWeightClass < 650) - weight = FC_WEIGHT_SEMIBOLD; - else if (os2->usWeightClass < 750) - weight = FC_WEIGHT_BOLD; - else if (os2->usWeightClass < 850) - weight = FC_WEIGHT_EXTRABOLD; - else if (os2->usWeightClass < 925) - weight = FC_WEIGHT_BLACK; - else if (os2->usWeightClass < 1000) - weight = FC_WEIGHT_EXTRABLACK; + weight = FcWeightFromOpenType (os2->usWeightClass); if ((FcDebug() & FC_DBG_SCANV) && weight != -1) printf ("\tos2 weight class %d maps to weight %d\n", os2->usWeightClass, weight); diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h index d3079edcc..45dfc6e61 100644 --- a/fontconfig/src/fcint.h +++ b/fontconfig/src/fcint.h @@ -1152,12 +1152,6 @@ FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2); FcPrivate int FcStrCmpIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims); -FcPrivate FcBool -FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex); - -FcPrivate FcBool -FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex); - FcPrivate const FcChar8 * FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2); diff --git a/fontconfig/src/fcmatch.c b/fontconfig/src/fcmatch.c index 78255186f..b0e695df3 100644 --- a/fontconfig/src/fcmatch.c +++ b/fontconfig/src/fcmatch.c @@ -483,7 +483,7 @@ FcFontRenderPrepare (FcConfig *config, { FcPattern *new; int i; - FcPatternElt *fe, *pe, *fel, *pel; + FcPatternElt *fe, *pe; FcValue v; FcResult result; @@ -508,36 +508,25 @@ FcFontRenderPrepare (FcConfig *config, fe->object == FC_STYLE_OBJECT || fe->object == FC_FULLNAME_OBJECT) { + FcPatternElt *fel, *pel; + FC_ASSERT_STATIC ((FC_FAMILY_OBJECT + 1) == FC_FAMILYLANG_OBJECT); FC_ASSERT_STATIC ((FC_STYLE_OBJECT + 1) == FC_STYLELANG_OBJECT); FC_ASSERT_STATIC ((FC_FULLNAME_OBJECT + 1) == FC_FULLNAMELANG_OBJECT); fel = FcPatternObjectFindElt (font, fe->object + 1); pel = FcPatternObjectFindElt (pat, fe->object + 1); - } - else - { - fel = NULL; - pel = NULL; - } - pe = FcPatternObjectFindElt (pat, fe->object); - if (pe) - { - const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse); - if (!FcCompareValueList (pe->object, match, - FcPatternEltValues(pe), - FcPatternEltValues(fe), &v, NULL, NULL, &result)) - { - FcPatternDestroy (new); - return NULL; - } if (fel && pel) { + /* The font has name languages, and pattern asks for specific language(s). + * Match on language and and prefer that result. + * Note: Currently the code only give priority to first matching language. + */ int n = 1, j; FcValueListPtr l1, l2, ln = NULL, ll = NULL; + const FcMatcher *match = FcObjectToMatcher (pel->object, FcTrue); - match = FcObjectToMatcher (pel->object, FcTrue); if (!FcCompareValueList (pel->object, match, FcPatternEltValues (pel), FcPatternEltValues (fel), NULL, NULL, &n, &result)) @@ -580,9 +569,10 @@ FcFontRenderPrepare (FcConfig *config, } else if (fel) { + /* Pattern doesn't ask for specific language. Copy all for name and + * lang. */ FcValueListPtr l1, l2; - copy_lang: l1 = FcValueListDuplicate (FcPatternEltValues (fe)); l2 = FcValueListDuplicate (FcPatternEltValues (fel)); FcPatternObjectListAdd (new, fe->object, l1, FcFalse); @@ -590,12 +580,23 @@ FcFontRenderPrepare (FcConfig *config, continue; } + } + + pe = FcPatternObjectFindElt (pat, fe->object); + if (pe) + { + const FcMatcher *match = FcObjectToMatcher (pe->object, FcFalse); + if (!FcCompareValueList (pe->object, match, + FcPatternEltValues(pe), + FcPatternEltValues(fe), &v, NULL, NULL, &result)) + { + FcPatternDestroy (new); + return NULL; + } FcPatternObjectAdd (new, fe->object, v, FcFalse); } else { - if (fel) - goto copy_lang; FcPatternObjectListAdd (new, fe->object, FcValueListDuplicate (FcPatternEltValues (fe)), FcTrue); diff --git a/fontconfig/src/fcname.c b/fontconfig/src/fcname.c index 466617872..1d8fe757c 100644 --- a/fontconfig/src/fcname.c +++ b/fontconfig/src/fcname.c @@ -136,6 +136,8 @@ static const FcConstant _FcBaseConstants[] = { { (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, }, { (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, }, { (FcChar8 *) "ultralight", "weight", FC_WEIGHT_EXTRALIGHT, }, + { (FcChar8 *) "demilight", "weight", FC_WEIGHT_DEMILIGHT, }, + { (FcChar8 *) "semilight", "weight", FC_WEIGHT_DEMILIGHT, }, { (FcChar8 *) "light", "weight", FC_WEIGHT_LIGHT, }, { (FcChar8 *) "book", "weight", FC_WEIGHT_BOOK, }, { (FcChar8 *) "regular", "weight", FC_WEIGHT_REGULAR, }, diff --git a/fontconfig/src/fcrange.c b/fontconfig/src/fcrange.c index 7d0c1c0b1..39eafd82d 100644 --- a/fontconfig/src/fcrange.c +++ b/fontconfig/src/fcrange.c @@ -205,3 +205,7 @@ FcRangeSerialize (FcSerialize *serialize, const FcRange *r) return r_serialize; } + +#define __fcrange__ +#include "fcaliastail.h" +#undef __fcrange__ diff --git a/fontconfig/src/fcstat.c b/fontconfig/src/fcstat.c index 7b054cf78..0bced5eed 100644 --- a/fontconfig/src/fcstat.c +++ b/fontconfig/src/fcstat.c @@ -360,3 +360,7 @@ FcIsFsMtimeBroken (const FcChar8 *dir) return FcFalse; } + +#define __fcstat__ +#include "fcaliastail.h" +#undef __fcstat__ diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index 024dae325..29a577d10 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -26,9 +26,6 @@ #include <stdlib.h> #include <ctype.h> #include <string.h> -#ifdef HAVE_REGEX_H -#include <regex.h> -#endif /* Objects MT-safe for readonly access. */ @@ -242,55 +239,6 @@ FcStrCmp (const FcChar8 *s1, const FcChar8 *s2) return (int) c1 - (int) c2; } -#ifdef USE_REGEX -static FcBool -_FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex, int cflags, int eflags) -{ - int ret = -1; - regex_t reg; - - if ((ret = regcomp (®, (const char *)regex, cflags)) != 0) - { - if (FcDebug () & FC_DBG_MATCHV) - { - char buf[512]; - - regerror (ret, ®, buf, 512); - printf("Regexp compile error: %s\n", buf); - } - return FcFalse; - } - ret = regexec (®, (const char *)s, 0, NULL, eflags); - if (ret != 0) - { - if (FcDebug () & FC_DBG_MATCHV) - { - char buf[512]; - - regerror (ret, ®, buf, 512); - printf("Regexp exec error: %s\n", buf); - } - } - regfree (®); - - return ret == 0 ? FcTrue : FcFalse; -} -#else -# define _FcStrRegexCmp(_s_, _regex_, _cflags_, _eflags_) (FcFalse) -#endif - -FcBool -FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex) -{ - return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB, 0); -} - -FcBool -FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex) -{ - return _FcStrRegexCmp (s, regex, REG_EXTENDED | REG_NOSUB | REG_ICASE, 0); -} - /* * Return a hash value for a string */ diff --git a/fontconfig/src/fcweight.c b/fontconfig/src/fcweight.c new file mode 100644 index 000000000..87bbe67ab --- /dev/null +++ b/fontconfig/src/fcweight.c @@ -0,0 +1,88 @@ +/* + * fontconfig/src/fcweight.c + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "fcint.h" + +static const struct { + int ot; + int fc; +} map[] = { + { 0, FC_WEIGHT_THIN }, + { 100, FC_WEIGHT_THIN }, + { 200, FC_WEIGHT_EXTRALIGHT }, + { 350, FC_WEIGHT_DEMILIGHT }, + { 300, FC_WEIGHT_LIGHT }, + { 380, FC_WEIGHT_BOOK }, + { 400, FC_WEIGHT_REGULAR }, + { 500, FC_WEIGHT_MEDIUM }, + { 600, FC_WEIGHT_DEMIBOLD }, + { 700, FC_WEIGHT_BOLD }, + { 800, FC_WEIGHT_EXTRABOLD }, + { 900, FC_WEIGHT_BLACK }, + {1000, FC_WEIGHT_EXTRABLACK }, +}; + +static int lerp(int x, int x1, int x2, int y1, int y2) +{ + int dx = x2 - x1; + int dy = y2 - y1; + assert (dx > 0 && dy > 0 && x1 <= x && x <= x2); + return y1 + (dy*(x-x1) + dx/2) / dx; +} + +FcPublic int +FcWeightFromOpenType (int ot_weight) +{ + int i; + if (ot_weight <= 0 || ot_weight > 1000) + return -1; + + for (i = 1; ot_weight > map[i].ot; i++) + ; + + if (ot_weight == map[i].ot) + return map[i].fc; + + /* Interpolate between two items. */ + return lerp (ot_weight, map[i-1].ot, map[i].ot, map[i-1].fc, map[i].fc); +} + +FcPublic int +FcWeightToOpenType (int fc_weight) +{ + int i; + if (fc_weight < 0 || fc_weight > FC_WEIGHT_EXTRABLACK) + return -1; + + for (i = 1; fc_weight > map[i].fc; i++) + ; + + if (fc_weight == map[i].fc) + return map[i].ot; + + /* Interpolate between two items. */ + return lerp (fc_weight, map[i-1].fc, map[i].fc, map[i-1].ot, map[i].ot); +} + +#define __fcweight__ +#include "fcaliastail.h" +#undef __fcweight__ diff --git a/fontconfig/src/fcwindows.h b/fontconfig/src/fcwindows.h index 02489d9dc..a0eee675e 100644 --- a/fontconfig/src/fcwindows.h +++ b/fontconfig/src/fcwindows.h @@ -32,8 +32,13 @@ #endif #ifdef _WIN32 + /* Request Windows Vista for building. This is required to + * get MemoryBarrier on mingw32... */ +# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 +# undef _WIN32_WINNT +# endif # ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0500 +# define _WIN32_WINNT 0x0600 # endif # define WIN32_LEAN_AND_MEAN # define WIN32_EXTRA_LEAN diff --git a/fontconfig/src/makefile b/fontconfig/src/makefile index 4ef9be83d..49f0fddef 100755 --- a/fontconfig/src/makefile +++ b/fontconfig/src/makefile @@ -39,6 +39,7 @@ CSRCS = \ fcserialize.c \ fcstat.c \ fcstr.c \ + fcweight.c \ fcxml.c \ ftglue.c |