Bug 107242

Summary: Postscript name matching issues
Product: fontconfig Reporter: Behdad Esfahbod <freedesktop>
Component: libraryAssignee: fontconfig-bugs
Status: RESOLVED MOVED QA Contact: Behdad Esfahbod <freedesktop>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Behdad Esfahbod 2018-07-16 10:21:00 UTC
Dominik and I are looking at postscriptname matching in Chrome, and I found a couple issues with it.

1. The code seems to want to ignore space and dash as delimiters:

""static double 
FcComparePostScript (const FcValue *v1, const FcValue *v2, FcValue *bestValue) 
{ 
    const FcChar8 *v1_string = FcValueString (v1); 
    const FcChar8 *v2_string = FcValueString (v2); 
    int n; 
    size_t len; 
 
    *bestValue = FcValueCanonicalize (v2); 
 
    if (FcToLower (*v1_string) != FcToLower (*v2_string) && 
↦       *v1_string != ' ' && *v2_string != ' ') 
↦       return 1.0; 
 
    n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -"); 
    len = strlen ((const char *)v1_string); 
 
    return (double)(len - n) / (double)len; 
} 
""

But in actual testing I don't see dash ignored.  NOT ignoring dash is actually correct and desired behavior.  I just don't understand why it's not ignored by the code currently.

Inside FcStrCaseWalkerNext(), delims are not checked when fulfilling request from w->read:

""
static FcChar8 
FcStrCaseWalkerNext (FcCaseWalker *w, const char *delims) 
{ 
    FcChar8↦    r; 
 
    if (w->read) 
    { 
↦       if ((r = *w->read++)) 
↦           return r; 
↦       w->read = 0; 
    } 
    do 
    { 
↦       r = *w->src++; 
    } while (r != 0 && delims && strchr (delims, r)); 
 
    if ((r & 0xc0) == 0xc0) 
↦       return FcStrCaseWalkerLong (w, r); 
    if ('A' <= r && r <= 'Z') 
        r = r - 'A' + 'a'; 
    return r; 
} 
""

Ie, "if ((r = *w->read++))" needs to also check delims...
Comment 1 GitLab Migration User 2018-08-20 21:46:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/46.

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.