Closed
Bug 987582
Opened 11 years ago
Closed 11 years ago
compress many of the system fonts to reduce ROM size
Categories
(Firefox OS Graveyard :: GonkIntegration, defect)
Tracking
(blocking-b2g:1.3T+, b2g-v1.3T fixed, b2g-v2.0 fixed)
People
(Reporter: jfkthame, Assigned: jfkthame)
References
Details
Attachments
(4 files)
With the Gecko support from bug 987357, we can consider installing fonts in compressed (.woff) format instead of raw .ttf or .otf files. This could save us several megabytes in total.
We'll need to be alert for possible performance impact due to the need to decompress the fonts into RAM on first access. For this reason, I propose to initially try compressing a bunch of the fonts that are likely to be less-used (the serif family CharisSIL, and many non-Latin fonts).
Assignee | ||
Comment 1•11 years ago
|
||
This compresses many of the fonts from moztt. I omitted Fira for now, because (a) the .otf files are not as compressible as most .ttfs, so there's less to be gained, and (b) these are the fonts most likely to be used right away during startup, so any perf impact might be most noticeable.
We should also consider compressing many of the fonts from frameworks/base/data/fonts in the same way (we could get big gains on Chinese and Japanese), but I'm not sure how we manage those files.
Assignee: nobody → jfkthame
Attachment #8396275 -
Flags: review?(mwu)
Comment 2•11 years ago
|
||
Comment on attachment 8396275 [details] [review]
[PR] compress a bunch of lesser-used fonts
I would rather not compress fonts on devices that don't need it. How about creating a variable that lets us switch between installing the compressed and uncompressed fonts?
Attachment #8396275 -
Flags: review?(mwu)
Comment 3•11 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #1)
> We should also consider compressing many of the fonts from
> frameworks/base/data/fonts in the same way (we could get big gains on
> Chinese and Japanese), but I'm not sure how we manage those files.
Let's just fork and use our own copy in moztt if we want to change them. I think you can just remove the fallback font from the packages list and have it install normally through the copy files list.
Comment 4•11 years ago
|
||
I try this patch together with the patch in bug 987357 on v1.3t, but the charater can't be rendered correctly.
The language used is Bengali and tried both external/moztt/Noto/NotoSansBengali-Regular.woff and external/moztt/Lohit/lohit-bengali-ttf-2.5.3/Lohit-Bengali.woff.
Before, it does work correctly with external/moztt/Lohit/lohit-bengali-ttf-2.5.3/Lohit-Bengali.ttf.
Do we need to do more for useing .woff fonts?
Comment 5•11 years ago
|
||
(In reply to Kai-Zhen Li from comment #4)
> Do we need to do more for useing .woff fonts?
Oh, I think the 1.3 branch might not have freetype 2.5.2, which is required for woff support. https://bugzilla.mozilla.org/show_bug.cgi?id=966795 added woff support.
Comment 6•11 years ago
|
||
(In reply to Michael Wu [:mwu] from comment #5)
> (In reply to Kai-Zhen Li from comment #4)\
>
> Oh, I think the 1.3 branch might not have freetype 2.5.2, which is required
> for woff support. https://bugzilla.mozilla.org/show_bug.cgi?id=966795 added
> woff support.
Michael, Thanks!
Yes, in 1.3t freetype 2.5.0.2 is used. I follow bug 966795 and bug 985806 and back-port freetype 2.5.2 to v1.3t successfully, now the woff font can be rendered correctly.
Assignee | ||
Comment 7•11 years ago
|
||
Comment on attachment 8396275 [details] [review]
[PR] compress a bunch of lesser-used fonts
Updated the PR with a flag MOZ_PRODUCT_COMPRESS_FONTS that can be set to 'true' to request that a number of the MozTT fonts are shipped in .woff format; otherwise we keep them in the original .ttf form.
Is this the kind of thing you had in mind? It appears to behave as intended: if I include
MOZ_PRODUCT_COMPRESS_FONTS := true
in my device's main .mk file, I get the .woff files in the resulting image; and if not, I get .ttfs.
I didn't do anything with the fonts from frameworks/base/data yet, but if you think this is the right direction to be going, I'll follow up with that.
Attachment #8396275 -
Flags: review?(mwu)
Comment 8•11 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #7)
> Is this the kind of thing you had in mind? It appears to behave as intended:
> if I include
> MOZ_PRODUCT_COMPRESS_FONTS := true
> in my device's main .mk file, I get the .woff files in the resulting image;
> and if not, I get .ttfs.
>
Yup, this is what I had in mind. I suppose we could try to get more sophisticated about which fonts to compressed based on what the target market is, but this is more than good enough to start with.
BTW I had asked Kai-Zhen to experiment with backporting woff support to Tarako. The v1.3t branch is pretty different. It sounds like compressing fonts doesn't give us enough of a savings, but I'm not entirely sure what set of fonts were compressed.
Updated•11 years ago
|
Attachment #8396275 -
Flags: review?(mwu) → review+
Comment 9•11 years ago
|
||
With patch from attachment 8396275 [details] [review], on tarako when MOZ_PRODUCT_COMPRESS_FONTS=true, 6538752 Bytes can be saved in ROM.
I'll do a simple test on tarako to compare the difference of memory and cpu usage between with ttf and wit woff. Update the result later.
Comment 10•11 years ago
|
||
I did two tests to compare the differences of memory and cpu usage between with ttf and with woff fonts.
Test result: http://goo.gl/XYZMbV (There are significant differences in Browser's memory usage and CPU time.)
Details about the test:
Test 1 - ttf (using ttf fonts)
Test 2 - woff (all ttf fonts are replaced with woff fonts)
Test 1 and 2 are with the same steps:
- reboot phone
- after boot to homescreen, open browser, search bbc bengala and open a bengali news page
- back to homescreen, scroll left and right some times
- open browser again, browse another bengali news page
The following fonts under /system/bin, .ttf or .woff
CharisSILCompact-B.ttf
CharisSILCompact-BI.ttf
CharisSILCompact-I.ttf
CharisSILCompact-R.ttf
DroidSerif-Bold.ttf
DroidSerif-BoldItalic.ttf
DroidSerif-Italic.ttf
DroidSerif-Regular.ttf
FiraMonoOT-Bold.otf
FiraMonoOT-Regular.otf
FiraSansOT-Bold.otf
FiraSansOT-BoldItalic.otf
FiraSansOT-Light.otf
FiraSansOT-LightItalic.otf
FiraSansOT-Medium.otf
FiraSansOT-MediumItalic.otf
FiraSansOT-Regular.otf
FiraSansOT-RegularItalic.otf
Lohit-Bengali.ttf
Assignee | ||
Comment 11•11 years ago
|
||
(In reply to Michael Wu [:mwu] from comment #8)
> (In reply to Jonathan Kew (:jfkthame) from comment #7)
> > Is this the kind of thing you had in mind? It appears to behave as intended:
> > if I include
> > MOZ_PRODUCT_COMPRESS_FONTS := true
> > in my device's main .mk file, I get the .woff files in the resulting image;
> > and if not, I get .ttfs.
> >
>
> Yup, this is what I had in mind. I suppose we could try to get more
> sophisticated about which fonts to compressed based on what the target
> market is, but this is more than good enough to start with.
Right - e.g. if there's going to be a Bengali-specific tarako version that includes only the basic Fira/Droid fonts plus the Bengali font, I'd suggest leaving Bengali uncompressed in that build.
I've squashed the PR to a single commit for merging; marking checkin-needed.
We can follow up with a second bug to bring additional fonts such as Japanese from frameworks/base into moztt and handle them the same way.
> BTW I had asked Kai-Zhen to experiment with backporting woff support to
> Tarako. The v1.3t branch is pretty different. It sounds like compressing
> fonts doesn't give us enough of a savings, but I'm not entirely sure what
> set of fonts were compressed.
Comment 9 says that over 6MB was saved, which seems pretty significant to me, but I have no idea what the actual target or constraints are. I think that must have been an "all fonts included" build, as I'd only expect savings of around 4MB for the cut-down list of fonts in comment 10.
Keywords: checkin-needed
Comment 12•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
status-b2g-v2.0:
--- → fixed
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 1.5 S1 (9may)
Assignee | ||
Comment 13•11 years ago
|
||
I have not yet done a test build using this, so handle with care. :)
Attachment #8398651 -
Flags: review?(mwu)
Assignee | ||
Comment 14•11 years ago
|
||
Re-opening this bug to finish the job by compressing the Android fonts as well; see above.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 15•11 years ago
|
||
Comment on attachment 8398651 [details] [review]
[PR] followup to compress fonts we're using from Android
Looks good.
Since we're going to get rid of Roboto Real Soon Now, I guess there's no point in making it work. (though I'll have to make it work for Tarako)
Attachment #8398651 -
Flags: review?(mwu) → review+
Comment 16•11 years ago
|
||
BTW it looks like removing DroidSansFallback from the product packages list also removes the DroidSansEthiopic font on ICS. On JB, DroidSansEthiopic and DroidSansTamil are removed.
Assignee | ||
Comment 17•11 years ago
|
||
Huh, interesting. Well, we shouldn't really need DroidSansTamil, as we have Lohit (though this may affect which font people actually see when fallback kicks in), but I think we should restore DroidSansEthiopic - unless we decide to substitute a different Ethiopic font at some point, but that would be a separate decision.
Comment 18•11 years ago
|
||
Here's the v1.3t backport. Switching to compressed fonts saves about 11mb.
Comment 19•11 years ago
|
||
Requesting blocking for 11mb system image savings on tarako. See also bug 987357 comment 7 .
blocking-b2g: --- → 1.3T?
Updated•11 years ago
|
blocking-b2g: 1.3T? → 1.3T+
Comment 20•11 years ago
|
||
status-b2g-v1.3T:
--- → fixed
Assignee | ||
Comment 21•11 years ago
|
||
I've updated the PR to restore DroidSansEthiopic to the build (compressed, if that option is enabled). Re-flagging for r? with that change.
Assignee | ||
Updated•11 years ago
|
Attachment #8398651 -
Flags: review+ → review?(mwu)
Updated•11 years ago
|
Attachment #8398651 -
Flags: review?(mwu) → review+
Comment 22•11 years ago
|
||
11MB saved is nuts. Both of you deserve a medal.
Updated•11 years ago
|
Component: General → GonkIntegration
Assignee | ||
Comment 23•11 years ago
|
||
Re-setting checkin-needed for the second PR (https://github.com/mozilla-b2g/moztt/pull/35) to be merged on trunk.
Keywords: checkin-needed
Was there ever a conclusion on whether this means we're using malloc where we were using mmap before (bug 987357 comment 2)? Does that affect our ability to handle low-memory situations (in that we could page out an mmap, but not a malloc)?
Comment 25•11 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #13)
> Created attachment 8398651 [details] [review]
> [PR] followup to compress fonts we're using from Android
Master: https://github.com/mozilla-b2g/moztt/commit/a425b5eaf4949ab17a1670442fc2b17a82c84a74
Status: REOPENED → RESOLVED
Closed: 11 years ago → 11 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Comment 26•11 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM UTC-4] from comment #25)
> (In reply to Jonathan Kew (:jfkthame) from comment #13)
> > Created attachment 8398651 [details] [review]
> > [PR] followup to compress fonts we're using from Android
>
> Master:
> https://github.com/mozilla-b2g/moztt/commit/
> a425b5eaf4949ab17a1670442fc2b17a82c84a74
Ryan, do you mind uplifting that one to 1.3T ?
Flags: needinfo?(ryanvm)
Comment 27•11 years ago
|
||
Fabrice, I thin it is already in 1.3T.
https://github.com/mozilla-b2g/moztt/commit/228cc186b31ef99df5a015fff1b67f4392463f56
Comment 28•11 years ago
|
||
Doesn't cherry-pick cleanly, so I assume Kai-Zhen is correct. Otherwise, someone will need to resolve whatever conflicts there are.
Flags: needinfo?(ryanvm)
Comment 29•11 years ago
|
||
(In reply to Kai-Zhen Li from comment #27)
> Fabrice, I thin it is already in 1.3T.
> https://github.com/mozilla-b2g/moztt/commit/
> 228cc186b31ef99df5a015fff1b67f4392463f56
ok. Then please make sure to flag the bug correctly...
You need to log in
before you can comment on or make changes to this bug.
Description
•