diff options
author | marha <marha@users.sourceforge.net> | 2013-01-16 08:28:39 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-01-16 08:28:39 +0100 |
commit | 92bd40b3fc3830028340969f2cc5c6a0720c4450 (patch) | |
tree | 538a7f953afd9b5cf38e1a24e20b5be333053f92 /fontconfig/src/fcdefault.c | |
parent | 2fe4d492f39a5a5b67c4444805f7b1eaa1e745a9 (diff) | |
download | vcxsrv-92bd40b3fc3830028340969f2cc5c6a0720c4450.tar.gz vcxsrv-92bd40b3fc3830028340969f2cc5c6a0720c4450.tar.bz2 vcxsrv-92bd40b3fc3830028340969f2cc5c6a0720c4450.zip |
libxtrans fontconfig glproto libX11 libXau libXext libXft libXinerama
libXmu libfontenc mesa xkeyboard-config
libxtrans: d9f3728ff74ceb956f6cf8dc24b38611f9a4868a
fontconfig: ec5ca08c807585a9230f83c95f7cca6b7065b142
glproto: 8e3407e02980d088e20041e79bdcdd3737e7827e
libX11: f57fd760cba92ad846917f21e94e73e9c846185f
libXau: 1a8a1b2c68967b48c07b56142799b1020f017027
libXext: 8eee1236041d46a21faba32e0d27c26985267d89
libXft: c5e760a239afc62a1c75e0509868e35957c8df52
libXinerama: 470b9356af961ff7d3968b164aa73872b49a5dcc
libXmu: 474d22468c90f99104873b4c5fd7b0f0d2cbf823
libfontenc: 0c3518df24192f18f15ce91c2868560a5973a3dc
mesa: 3c00a52f7e02007f40fa53a06fad517bed0328ff
xkeyboard-config: 8a117fbd4a029b952afcfe362931628dccf496e4
Diffstat (limited to 'fontconfig/src/fcdefault.c')
-rw-r--r-- | fontconfig/src/fcdefault.c | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/fontconfig/src/fcdefault.c b/fontconfig/src/fcdefault.c index 6937994b7..aa47840d1 100644 --- a/fontconfig/src/fcdefault.c +++ b/fontconfig/src/fcdefault.c @@ -104,11 +104,81 @@ retry: return lang; } +static FcChar8 *default_prgname; + +FcChar8 * +FcGetPrgname (void) +{ + FcChar8 *prgname; +retry: + prgname = fc_atomic_ptr_get (&default_prgname); + if (!prgname) + { +#ifdef _WIN32 + char buf[MAX_PATH+1]; + + /* TODO This is ASCII-only; fix it. */ + if (GetModuleFileNameA (GetModuleHandle (NULL), buf, sizeof (buf) / sizeof (buf[0])) > 0) + { + char *p; + unsigned int len; + + p = strrchr (buf, '\\'); + if (p) + p++; + else + p = buf; + + len = strlen (p); + + if (len > 4 && 0 == strcmp (p + len - 4, ".exe")) + { + len -= 4; + buf[len] = '\0'; + } + + prgname = FcStrdup (p); + } +#else + char buf[8192]; + unsigned int len; + + len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1); + if (len > 0) + { + char *p; + + p = strrchr (buf, '/'); + if (p) + p++; + else + p = buf; + + prgname = FcStrdup (p); + } +#endif + + if (!prgname) + prgname = FcStrdup (""); + + if (!fc_atomic_ptr_cmpexch (&default_prgname, NULL, prgname)) { + free (prgname); + goto retry; + } + } + + if (prgname && !prgname[0]) + return NULL; + + return prgname; +} + void FcDefaultFini (void) { FcChar8 *lang; FcStrSet *langs; + FcChar8 *prgname; lang = fc_atomic_ptr_get (&default_lang); if (lang && fc_atomic_ptr_cmpexch (&default_lang, lang, NULL)) { @@ -120,6 +190,11 @@ FcDefaultFini (void) FcRefInit (&langs->ref, 1); FcStrSetDestroy (langs); } + + prgname = fc_atomic_ptr_get (&default_prgname); + if (prgname && fc_atomic_ptr_cmpexch (&default_prgname, prgname, NULL)) { + free (prgname); + } } void @@ -195,7 +270,7 @@ FcDefaultSubstitute (FcPattern *pattern) * exact matched "en" has higher score than ll-cc. */ v2.type = FcTypeString; - v2.u.s = FcStrdup ("en-us"); + v2.u.s = (FcChar8 *) "en-us"; if (FcPatternObjectGet (pattern, FC_FAMILYLANG_OBJECT, 0, &v) == FcResultNoMatch) { FcPatternObjectAdd (pattern, FC_FAMILYLANG_OBJECT, namelang, FcTrue); @@ -211,7 +286,13 @@ FcDefaultSubstitute (FcPattern *pattern) FcPatternObjectAdd (pattern, FC_FULLNAMELANG_OBJECT, namelang, FcTrue); FcPatternObjectAddWithBinding (pattern, FC_FULLNAMELANG_OBJECT, v2, FcValueBindingWeak, FcTrue); } - FcFree (v2.u.s); + + if (FcPatternObjectGet (pattern, FC_PRGNAME_OBJECT, 0, &v) == FcResultNoMatch) + { + FcChar8 *prgname = FcGetPrgname (); + if (prgname) + FcPatternObjectAddString (pattern, FC_PRGNAME_OBJECT, prgname); + } } #define __fcdefault__ #include "fcaliastail.h" |