Closed davidgodzsak closed 3 years ago
This pull request introduces 1 alert when merging 209a8cd9042a7171df06cccbcdd2ae39a5aafb88 into 038bb25bcf9ccf0408bde708c4758674d7db5247 - view on LGTM.com
new alerts:
Merging #23 (38886cd) into master (038bb25) will increase coverage by
1.56%
. The diff coverage is75.00%
.
@@ Coverage Diff @@
## master #23 +/- ##
==========================================
+ Coverage 40.22% 41.79% +1.56%
==========================================
Files 4 4
Lines 445 457 +12
Branches 75 76 +1
==========================================
+ Hits 179 191 +12
Misses 263 263
Partials 3 3
Impacted Files | Coverage Δ | |
---|---|---|
lib/opentypesvg/fonts2svg.py | 33.75% <75.00%> (+5.37%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 038bb25...38886cd. Read the comment docs.
After some manual testing, I noticed that head.yMin
possibly denotes the bottom of the bounding box for a glyph and yMax
the top while in SVG it is the other way around, hence y = -head.yMax
.
I think you'll have to factor
head.yMin
somewhere because if the font has ahead.yMin
value grater than zero the glyphs won't be centered nor scaled as expected. I made these two edge-case fonts to help you test.
I already have them factored in the: height = head.yMax + abs(head.yMin)
. I think this is an solution for the y-up -y-down problem together with having -yMax as the top
@miguelsousa Ahh I think the problem is that the tables in ttf tell you information about the whole font and not the glyphs themselves. With this, the borders won't snuggle the glyph, they are living in a box where any glyph could fit from the font. I guess it's something like the "box" you see around a glyph in Glyphs3 or other font editing software (I'm not a font designer I am not familiar with the proper terminology, I just want to use this for an AI project to generate fonts).
If the desired effect is to snuggle the fonts then that has to be dynamically calculated for every glyph. I might be wrong tho in that case please correct me.
the tables in ttf tell you information about the whole font and not the glyphs themselves
Yes, the x/yMin/Max values in thehead
table define the combined bounding box of all glyphs in the font, not the bounding box of each individual glyph.
With this, the borders won't snuggle the glyph
Right, in a common font they likely won't because usually not all glyphs will have the same bounding box. But in the case of the test fonts, each of them has a single glyph, so the font's bbox will certainly match the glyph's. I did this to make it easy to validate the viewBox calculations.
If the desired effect is to snuggle the fonts then that has to be dynamically calculated for every glyph.
For me, the goal of the new -av
option is to make the tool output the SVGs with a viewBox that encloses all of the glyphs in the font. The viewBox value will be the same for all SVGs, and all the glyphs will be fully visible (as opposed to the default behavior which makes a "view window" of 1000x1000 edge-aligned at 0,0).
@miguelsousa I think I got it this time, thanks for all the help!
SVG ViewBox originally contained glyphs from the baseline, with a
-av
flag this can now be changed to also include the descender and lineGap.