Comments (6)
OK, an experiment does seem to show that they are the actual font metrics on a character-by-character basis, and that they use decimal parts of a pixel rather than full pixels. So that does seem useful, and worth looking into.
from mathjax-src.
Currently, there is no API for javascript to get the glyph metrics for a browser font (though there are some proposals for that). So MathJax has the needed data for the characters in its fonts stored in data files that it loads as part of the font data. That is one reason that MathJax only handles specific fonts (one right now, but more on the way later this summer). See the common/fonts files for the base information. The CHTML and SVG output jax add more information that is specific to that output format. The SVG output doesn't actually use fonts, but rather paths generated from the fonts, so svg/fonts adds all the path information into the font data.
from mathjax-src.
Thanks, that’s exactly what I was looking for.
from mathjax-src.
As a follow-up on that: what about the TextMetrics
object the Canvas API provides with measureText()
? It seems like it's widely supported and provides actualBoundingBoxAscent
and actualBoundingBoxDescent
.
from mathjax-src.
@paeifbnaeufbpae, that is a nice idea, but the values seem to be in CSS pixels, while MathJax needs sub-pixel accuracy in order to do the layout properly. Also, I suspect that actualBoundingBoxAscent
and actualBoundingBoxDescent` are the ascent and decent values of the font being used, which is the same for all characters in the font, but MathJax needs the character-by-character height and depth information for each glyph, not the font-wide ascent and descent. I haven't checked this, but that is what the documentation and the names of these value seem to imply (it is not entirely clear).
from mathjax-src.
@paeifbnaeufbpae, that is a nice idea, but the values seem to be in CSS pixels, while MathJax needs sub-pixel accuracy in order to do the layout properly. Also, I suspect that
actualBoundingBoxAscent
and actualBoundingBoxDescent` are the ascent and decent values of the font being used, which is the same for all characters in the font, but MathJax needs the character-by-character height and depth information for each glyph, not the font-wide ascent and descent. I haven't checked this, but that is what the documentation and the names of these value seem to imply (it is not entirely clear).
Hm... I suspect that you could just artificially scale the text up by 1 / precision
(with precision
being 1e-3 or something) to get the equivalent of sub-pixel accuracy?
And given that you first need to call the measureText
function and pass in a specific string to measure to even get a FontMetrics
object, I'd think it does indeed return the text-specific ascent/descent values. (Of course, one would have to measure single characters then and not larger runs of text.)
I guess a quick experiment would answer this question.
from mathjax-src.
Related Issues (20)
- Upgrading from alpha 1 to latest beta, Fira font-config HOT 4
- algebra manipulation tool HOT 3
- "ReferenceError: window is not defined" when dev page reloaded. HOT 1
- Multiple Typescript Errors HOT 9
- delete arguments.callee HOT 2
- support for \oiint and \oiiint HOT 1
- v4: DefaultFont.js not CJS HOT 2
- how do i customize the the latex defined by myself, and change it to mathml defined by myself HOT 1
- Overlapping output when using serveral expressions on the same page HOT 3
- SVG StyleList unused styles? HOT 3
- Reverse process HOT 1
- Integrate better tooling infra into mathjax
- ES6 class keyword used in "ES5" code due to bundled speech-rule-engine dependency HOT 6
- use mathjax3 in andriod5 show error "getExplicit of null" HOT 1
- Build directions don't work for v4-update branch HOT 3
- MathJax-Fonts repository private HOT 9
- Can I use a custom font in version 3.2?
- ts/util/asyncLoad/node.js needs ESM version HOT 15
- installation of v4 not working with yarn 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 mathjax-src.