Bug 19128

Summary: Handling whitespace in aliases
Product: fontconfig Reporter: Behdad Esfahbod <freedesktop>
Component: confAssignee: Akira TAGOH <akira>
Status: RESOLVED FIXED QA Contact: Behdad Esfahbod <freedesktop>
Severity: normal    
Priority: medium CC: akira, bugs.freedesktop, cloos, dirtyepic, eric225125, fontconfig-bugs, freedesktop, hib, martin, mcepl, pva, vuntz
Version: 2.4   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Behdad Esfahbod 2008-12-16 22:44:28 UTC
Add:

        <alias binding="same">
          <family>ZapfDingbats</family>
          <accept><family>Dingbats</family></accept>
        </alias>

This fixes bugs with viewing some PDF files that do not include the font...
See:
https://bugzilla.redhat.com/show_bug.cgi?id=468565
http://bugzilla.gnome.org/show_bug.cgi?id=502664
Comment 1 James Cloos 2008-12-17 03:30:11 UTC
This is an example of the more general issue that <alias>s are matched
to patterns' <fontname>s literally, but actual fonts' names are matched
with whitespace ignored.

Ie, if the font is installed, these:

	:; fc-match DejaVuSansMono
	:; fc-match 'DejaVu Sans Mono'

give the same result.  But to use aliases you need to have all
possibilities accounted for in the conf.

It is also related to the issue that libs like poppler pass PS names to
fontconfig whereas fontconfig caches the full names.  (For Type1 fc
caches the /FullName, poppler passes the /FontName; for sfnts poppler
passes the TT_NAME_ID_PS_NAME, which fc explicitly ignores:

	#if 0       
	                case TT_NAME_ID_PS_NAME:
	                case TT_NAME_ID_UNIQUE_ID:
	#endif

)
Comment 2 Behdad Esfahbod 2008-12-17 11:41:09 UTC
Ah I see.  Good point.
Comment 3 Behdad Esfahbod 2008-12-28 13:14:48 UTC
We prolly need a new comparison operator for the config file that compares ignoring case and blanks.  Then we can update all the config files to use that.
Comment 4 Karl Tomlinson 2009-01-01 12:42:29 UTC
(In reply to comment #3)
> We prolly need a new comparison operator for the config file that compares
> ignoring case and blanks.  Then we can update all the config files to use that.

That may be one issue, but isn't necessary going to help with PS-names.
e.g. NimbusSansL-Regu is never going to match a full name or family name.
PS-names and family names are really quite different.  
Comment 5 Behdad Esfahbod 2009-01-01 14:09:34 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > We prolly need a new comparison operator for the config file that compares
> > ignoring case and blanks.  Then we can update all the config files to use that.
> 
> That may be one issue, but isn't necessary going to help with PS-names.
> e.g. NimbusSansL-Regu is never going to match a full name or family name.
> PS-names and family names are really quite different.  

Right.  PS-names are a different issue and that's bug 18095.  Retitling again.
Comment 6 Behdad Esfahbod 2009-02-03 13:50:46 UTC
Note that fc-list also doesn't ignore whitespace when matching.
Comment 7 Behdad Esfahbod 2009-08-05 07:57:22 UTC
*** Bug 23152 has been marked as a duplicate of this bug. ***
Comment 8 Eric Smith 2010-02-19 04:01:40 UTC
The problem with the ZapfDingbats alias is still present in fontconfig-2.8.
Comment 9 Ryan Hill 2010-04-10 18:33:02 UTC
If the larger issue of whitespace isn't going to be addressed soon can we add the ZapfDingbats bit in the meantime?
Comment 10 James Cloos 2010-04-21 11:06:57 UTC
Does anyone have any comments on the proposed patch I posted to the mailing list a couple of weeks ago (<m3r5mwt1wj.fsf@lugabout.jhcloos.org> and its followup)?
Comment 11 Akira TAGOH 2012-03-07 01:23:34 UTC
(In reply to comment #10)
> Does anyone have any comments on the proposed patch I posted to the mailing
> list a couple of weeks ago (<m3r5mwt1wj.fsf@lugabout.jhcloos.org> and its
> followup)?

I've decided to include a workaround patch for this issue so far because I want to give priority releasing new version since there hasn't seen for awhile. I'll have a look at your patch once new release is out.
Comment 12 Akira TAGOH 2012-03-13 02:50:17 UTC
(In reply to comment #10)
> Does anyone have any comments on the proposed patch I posted to the mailing
> list a couple of weeks ago (<m3r5mwt1wj.fsf@lugabout.jhcloos.org> and its
> followup)?

Well, that might be good start to work on Bug#18095 though, I'm not sure how it helps for this since this is to handle the white spaces in the family name on alias.

(In reply to comment #3)
> We prolly need a new comparison operator for the config file that compares
> ignoring case and blanks.  Then we can update all the config files to use that.

I'd vote this idea. we could force using FcStrCmpIgnoreBlanksAndCase() for family but is there any cases one strictly needs to check the white spaces in the string? otherwise can we simply use it for string too?
Comment 13 Akira TAGOH 2012-03-30 01:50:43 UTC
the proposed fixes for this:
http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz19128

I guess there may be the better operator name though. please test it. hope I'm not missing anything else. thanks.
Comment 14 Akira TAGOH 2012-04-09 21:08:31 UTC
FcStrCmpIgnoreBlanksAndCase() ignores the blanks in any places anyway. so that will says "Co urier" and "C o u r i e r" is same. should we just skips the blanks when the next character is only capitalized?
Comment 15 Behdad Esfahbod 2012-04-10 10:27:44 UTC
Not really sure.  Lets go for less complexity.
Comment 16 Akira TAGOH 2012-04-10 18:39:17 UTC
Okay. we can fix it later as needed.
Comment 17 Akira TAGOH 2012-04-10 19:10:19 UTC
I still wonder if "eq_case_blanks" is really better name for operator. there are another idea when I thought of. it is to make the case-sensitivity and ignoring blanks optional.

  <test name="family" compare="eq" case-sensitivity="false" ignore-blanks="true">
    ...
  </test>

the concern is, it's only effective for string. but that may be ok since fontconfig implicitly adjusts the behavior against the operator in even current implementation. e.g. FcOpContains and FcOpListing is equal to FcOpEqual for integer and float.
Comment 18 Akira TAGOH 2012-04-10 19:18:49 UTC
and it would be capable to add another rule for skip blanks like:
  <test name="family" ignore-blanks="only_when_capitalized">

not sure if we really want to do that in the future, but maybe good to have scalability in its syntax.

another advantage on this idea would be compatibility with the older release. it behaves differently but still can share them.
Comment 19 Akira TAGOH 2012-05-08 04:10:39 UTC
another try:
http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz19128-2

That looks better now. any volunteers for testing are welcome.
Comment 20 Akira TAGOH 2012-05-13 20:11:01 UTC
Merged into master.

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.