Postscript name matching issues
Submitted by Behdad Esfahbod
Assigned to fon..@..op.org
Link to original bug (#107242)
Description
Dominik and I are looking at postscriptname matching in Chrome, and I found a couple issues with it.
- 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...
Edited by Akira TAGOH