Comments (9)
This happens because:
- The font has wrong bounding box info in the glyf table (ie, claims xmin=0 while it's clearly not the case),
- Reference implementation always throws away the bounding box. That has been a known issue. Ie, check sbbox_ in transform.cc; it's never set to true.
from woff2.
Interesting. This whole library is a bit over my head, or I would try to do a pull request (not even sure where to start).
By the way I think this is the only open source WOFF2 converter, so hopefully someone that runs into it can solve it.
from woff2.
There's also this:
fonttools/fonttools#222
I haven't merged it yet.
from woff2.
Setting sbox_
to true is not enough since the bounding box is already normalized (i.e. recalculated) at this point. To fix this one needs to drop NormalizeSimpleGlyphBoundingBox()
and instead use similar code in WriteSimpleGlyph()
to calculate the bounding box, compare it with the original and if it is different call WriteBbox()
. The sbbox_
as well as cbbox_
member variables should just be dropped.
from woff2.
Have you seen a conformance test that would cover this? If not, I suppose
we should add one.
On Fri, Apr 10, 2015 at 12:33 PM, Khaled Hosny [email protected]
wrote:
Setting sbox_ to true is not enough since the bounding box is already
normalized (i.e. recalculated) at this point. To fix this one needs to drop
NormalizeSimpleGlyphBoundingBox() and instead use similar code in
WriteSimpleGlyph() to calculate the bounding box, compare it with the
original and if it is different call WriteBbox(). The sbbox_ as well as
cbbox_ member variables should just be dropped.β
Reply to this email directly or view it on GitHub
#12 (comment).
from woff2.
Yes, there is http://dev.w3.org/webfonts/WOFF2/spec/#conform-mustCalculateOmitBBoxValues and http://dev.w3.org/webfonts/WOFF2/spec/#conform-mustHaveCompositeBBox.
from woff2.
Just for the record, an alternative, more filesize-friendly, way to fix it is: if the incoming bounding box of a glyph is wrong, fix it (ie. normalize it), but adjust the lsb in hmtx to offset the change, so the glyph doesn't shift.
from woff2.
But this would work only for this particular case, not for the general case of setting a bounding box different from what the font actually has.
(Playing with the bounding box is not something I have seen in the wild, but for a while I wanted to explore it in math fonts to control glyph stacking to be uniform for some glyphs that have different βnaturalβ bounding boxes, a trick used by some traditional TeX math fonts).
from woff2.
I just got around to testing the patch that @khaledhosny has suggested and it solves the issue for me.
Comparison vs Third Party
My test font has 1035 glyphs. This is an odd comparison obviously, but thought I would share it to illustrate that a third party tool does have a smaller size.
Broken | Patched | Third Party WOFF2 |
---|---|---|
53.0 KB (54,304 bytes) | 54.7 KB (56,072 bytes) | 53.8 KB (55,136 bytes) |
Generated from TTF | Generated from TTF | Generated from WOFF |
from woff2.
Related Issues (20)
- Build failed on Pop_os HOT 1
- Pre-compiled binaries for Windows? HOT 1
- Yahoo is now HOT 1
- How to I compile Windows x64 binaries either on Windows 10 or Ubuntu WSL2? HOT 4
- Silent woff2_decompress failure? HOT 7
- build a static link executable
- fix README.md for https://github.com/google/woff2/tree/master#build
- make woff2_compress less verbose
- Can't uninstall.
- Compres multiple .ttf HOT 4
- Google cc+
- command not found: woff2_compress HOT 1
- Compress glyf table generically if it fails specifically HOT 1
- Windows binary? HOT 3
- Parsing of the input font failed. HOT 4
- π₯ Windows Version
- Web version with progress bar support HOT 1
- Daniela's HOT 1
- Compressing a variable TTF to WOFF2 suffixes font name with lightest weight
- OSS-Fuzz issue 65939 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from woff2.