-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[80_3] Enhance sup/subscript kerning via OpenType math table (#2090)
## What We have utilized the italic correction table and kerning table in OpenType to optimize the typesetting of superscripts and subscripts. However, it is important to note that this implementation is non-standard. The italic correction table is used to improve the typesetting on the right side of glyphs. For general characters, the right subscript uses the default position, while the right superscript needs to be shifted to the right by this correction. For symbols like integral signs, the official documentation suggests that both the right superscript and right subscript should be moved by half the offset, while some documents recommend that the superscript remain stationary and the subscript be moved by the full offset. For aesthetic reasons, we have adopted a compromise solution here, where the subscript is shifted left by 0.6 times the offset and the superscript is shifted right by 0.4 times the offset. For the kerning table, it provides correction values for the left and right superscripts and subscripts of a glyph based on their height. According to the OpenType standard recommendations, we should select an optimal correction value by considering both the base glyph and the superscript/subscript glyph at the two recommended correction heights. However, we are unable to handle this in the font's cpp file, so we have opted for a simpler approach, using `fn->y1` and `fn->y2` as the correction heights for the subscript and superscript, respectively, which also yields satisfactory results. Another fact is that many fonts do not provide a kerning table or only provide a very limited kerning table, and almost none of them provide correction values for left superscripts and subscripts. So it can be considered that this PR does not actually change any left-side typesetting. ## Why For certain OpenType fonts, some symbols such as integral signs and superscripts/subscripts appear in incorrect positions. Now, we can improve this by utilizing the metrics provided in OpenType. ## How to test Open `devel/80_3.tmu`. Before: ![image](https://github.com/user-attachments/assets/ff0aef4c-5c5d-4c87-8853-60ef18732134) After: ![image](https://github.com/user-attachments/assets/f3076b05-eae4-4dbc-848e-288340669288) It can be seen that the first two Opentype fonts have been correctly improved, while the latter two have not changed because we used a hardcoded solution.
- Loading branch information
Showing
5 changed files
with
302 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<TMU|<tuple|1.0.5|1.2.9.5>> | ||
|
||
<style|generic> | ||
|
||
<\body> | ||
Asana Math: | ||
|
||
<math|<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4>> | ||
|
||
<\equation*> | ||
<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4> | ||
</equation*> | ||
|
||
\; | ||
|
||
Fira Math: | ||
|
||
<\with|font|Fira Math> | ||
<math|<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4>> | ||
|
||
<\equation*> | ||
<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4> | ||
</equation*> | ||
</with> | ||
|
||
\; | ||
|
||
TeX Gyre Pagella Math: | ||
|
||
<\with|font|TeX Gyre Pagella Math> | ||
<math|<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4>> | ||
|
||
<\equation*> | ||
<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4> | ||
</equation*> | ||
|
||
\; | ||
</with> | ||
|
||
TeX Gyre Schola Math: | ||
|
||
<\with|font|TeX Gyre Schola Math> | ||
<math|<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4>> | ||
|
||
<\equation*> | ||
<big|oint><rsub|1><rsup|1><big|int><rsub|1><rsup|1><big|iint><rsub|1><rsup|1>𝑒<rsup|𝑥>dx BA<rsub|1><rsup|1> UV<rsub|1><rsup|1>ZZ<rsub|1><rsup|1>PQ<rsub|1><rsup|1>\<Omega\><rsub|1><rsup|1>\<Lambda\><rsub|1><rsup|1>\<Delta\><rsub|4><rsup|4>\<alpha\><rsub|4><rsup|4>\<b-cal-M\><rsub|4><rsup|4>𝓐<rsub|4><rsup|4>𝓥<rsup|4><rsub|4>𝓦<rsub|4><rsup|4> | ||
</equation*> | ||
</with> | ||
|
||
\; | ||
|
||
\; | ||
</body> | ||
|
||
<\initial> | ||
<\collection> | ||
<associate|font|Asana Math> | ||
<associate|font-base-size|14> | ||
<associate|font-family|rm> | ||
<associate|page-medium|paper> | ||
<associate|page-screen-margin|false> | ||
</collection> | ||
</initial> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.