-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
Fix @ylemkimon's issues reported in KaTeX#41 (comment)
width = glyph.xMax - glyph.xMin | ||
height = glyph.yMax / unitsPerEm | ||
depth = -glyph.yMin / unitsPerEm | ||
width = widths[name].width / unitsPerEm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get width by glyph.width
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I tried that, and it wasn't defined. Unless I somehow have the wrong version installed? I did it pretty recently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edemaine Ah, sorry, I was looking at the fontforge
Python API.
depth = -glyph.yMin | ||
width = glyph.xMax - glyph.xMin | ||
height = glyph.yMax / unitsPerEm | ||
depth = -glyph.yMin / unitsPerEm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During refactoring the generation scripts of fonts and their metrics, I discovered that yMax
and yMin
from generated TTF
does not match height
and depth
from tfm
(TeX font metrics).
Are their definitions different? Or, do they change during conversion process? If so, which metrics should KaTeX use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did some spot checking of Typewriter-Regular (as that's what I was working on recently) and the letters I checked seemed close, but there's definitely some error. For example, y
has a yMin
of -228
and yMax
of 431
, and the metrics file says [0.22222, 0.43056, ...]
. That's more than floating-point rounding should account for... I'll turn this into an issue (#43).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ylemkimon the height
and depth
calculations look reasonable.
@edemaine the difference may be due to when we're getting the measurements. One of the steps in the pipeline is the darken the fonts by making them a bit thicker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like only the entries that had issues in fontMetricsData.js
were updated. Based on what I'm seeing in this diff things look fine. If there's differences between the TTF and tfm file it's probably because of the darkening we do the font.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Me neither. |
Fix KaTeX#1255 via KaTeX/katex-fonts#41. Also fix width metrics via KaTeX/katex-fonts#42.
* Fix space width in \texttt Fix #1255 via KaTeX/katex-fonts#41. Also fix width metrics via KaTeX/katex-fonts#42. * Improve test * Update screenshots
* Fix space width in \texttt Fix KaTeX#1255 via KaTeX/katex-fonts#41. Also fix width metrics via KaTeX/katex-fonts#42. * Improve test * Update screenshots
* Expose defineSymbol in the main KaTeX object * More Unicode letters (#1260) This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF. * Include Bold-Italic fonts for \boldsymbol (#1257) * Include Bold-Italic fonts for \boldsymbol Fix #1228 * Update screenshots * README: Add size badge (#1253) * README: Add size badge Add a size badge showing size of gzipped katex.min.js * update-sri: Add code to replace size badge in readme * Change to use badge from shields.io instead My bad for assuming that badgesize.io supports https. Change to use the badge from shields.io which supports https. * More Unicode letters (#1260) This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF. * Include Bold-Italic fonts for \boldsymbol (#1257) * Include Bold-Italic fonts for \boldsymbol Fix #1228 * Update screenshots * README: Add size badge Add a size badge showing size of gzipped katex.min.js * update-sri: Add code to replace size badge in readme * Change to use badge from shields.io instead My bad for assuming that badgesize.io supports https. Change to use the badge from shields.io which supports https. * Use badgesize.io with https * Fix space width in \texttt (#1261) * Fix space width in \texttt Fix #1255 via KaTeX/katex-fonts#41. Also fix width metrics via KaTeX/katex-fonts#42. * Improve test * Update screenshots
Fix @ylemkimon's issues reported in #41 (comment)
In particular, fix width of space characters.
I'm not an expert in fonttools but it seemed that I needed to use both the existing
'glyf'
structure for xMin/xMax and thegetGlyphSet
structure for width. Let me know if you know a cleaner way.This will require rerunning the script if #41 gets merged first.