Comments (8)
Actually I think this was due to me using the font's ascender, descender, and line gap values rather than its hhea ascender, hhea descender, and hhea line gap! The documentation should really be clear about which to use.
I'm not certain I entirely like the results I'm getting using the capsize formulas; will follow up with my own for comparison.
from capsize.
Yeah, the results I get using my own formulas match capsize, now that I am feeding it the right metric values.
from capsize.
Sorry about the close. Reopening to deal with the documentation issue.
from capsize.
Thanks for digging into this. Glad you're finding the technique useful.
I am wanting to do a documentation and site uplift but just haven't had time to do it. I would suggest that documenting the internal metrics tables is not really something the Capsize documentation would do. Capsize deliberately tries to abstract that detail away where possible.
I based a lot of my work on this fantastic post: Deep dive CSS: font metrics, line-height and vertical-align by Vincent De Oliveira. This really helps identify which parts of the metrics the browse cares about when rendering.
Hope that helps.
from capsize.
I would suggest that documenting the internal metrics tables is not really something the Capsize documentation would do. Capsize deliberately tries to abstract that detail away where possible.
It also exposes APIs that take ascent, descent, and lineGap parameters. If I am trying to use this API, I'm going to dig up those values. If you open a font with FontLab you will find values with those labels prominently available in the "family dimensions" pane
when the ones you actually want for use with capsize are buried in "other values":
This just seems like a recipe for failure of other users. I had actually read the article by Mr. De Olivera and when I didn't see hhea in the metrics displayed by FontLab, I assumed that the software omitted that particular label. It was only on my 3rd re-reading of the article that it occurred to me to dig further to find the relevant values.
from capsize.
Yep agreed, from a Capsize perspective, the documentation failure is not about which tables to look at, rather how to use the suite of capsize packages to extract these values (without needing FontLab).
- The @capsizecss/unpack package does this for you and will extract the metrics from the font given a url or a file.
- The @capsizecss/metrics package does this for you and provides you with system metrics as well as google fonts, directly importable (and typed!)
I finally merged the site update this morning, which cross links with the github repo and also "Step 3"
on the site now highlights which packages to use based on your selection.
Hopefully you find this more interactive and helpful.
from capsize.
It's your prerogative to leave out these four characters if you want of course, but FWIW that doc update wouldn't have solved the problem for me. I have a proprietary font file that I can't upload. The code in “step 3” doesn't show me any reference to a filename; it's (still) completely non-obvious to me that digging into the "step 3" example is going to help me run the code on my font file.
On the other hand, I know there are ways to get the metrics of any font—just use a font editor and examine them—so I do that, and I look for the measurements whose names match your parameters…
Anyway, I'll stop arguing now, because I don't want to annoy you to the point where you don't want to answer this question. 😉
from capsize.
Ah sorry, for clarity the readme was also updated and in the fontMetrics documentation it points you to the correct metrics extraction package for your use case.
There are many consumers who wouldn't know about the internals of fonts, and Capsize does its best to abstract that away. In particular, with the new packages meaning you dont have to know about ascent
, descent
etc unless you have to customise the values due to incorrect data in the font tables.
PS Im not annoyed or arguing btw 😄 just providing clarity around decisions taken so far. I did miss the discussion topic though, i'll have a look.
from capsize.
Related Issues (20)
- Support for variable fonts HOT 5
- Text-overflow: ellipsis is not working HOT 2
- @capsizecss/metrics missing metrics HOT 3
- TailwindCSS Plugin
- Supporting rem as fontSize and lineheight HOT 4
- Latest version of `@capsizecss/metrics` doesn't generate font files HOT 4
- createFontStack returns incorrect values for fonts with the same metrics HOT 2
- Start error HOT 2
- Getting an error when using createTextStyle HOT 2
- capsize_capsizeStyle rules not being built in Remix projects HOT 4
- @capsizecss/unpack fontkit module import error HOT 4
- Font metrics covering all available font weights HOT 3
- Expose reference to Vanilla Extract CSS Variables HOT 1
- Some URLs are invalid for variable fonts from Google Fonts. No support of font variables in general. HOT 1
- Please add support for M PLUS Rounded 1c from Google Fonts HOT 3
- Horriable error in build and dev command nuxt 3 HOT 1
- Some combination of values don't wrap the full text height HOT 4
- `text-indent` not applied to Capsize elements HOT 1
- expose xHeight to metrics package HOT 3
- Return numeric values in precomputeValues HOT 4
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 capsize.