Bug 107242 - Postscript name matching issues
Summary: Postscript name matching issues
Status: RESOLVED MOVED
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: 2018-07-16 10:21 UTC by Behdad Esfahbod
Modified: 2018-08-20 21:46 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.