Comments (14)
Because I know how to have fun on New Years Eve I decided to try to put together a fix.
This commit in my fork fixes the issue for all fonts I tested: kettle11@3dce741
The way it works is for each glyph it calculates and keeps track of the winding direction of the left most path (is path the correct term?).
If the left most path wraps counter-clockwise, then the glyph's points are reversed, otherwise they are not.
This is not a perfect solution. It will produce incorrect results if a path intended to be subtractive is left of a path intended to be solid. But it seems most fonts use subtractive (counter-clockwise) paths to represent holes on the interior of as solid area.
Likely it introduces a small performance hit, but I have not tested that yet.
I also have not rigorously tested this with a wide array of fonts, but it seems promising for the few I did test.
from fontdue.
It's not that I'm assuming the wrong ordering, it's that the font is actually out of spec. Font engines like FreeType do a very expensive operation to check the winding order if it produces a blank output. I'm considering doing this on startup for fontdue
from fontdue.
I downloaded Inconsolata from your link and was not able to reproduce the issue with Inconsolata-VariableFont_wdth,wght.ttf or Inconsolata-Regular.ttf.
That's weird as the font file I am seeing this issue is static\Inconsolata-Regular.ttf
in the download.
This commit in my fork fixes the issue for all fonts I tested
Just tested your changes and I can confirm that this also fixes Inconsolata font issue with )
glyph I described above.
from fontdue.
Seeing the same symptoms with iosevka-regular.ttf
- correct metrics, but the image is a big ol' bucket of 0
. I'll have a go with kettle's fix and see what happens.
Update: the fix works; suddenly I have glyphs!
from fontdue.
I'll use a heuristic to guess the winding order of the glyph on startup. Should be in the spirit of what Kettle11 did
from fontdue.
Adding some investigation:
For HelveticaNeue.ttc
the 'a' character appears, but the rest appear to be wrapping the opposite direction.
For NewYork.ttf
fontdue
is assuming the wrong wrapping direction and if the wrapping is reversed then the font appears for all characters I tested.
from fontdue.
I assume this is related to this issue somehow: RazrFalcon/ttf-parser#43
from fontdue.
Oh no. I assumed such mainstream fonts would be in spec.
One thing I noticed is that I could take the absolute value of the produced float to get a reasonable looking result, but I assume that’s a bad idea for some reason?
from fontdue.
I have some fonts where that doesn't work :( , some transform operations specified in the font can also result in bad winding orders. Browser grade (chromium) handling of this is actually just guess and check.
from fontdue.
Inter (a very popular font) also has this issue.
'q' appears to be a reflection of 'p' so it rasterizes blank.
Edit: I couldn't actually replicate this with the newest version of Inter
.
I checked and I was using this old version: https://github.com/rsms/inter/releases/tag/v3.13
with Inter-3-2/Inter Hinted for Windows/Desktop/Inter-Regular.ttf
The issue still replicates for the old version, but I wonder why they changed it in the newer versions?
from fontdue.
Just hit the same issue with Inconsolata font. In particular )
glyph is rasterized with width/height but the bitmap is all empty bytes (0s).
from fontdue.
@simast I downloaded Inconsolata from your link and was not able to reproduce the issue with Inconsolata-VariableFont_wdth,wght.ttf
or Inconsolata-Regular.ttf
.
Are you using another .ttf?
from fontdue.
This probably works cb2e9b2. Can anyone confirm they still have the issue with this fix?
I tested these characters real quick on a few fonts and they worked correctly
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u,
v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, !,
@, #, $, %, ^, &, *, (, ), _, +, -, =, `, ~, [, ], \\, ;, \,
,, ., /, {, }, |, :, ", <, >, ?, «, ¼, ½, ¾, ¿, »,
Roboto-Regular.ttf
RobotoMono-Regular.ttf
Comfortaa-Regular.ttf
Inconsolata-Regular.ttf
Exo2-Regular.otf
from fontdue.
I decided to make a more robust test, so I am now testing all glyphs in the following fonts:
Roboto-Regular.ttf
RobotoMono-Regular.ttf
Comfortaa-Regular.ttf
Inconsolata-Regular.ttf
FasterOne-Regular.ttf
Exo2-Regular.otf
GreatVibes-Regular.otf
modernpics.otf
I found an issue in my original heuristic so I decided to just do it right the second time and added some heavier math to actually calculate the winding right.
from fontdue.
Related Issues (20)
- C interface HOT 6
- Fonts with variable weight? HOT 2
- Adding an example for calculating the bounding box HOT 8
- can fontdue rasterize with fractional pixel offsets? HOT 5
- SDF texture generation HOT 1
- Ligature support- pairing with other libraries
- Rasterize a whole string HOT 3
- Glyph metrics are incorrect HOT 1
- Font line metrics don't match character metrics
- Png Support HOT 1
- How to rasterize colored emojis HOT 1
- Can you add an example of how to create a simple letter and save as a font? HOT 1
- Option to drop the rest of a line instead of wrapping HOT 2
- Bounding box of laid out text for easy shiftnig of the origin?
- Misaligned pointer dereference in `get_bitmap` HOT 4
- Custom font colors HOT 1
- Live demo error when a glagolitic character ( Ⱆ ) is used HOT 3
- 0.7.4 is a semver break HOT 3
- Slight layout performance regression
- No ability to query font for its name HOT 3
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 fontdue.