Summary: | fontconfing 2.13 makes bold font when it's not expected to | ||
---|---|---|---|
Product: | fontconfig | Reporter: | Jan Palus <jpalus> |
Component: | library | Assignee: | fontconfig-bugs |
Status: | RESOLVED FIXED | QA Contact: | Behdad Esfahbod <freedesktop> |
Severity: | normal | ||
Priority: | medium | CC: | akira, freedesktop, tomi, ulm |
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
another patch
another try proposed patch |
Description
Jan Palus
2018-03-09 11:45:46 UTC
(In reply to Jan Palus from comment #0) > * xft:Input Mono Narrow-10:weight=medium (urxvt does not start as fontconfig > fails to parse font spec) What exactly errors did the application show you? that looks valid to me. Also try fc-match "Input Mono Narrow-10" and "Input Mono Narrow-10:weight=medium" too maybe. > > Is there anything I am missing? $ fc-match "Input Mono Narrow-10" InputMonoNarrow-Regular.ttf: "Input Mono Narrow" "Regular" $ fc-match "Input Mono Narrow-10:weight=medium" Unable to parse the pattern Note that it works fine with fontconfig 2.12.6: $ fc-match "Input Mono Narrow-10:weight=medium" InputMonoNarrow-Medium.ttf: "Input Mono Narrow" "Medium" Looks like "Unable to parse the pattern" came with: commit d3a7c3ce697a8ceb8042bf5bea11c38ac8990553 Author: Behdad Esfahbod <behdad@behdad.org> Date: Wed Sep 13 03:31:48 2017 -0400 [varfonts] Change FC_WEIGHT and FC_WIDTH into ranges Changing invocation at least gives some result: $ fc-match 'Input Mono Narrow-10:weight<=medium' InputMonoNarrow-Regular.ttf: "Input Mono Narrow" "Regular" but it still has no influence on rxvt-unicode bold font. As far as I can tell above result is also different than the one in 2.12.6 "Regular" vs "Medium" Hm, thanks. well, there are no syntax to set the range in constant names. you have to set like this to obtain the font with the weight medium anyway: fc-match "Input Mono Narrow-10:weight=[100 100]" For backward compatibility: diff --git a/src/fcname.c b/src/fcname.c index 79e413e..b9933df 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -293,6 +293,7 @@ FcNameConvert (FcType type, FcChar8 *string) FcMatrix m; double b, e; char *p; + int i; v.type = type; switch ((int) v.type) { @@ -330,13 +331,18 @@ FcNameConvert (FcType type, FcChar8 *string) case FcTypeRange: if (sscanf ((char *) string, "[%lg %lg]", &b, &e) != 2) { - v.u.d = strtod ((char *) string, &p); - if (p != NULL && p[0] != 0) + if (FcNameConstant(string, &i)) { - v.type = FcTypeVoid; - break; + v.u.r = FcRangeCreateDouble (i, i); + } else { + v.u.d = strtod ((char *) string, &p); + if (p != NULL && p[0] != 0) + { + v.type = FcTypeVoid; + break; + } + v.type = FcTypeDouble; } - v.type = FcTypeDouble; } else v.u.r = FcRangeCreateDouble (b, e); $ ./build/fc-pattern/fc-pattern "Input Mono Narrow-10:weight=medium" Pattern has 3 elts (size 16) family: "Input Mono Narrow"(s) weight: [100 100](s) size: 10(f)(s) Created attachment 137956 [details] [review] another patch patch to support the ranges of constant names. $ ./build/fc-pattern/fc-pattern "Input Mono Narrow-10:weight=[medium bold]" Pattern has 3 elts (size 16) family: "Input Mono Narrow"(s) weight: [100 200](s) size: 10(f)(s) Created attachment 137957 [details] [review] another try non-range constant name should be converted to double: $ ./build/fc-pattern/fc-pattern "Input Mono Narrow-10:weight=medium" Pattern has 3 elts (size 16) family: "Input Mono Narrow"(s) weight: 100(f)(s) size: 10(f)(s) $ ./build/fc-pattern/fc-pattern "Input Mono Narrow-10:weight=[medium bold]" Pattern has 3 elts (size 16) family: "Input Mono Narrow"(s) weight: [100 200](s) size: 10(f)(s) Created attachment 137958 [details] [review] proposed patch fixed leak in the previous patch Thanks. fontconfig with the patch seems to work fine for me. Thanks Akira. Lgtm. Fixed in git. thanks. Not sure if that's a valid syntax but there's still a slight difference in behavior between 2.12.6 and patched 2.13.0: # 2.12.6 $ fc-match 'Input Mono Narrow-10:medium' InputMonoNarrow-Medium.ttf: "Input Mono Narrow" "Medium" # 2.13.0 $ fc-match 'Input Mono Narrow-10:medium' InputMonoNarrow-Regular.ttf: "Input Mono Narrow" "Regular" so "medium" is ignored if not passed explicitly with attribute name "weight=medium" (In reply to Jan Palus from comment #13) > Not sure if that's a valid syntax but there's still a slight difference in > behavior between 2.12.6 and patched 2.13.0: > > # 2.12.6 > $ fc-match 'Input Mono Narrow-10:medium' > InputMonoNarrow-Medium.ttf: "Input Mono Narrow" "Medium" > > # 2.13.0 > $ fc-match 'Input Mono Narrow-10:medium' > InputMonoNarrow-Regular.ttf: "Input Mono Narrow" "Regular" > > so "medium" is ignored if not passed explicitly with attribute name > "weight=medium" I see this too: $ fc-match 'Droid Sans-10:bold' # 2.12.6 DroidSans-Bold.ttf: "Droid Sans" "Bold" $ fc-match 'Droid Sans-10:bold' # 2.13.0 (with or without patch) DroidSans.ttf: "Droid Sans" "Regular" User documentation explictly mentions examples like 'Times-12:bold' so I believe that the above syntax should work. https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#AEN36 Reopening. (In reply to Jan Palus from comment #13) > Not sure if that's a valid syntax but there's still a slight difference in > behavior between 2.12.6 and patched 2.13.0: Yes, that is a valid syntax. fixed in git. $ ./build/fc-pattern/fc-pattern :normal:bold Pattern has 2 elts (size 16) weight: 200(i)(s) width: 100(i)(s) |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.