X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=635d10d5c3c2f9d2e5ea4641bddbe7e980f8b900;hp=dee94f94fda61ac94161bff4ea12dce7f8cd6587;hb=4454f6b665f2f14d0107a0144be947d95a252f8e;hpb=5e60b81690ac5883abe4f68b61814b8764604fd1 diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index dee94f9..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); @@ -627,6 +648,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) this->config_drawonlyshapes = 0; this->config_disable_polygon_conversion = 0; this->config_multiply = 1; + this->config_detectspaces = 1; this->config_linkdatafile = 0; this->page2page = 0; this->num_pages = 0; @@ -644,6 +666,8 @@ void GFXOutputDev::setParameter(const char*key, const char*value) this->config_transparent = atoi(value); } else if(!strcmp(key,"drawonlyshapes")) { this->config_drawonlyshapes = atoi(value); + } else if(!strcmp(key,"detectspaces")) { + this->config_detectspaces = atoi(value); } else if(!strcmp(key,"extrafontdata")) { this->config_extrafontdata = atoi(value); } else if(!strcmp(key,"linkdatafile")) { @@ -1453,7 +1477,7 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, (render == RENDER_INVISIBLE)) { int space = this->current_fontinfo->space_char; - if(config_extrafontdata && space>=0 && m.m00 && !m.m01) { + if(config_extrafontdata && config_detectspaces && space>=0 && m.m00 && !m.m01) { /* space char detection */ if(last_char_gfxfont == current_gfxfont && last_char_y == m.ty &&