Closed Bug 987357 Opened 10 years ago Closed 10 years ago

support system-installed fonts in .woff format on b2g/android devices

Categories

(Core :: Graphics: Text, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31
blocking-b2g 1.3T+
Tracking Status
b2g-v1.3T --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(1 file)

To reduce the size of the ROM image on B2G devices, we could consider storing the "system" fonts (in the /system/fonts/ directory) in compressed .woff format instead of raw .ttf or .otf.

This will reduce the total size of the CharisSILCompact fonts from 6.4MB to 2.1MB, for example; most other fonts also show substantial savings, often of the order of 50% (with the exception of AndroidColorEmoji, whose PNG glyphs cannot be compressed very much further).

FreeType now supports .woff fonts (by decompressing them to sfnt structures internally), so we could store the fonts as .woff in the filesystem to reduce our ROM footprint. (This is dependent on the FreeType 2.5.2 update we took in bug 966795.)

There may be some performance cost to this when a font is loaded for the first time (or perhaps re-loaded if it has been discarded from any caches, etc.), so we'll want to test on actual devices to check this is acceptable. It's possible that reducing the amount of data we need to load from the filesystem to instantiate a font will compensate, at least to some degree, for the added work of decompressing it.

If we can keep the fonts in compressed form, this may reduce pressure to omit certain fonts from the builds in order to save space (bug 985363).
This is the Gecko part: we just need to recognize .woff files when scanning the system fonts directory. The other part of this will be to .woff-compress the various font files in frameworks/base/data/fonts and external/moztt.
Attachment #8395933 - Flags: review?(roc)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
With the fonts in OTF format, they get mmapped directly from the filesystem right? Whereas now they'll have to be decompressed into RAM. So it seems like there's a performance hit here?

Maybe we can WOFF-ify just the "rarely used" fonts? Do you know what that list is?
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #2)
> With the fonts in OTF format, they get mmapped directly from the filesystem
> right? Whereas now they'll have to be decompressed into RAM. So it seems
> like there's a performance hit here?

Yes, that's most likely true. Whether it's a good trade-off is an open question, in my mind, but it seems worth investigating/experimenting.

> Maybe we can WOFF-ify just the "rarely used" fonts? Do you know what that
> list is?

It would depend on the locale. This would relate pretty closely to the discussion in bug 985363 about which fonts are needed in which locales.
Pushed this to inbound:
https://hg.mozilla.org/integration/mozilla-inbound/rev/7462bee51ec6

This enables Gecko support for .woff-compressed fonts, but doesn't actually change any of the font files we're shipping. Let's do that in separate followup bugs.
Blocks: 987582
https://hg.mozilla.org/mozilla-central/rev/7462bee51ec6
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
blocking-b2g: --- → 1.3T?
triage: ni? Thomas for evaluation
minus for now. if this is really going to benefit tarako, please renom
blocking-b2g: 1.3T? → -
Flags: needinfo?(ttsai)
Rerequesting blocking. With this, bug 987582, bug 966795, and bug 968626, we can save about 11mb in the system image.
blocking-b2g: - → 1.3T?
blocking-b2g: 1.3T? → 1.3T+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: