Open
Bug 1221146
Opened 9 years ago
Updated 2 years ago
Fontconfig cannot match downloaded fonts anymore
Categories
(Core :: Graphics: Text, defect, P3)
Tracking
()
NEW
People
(Reporter: heftig, Unassigned)
References
(Depends on 1 open bug)
Details
(Whiteboard: [gfx-noted])
Attachments
(2 files)
1.31 KB,
text/plain
|
Details | |
1.36 KB,
patch
|
karlt
:
review-
|
Details | Diff | Splinter Review |
In release Firefox I am able to match downloaded fonts in Fontconfig (family containing `@font-face:` and no file) in order to adjust rendering parameters. In Dev Ed this is not the case anymore.
Disabling `gfx.font_rendering.fontconfig.fontlist.enabled` restores the expected behavior.
Comment 1•9 years ago
|
||
Jan, could you provide a snippet or the full text of the fontconfig conf file that you're using? That would help to try and reproduce the problem.
Blocks: 1056479
Updated•9 years ago
|
Flags: needinfo?(jan.steffens)
Comment 2•9 years ago
|
||
I used to use
<match target="font">
<test name="family" compare="contains">
<string>@font-face:</string>
</test>
</match>
but I think this works now:
<match target="font">
<test name="prgname">
<string>firefox</string>
</test>
<!-- no file name matches with |all| and means a downloaded font -->
<test name="file" qual="all">
<string>A STRING THAT IS NOT A FILENAME//</string>
</test>
</match>
Updated•9 years ago
|
Whiteboard: [gfx-noted]
Reporter | ||
Comment 3•9 years ago
|
||
Here's the font config file I was using, which attempts to use full hinting for most system fonts and slight hinting for downloaded TrueType fonts, as these are often handled poorly by FreeType's native, ClearType-style "subpixel" hinter.
Flags: needinfo?(jan.steffens)
Reporter | ||
Comment 4•9 years ago
|
||
I suppose for testing purposes you could use a config that disables anti-aliasing for downloaded fonts, which is highly visible:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "/etc/fonts/fonts.dtd">
<fontconfig>
<match target="font">
<edit name="file" mode="append"><string></string></edit>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
</match>
<match target="font">
<test name="family" compare="contains"><string>@font-face:</string></test>
<test name="file" qual="all" compare="not_contains"><string>/</string></test>
<edit name="antialias" mode="assign"><bool>false</bool></edit>
</match>
</fontconfig>
Comment 6•9 years ago
|
||
Starting with Firefox 44, fonts can no longer be replaced with fontconfig (Fedora Linux 23). For example, my ~/.config/fontconfig/fonts.conf contains this to replace a web-font named "Droid Sans" with "Arial":
<match target="pattern">
<test qual="any" name="family">
<string>@font-face:Droid Sans</string>
</test>
<edit name="family" mode="assign" binding="strong">
<string>Arial</string>
</edit>
</match>
It worked fine until Firefox 43 (official), but Firefox 44 (official) ignores this configuration.
Has this been changed intentionally in Firefox 44, or is this is bug?
Updated•9 years ago
|
Assignee: nobody → jd.bugzilla
Flags: needinfo?(jd.bugzilla)
Comment 7•9 years ago
|
||
This fixes the problem. I'm not adding this to src local webfonts as I think those are better considered as local fonts rather than ones downloaded for a page.
Attachment #8714677 -
Flags: review?(karlt)
Comment 8•9 years ago
|
||
(In reply to Andreas M. Kirchwitz from comment #6)
> Starting with Firefox 44, fonts can no longer be replaced with fontconfig
> (Fedora Linux 23). For example, my ~/.config/fontconfig/fonts.conf contains
> this to replace a web-font named "Droid Sans" with "Arial":
>
> <match target="pattern">
> <test qual="any" name="family">
> <string>@font-face:Droid Sans</string>
> </test>
> <edit name="family" mode="assign" binding="strong">
> <string>Arial</string>
> </edit>
> </match>
>
> It worked fine until Firefox 43 (official), but Firefox 44 (official)
> ignores this configuration.
>
> Has this been changed intentionally in Firefox 44, or is this is bug?
The patch adds the '@font-face:' prefix but I don't think it's going to fix the regression you're experiencing. The new code in Firefox 44 handles font selection internally. It uses fontconfig to look up platform family names but it won't allow substitutions to webfont font families like this.
We needed to make this change to handle the complex loading behavior associated with the unicode-range descriptor of @font-face rules.
Comment 9•9 years ago
|
||
Comment on attachment 8714677 [details] [diff] [review]
patch, prepend @font-face: to the font family name for webfonts
I think it would be better to do this after FcFreeTypeQueryFace() in the
constructor. That makes it is clear that mFontPattern is only ever used with
this family and saves recreating the family each time a gfxFont instance is
created. There's also no need then to check mIsDataUserFont.
A comment to explain this is added to the family would be helpful. Something
like:
// Adjust the family name so that fontconfig rules can easily distinguish
// between web fonts and platform fonts.
>+ NS_ConvertUTF16toUTF8 fam(mFamilyName);
>+ nsAutoCString patternFamily = NS_LITERAL_CSTRING("@font-face:") + fam;
I expect something like the following would save the buffer copy of fam and
convert directly into patternFamily:
nsAutoCString patternFamily = NS_LITERAL_CSTRING("@font-face:);
AppendUTF16toUTF8(mFamilyName, patternFamily);
>+ FcPatternDel(mFontPattern, FC_FAMILY);
>+ FcPatternAddString(mFontPattern, FC_FAMILY,
>+ ToFcChar8Ptr(patternFamily.get()));
This is deleting all the family names found in the font and replacing them
with a single family name based on mFamilyName. I assume mFamilyName is the
name in the @font-face rule? That's all fine I think, as that is what
gfxFontconfigFonts does. However, now the FC_FAMILYLANG entries from the font
don't necessarily correspond with FC_FAMILY from the @font-face family. I
guess perhaps FC_FAMILYLANG should be given a single entry corresponding to
the single family from the @font-face rule, but the old code simply removed
the FC_FAMILYLANG entries, so doing that should be fine too.
Attachment #8714677 -
Flags: review?(karlt) → review-
Comment 10•9 years ago
|
||
(In reply to Karl Tomlinson (ni?:karlt) from comment #9)
> A comment to explain this is added to the family would be helpful.
explain *why* ...
Comment 11•9 years ago
|
||
(In reply to Karl Tomlinson (ni?:karlt) from comment #9)
> Comment on attachment 8714677 [details] [diff] [review]
> patch, prepend @font-face: to the font family name for webfonts
>
> I think it would be better to do this after FcFreeTypeQueryFace() in the
> constructor. That makes it is clear that mFontPattern is only ever used with
> this family and saves recreating the family each time a gfxFont instance is
> created. There's also no need then to check mIsDataUserFont.
Yeah, I think I agree with you here. It's a bigger change because the current code sets the family name in gfxUserFontEntry::LoadPlatformFont after the constructor is called. But this would make sense to change.
I'll rework the interfaces to MakePlatformFont and LookupLocalFont so that the family name is set within the constructor. Then simplify the patch here.
Comment 12•9 years ago
|
||
(In reply to John Daggett (:jtd) from comment #8)
> (In reply to Andreas M. Kirchwitz from comment #6)
> > Starting with Firefox 44, fonts can no longer be replaced with fontconfig
> > (Fedora Linux 23). For example, my ~/.config/fontconfig/fonts.conf contains
> > this to replace a web-font named "Droid Sans" with "Arial":
> >
> > <match target="pattern">
> > <test qual="any" name="family">
> > <string>@font-face:Droid Sans</string>
> > </test>
> > <edit name="family" mode="assign" binding="strong">
> > <string>Arial</string>
> > </edit>
> > </match>
> >
> > It worked fine until Firefox 43 (official), but Firefox 44 (official)
> > ignores this configuration.
> >
> > Has this been changed intentionally in Firefox 44, or is this is bug?
>
> The patch adds the '@font-face:' prefix but I don't think it's going to fix
> the regression you're experiencing. The new code in Firefox 44 handles font
> selection internally. It uses fontconfig to look up platform family names
> but it won't allow substitutions to webfont font families like this.
>
> We needed to make this change to handle the complex loading behavior
> associated with the unicode-range descriptor of @font-face rules.
After reading the discussion on this bug and the related bug 1243194, but the parent post in particular, it became clear to me that the only way to reliably keep the control that I'm supposed to have (per the original WWW vision) was to disable webfonts entirely, with gfx.downloadable_fonts.enabled=false. The next step, after you take away _that_ setting, is browser.display.use_document_fonts=0; the next after that, give up Firefox.
So much for improving Firefox on Linux.
Comment 13•9 years ago
|
||
Modifying rendering parameters of downloaded fonts doesn't work at all for me anymore, even ignoring the "@font-face" matching issue. An example would be something like this:
<match target="font">
<test name="family" compare="contains">
<string>Neue</string>
</test>
<edit name="autohint">
<bool>true</bool>
</edit>
</match>
The match and edit work fine (confirmed with FC_DEBUG) but Firefox seems to not honor the autohint change. Without this, some fonts are near unreadable without the proper configuration. I can't figure out where the configuration they're using comes from, either. Even if I change my overall default in my fonts.conf to autohint true, the downloaded fonts in Firefox are still using autohint false (which is fontconfig's builtin default for that, I believe - maybe that's where it's coming from?)
Everything works fine after turning off "gfx.font_rendering.fontconfig.fontlist.enabled". Are there any alternate/long-term solutions? Besides disabling downloadable fonts.
Comment 14•9 years ago
|
||
My last comment can be disregarded. I was able to get back control of the rendering parameters on DL'ed fonts. The newer 44+ font behavior had an effect on some of the matches/edits I'm doing in my fonts.conf, and it was triggering some unexpected edits that were never triggered at all before. After re-working my fonts.conf, now I'm able to get the same behavior regardless of the setting of "gfx.font_rendering.fontconfig.fontlist.enabled".
Updated•7 years ago
|
Priority: -- → P3
Updated•6 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Updated•3 years ago
|
Assignee: jd.bugzilla → nobody
Status: ASSIGNED → NEW
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•