X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=635d10d5c3c2f9d2e5ea4641bddbe7e980f8b900;hp=11490886866293e4d6c3b32da397af3c96f4a646;hb=4454f6b665f2f14d0107a0144be947d95a252f8e;hpb=df99e9de2273822d54a2efa8d02a08e90181ede1 diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 1149088..635d10d 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -371,6 +371,11 @@ static char fc_ismatch(FcPattern*match, char*family, char*style) } #endif +static inline char islowercase(char c) +{ + return (c>='a' && c<='z'); +} + char* fontconfig_searchForFont(char*name) { #ifdef HAVE_FONTCONFIG @@ -468,20 +473,36 @@ char* fontconfig_searchForFont(char*name) } char*family = strdup(name); - char*style = 0; - char*dash = strchr(family, '-'); - if(!dash) dash = strchr(family, ','); + int len = strlen(family); + char*styles[] = {"Medium", "Regular", "Bold", "Italic", "Black", "Narrow"}; + char*style = 0; + int t; + for(t=0;tl+1 && !strcmp(family+len-l, styles[t]) && islowercase(family[len-l-1])) { + style = styles[t]; + family[len-l]=0; + break; + } + } + if(!style) { + char*dash = strchr(family, '-'); + if(!dash) dash = strchr(family, ','); + if(dash) { + *dash = 0; + style = dash+1; + } + } FcPattern*pattern = 0; - if(dash) { - *dash = 0; - style = dash+1; + if(style) { msg(" FontConfig: Looking for font %s (family=%s style=%s)", name, family, style); pattern = FcPatternBuild(NULL, FC_OUTLINE, FcTypeBool, FcTrue, FC_SCALABLE, FcTypeBool, FcTrue, FC_FAMILY, FcTypeString, family, FC_STYLE, FcTypeString, style, NULL); } else { msg(" FontConfig: Looking for font %s (family=%s)", name, family); pattern = FcPatternBuild(NULL, FC_OUTLINE, FcTypeBool, FcTrue, FC_SCALABLE, FcTypeBool, FcTrue, FC_FAMILY, FcTypeString, family, NULL); } + pattern = FcPatternBuild(NULL, FC_OUTLINE, FcTypeBool, FcTrue, FC_SCALABLE, FcTypeBool, FcTrue, FC_FAMILY, FcTypeString, family, NULL); FcResult result; FcConfigSubstitute(0, pattern, FcMatchPattern);