Bug 72380 - Never drop first font when trimming
Summary: Never drop first font when trimming
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: fontconfig-bugs
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-06 04:45 UTC by Behdad Esfahbod
Modified: 2013-12-10 02:22 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch (891 bytes, patch)
2013-12-10 00:51 UTC, Behdad Esfahbod
Details | Splinter Review

Description Behdad Esfahbod 2013-12-06 04:45:21 UTC
We always advertise that FcFontMatch() returns the first item from FcFontSort().  This isn't true if the first font in the sort list has no character coverage and trimming is enabled.  This happens with symbol.ttf since it has no usable cmap table.  We should fix this by never trimming the first font in the list.
Comment 1 Akira TAGOH 2013-12-09 10:43:00 UTC
(In reply to comment #0)
> We always advertise that FcFontMatch() returns the first item from
> FcFontSort().

How is FcFontMatch() is relevant to that? I think it do more with the intelligent way than FcFontSort() because it checks the language coverage for the first font in the list.

>               This isn't true if the first font in the sort list has no
> character coverage and trimming is enabled.  This happens with symbol.ttf
> since it has no usable cmap table.  We should fix this by never trimming the
> first font in the list.

I guess you are talking about FcFontSort() since FcFontMatch() doesn't have a feature to trim the list. so the suggestion may be to check the language coverage for the first font in the list as well as FcFontMatch() ?
Comment 2 Behdad Esfahbod 2013-12-10 00:39:34 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > We always advertise that FcFontMatch() returns the first item from
> > FcFontSort().
> 
> How is FcFontMatch() is relevant to that?

What I said.  We always advertise that FcFontMatch() returns the same font that is at the top of the list of FcFontSort().  Pango relies on that for example.  I believe Qt does too.


> I think it do more with the
> intelligent way than FcFontSort() because it checks the language coverage
> for the first font in the list.

Correct.


> >               This isn't true if the first font in the sort list has no
> > character coverage and trimming is enabled.  This happens with symbol.ttf
> > since it has no usable cmap table.  We should fix this by never trimming the
> > first font in the list.
> 
> I guess you are talking about FcFontSort() since FcFontMatch() doesn't have
> a feature to trim the list. so the suggestion may be to check the language
> coverage for the first font in the list as well as FcFontMatch() ?

No.  My suggestion is the other way around: to never trim the first font in FcFontSort().  I'll attach a patch.
Comment 3 Behdad Esfahbod 2013-12-10 00:51:37 UTC
Created attachment 90545 [details] [review]
Patch
Comment 4 Akira TAGOH 2013-12-10 01:51:46 UTC
(In reply to comment #2)
> What I said.  We always advertise that FcFontMatch() returns the same font
> that is at the top of the list of FcFontSort().  Pango relies on that for
> example.  I believe Qt does too.

Well, my question is "This isn't true if the first font in the sort list has no character coverage and trimming is enabled.". what does this "This" point to?
I saw your patch attached. but FcSortWalk() is called from FcFontSetSort() only which is called from FcFontSort() only. either functions are not involved with FcFontMatch() nor FcFontSetMatch(). it sounded to me like you were saying there are a problem in FcFontMatch() or so. so just got confused now.
Comment 5 Behdad Esfahbod 2013-12-10 01:55:44 UTC
Let me show it with an example.

Currently:

$ fc-match symbol
symbol.ttf: "Symbol" "Regular"

$ fc-match symbol --sort | head -n 1
Symbol.pfb: "Symbol" "Regular"

$ fc-match symbol --sort --all | head -n 1
symbol.ttf: "Symbol" "Regular"

I want to make sure the above three commands all return the same font.  Ie.  I want to make sure FcFontMatch() always returns the first font from FcFontSort().  You can say FcFontMatch() is buggy, or you can say FcFontSort() is buggy.  Doesn't matter.  We want the above to return the same font, and the easiest way to fix it is the patch I attached.
Comment 6 Akira TAGOH 2013-12-10 02:14:12 UTC
(In reply to comment #5)
> Let me show it with an example.
> 
> Currently:
> 
> $ fc-match symbol
> symbol.ttf: "Symbol" "Regular"
> 
> $ fc-match symbol --sort | head -n 1
> Symbol.pfb: "Symbol" "Regular"
> 
> $ fc-match symbol --sort --all | head -n 1
> symbol.ttf: "Symbol" "Regular"

Ah, got it. though fc-match --sort and/or --all doesn't use FcFontMatch() at all. that's why, but anyway.

> I want to make sure the above three commands all return the same font.  Ie. 
> I want to make sure FcFontMatch() always returns the first font from
> FcFontSort().  You can say FcFontMatch() is buggy, or you can say
> FcFontSort() is buggy.  Doesn't matter.  We want the above to return the
> same font, and the easiest way to fix it is the patch I attached.

agreed.
Comment 7 Behdad Esfahbod 2013-12-10 02:17:29 UTC
Good to go in?
Comment 8 Akira TAGOH 2013-12-10 02:18:39 UTC
Yes, please. thanks
Comment 9 Behdad Esfahbod 2013-12-10 02:22:59 UTC
commit fee834a9c9e1089a9ae29b1d8e8b6a4cc710204b
Author: Behdad Esfahbod <behdad@behdad.org>
Date:   Mon Dec 9 21:21:57 2013 -0500

    Bug 72380 - Never drop first font when trimming
    
    Let me show it with an example.
    
    Currently:
    
    $ fc-match symbol
    symbol.ttf: "Symbol" "Regular"
    
    $ fc-match symbol --sort | head -n 1
    Symbol.pfb: "Symbol" "Regular"
    
    $ fc-match symbol --sort --all | head -n 1
    symbol.ttf: "Symbol" "Regular"
    
    I want to make sure the above three commands all return the same font.
    Ie.  I want to make sure FcFontMatch() always returns the first font
    from FcFontSort().  As such, never trim first font.


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.