Hi cbreeden,
This is a continuation of the reddit thread; it'd be great to get support for OpenType working, or at least a primitive version. I tried to get Latin Modern Math working today and this is how much I've accomplished so far. It would be great to get your mentorship and progress further.
Setup
Generating static files
- Run
python3 rexify.py latinmodern-math.otf out/lmmodern in the rex-fonts directory to generate the files (e.g., glyphs.rs).
Issue. Due to changes changes in Rust 2018 and my recent PR, you need to change the glyphs.mako.rs file. I will submit a PR soon.
Integration
-
Create a new crate in ReX/fonts, and copy over the files generated in the previous step. However, the styles.rs, kernings.rs and macros.rs (and lib.rs) are missing, so I just copied them over from the ReX/fonts/stix2 directory. Note that kernings.rs is supposed to be generated during the previous script, but the rexify.py reports that no kerning tables are found.
-
In the root Cargo.toml file, point stix2 are the new crate (never mind the fact that it's still called "stix2").
-
cargo build --release
[Bug.] In the generated styles.rs, we need to add the following lines. It's interesting that the python script doesn't generate these lines automatically, but they are somehow found in the stix2 package.
pub const NULL_DELIMITER_SPACE: FontUnit = fontunit!(100);
pub const DELIMITER_SHORT_FALL: FontUnit = fontunit!(100);
pub const DELIMITER_FACTOR: FontUnit = fontunit_raw!(0xE6); // 90.1%
- Copy over the font from the first step, and change
main.rs so the generated SVG reads from the correct file.
Here is the SVG produced for \sum_{n\geq1} \frac{1}{n^2} = \pi^2/6, which looks like this. The problem is that operator symbols are somehow not working. I would need some assistance to figure out how to fix this -- where does the code look for these tables? (My guess is that the automatically generated symbols.rs somehow is not working.)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="639.3165" height="260.053125" viewBox="0 0 6659 2708" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css">@font-face{font-family:rex;src:url('rex-lmodern.otf');}</style>
</defs>
<g font-family="rex" font-size="1000">
<rect x="250" y="100" width="6159" height="1343" fill="none" stroke="blue" stroke-width="8"/>
<rect x="250" y="293" width="1444" height="2315" fill="none" stroke="red" stroke-width="8"/>
<rect x="972" y="293" width="1444" height="0" fill="none" stroke="blue" stroke-width="8"/>
<rect x="972" y="293" width="0" height="0" fill="none" stroke="blue" stroke-width="8"/>
<rect x="250" y="493" width="1444" height="950" fill="none" stroke="blue" stroke-width="8"/>
<rect x="250" y="493" width="1444" height="1400" fill="none" stroke="red" stroke-width="8"/>
<rect x="250" y="493" width="1444" height="1400" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(250, 1443)"></text>
<rect x="315" y="2060" width="1444" height="465" fill="none" stroke="blue" stroke-width="8"/>
<rect x="315" y="2060" width="1313" height="465" fill="none" stroke="blue" stroke-width="8"/>
<rect x="315" y="2216" width="419" height="316" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(315, 2525) scale(0.70)">𝑛</text>
<rect x="734" y="2084" width="543" height="524" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(734, 2525) scale(0.70)">≥</text>
<rect x="1278" y="2060" width="349" height="465" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(1278, 2525) scale(0.70)">1</text>
<rect x="1960" y="100" width="949" height="2040" fill="none" stroke="red" stroke-width="8"/>
<rect x="2185" y="100" width="949" height="666" fill="none" stroke="blue" stroke-width="8"/>
<rect x="2185" y="100" width="500" height="666" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(2185, 766)">1</text>
<rect x="1960" y ="1173" width="949" height="40" fill="#000"/>
<rect x="1960" y="1374" width="949" height="754" fill="none" stroke="blue" stroke-width="8"/>
<rect x="1960" y="1687" width="600" height="442" fill="none" stroke="blue" stroke-width="8"/>
<rect x="1960" y="1687" width="600" height="453" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(1960, 2129)">𝑛</text>
<rect x="2560" y="1374" width="349" height="754" fill="none" stroke="red" stroke-width="8"/>
<rect x="2560" y="1374" width="349" height="465" fill="none" stroke="blue" stroke-width="8"/>
<rect x="2560" y="1374" width="349" height="465" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(2560, 1840) scale(0.70)">2</text>
<rect x="3343" y="1076" width="778" height="234" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(3343, 1443)">=</text>
<rect x="4454" y="1012" width="570" height="431" fill="none" stroke="blue" stroke-width="8"/>
<rect x="4454" y="1012" width="570" height="442" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(4454, 1443)">𝜋</text>
<rect x="5024" y="614" width="384" height="828" fill="none" stroke="red" stroke-width="8"/>
<rect x="5024" y="614" width="384" height="465" fill="none" stroke="blue" stroke-width="8"/>
<rect x="5059" y="614" width="349" height="465" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(5059, 1080) scale(0.70)">2</text>
<rect x="5409" y="693" width="500" height="1000" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(5409, 1443)">/</text>
<rect x="5909" y="777" width="500" height="688" fill="none" stroke="green" stroke-width="8"/>
<text transform="translate(5909, 1443)">6</text>
</g>
</svg>
Hi cbreeden,
This is a continuation of the reddit thread; it'd be great to get support for OpenType working, or at least a primitive version. I tried to get Latin Modern Math working today and this is how much I've accomplished so far. It would be great to get your mentorship and progress further.
Setup
Generating static files
python3 rexify.py latinmodern-math.otf out/lmmodernin therex-fontsdirectory to generate the files (e.g.,glyphs.rs).Issue. Due to changes changes in Rust 2018 and my recent PR, you need to change the
glyphs.mako.rsfile. I will submit a PR soon.Integration
Create a new crate in
ReX/fonts, and copy over the files generated in the previous step. However, thestyles.rs,kernings.rsandmacros.rs(andlib.rs) are missing, so I just copied them over from theReX/fonts/stix2directory. Note thatkernings.rsis supposed to be generated during the previous script, but therexify.pyreports that no kerning tables are found.In the root
Cargo.tomlfile, point stix2 are the new crate (never mind the fact that it's still called "stix2").cargo build --release[Bug.] In the generated
styles.rs, we need to add the following lines. It's interesting that the python script doesn't generate these lines automatically, but they are somehow found in thestix2package.main.rsso the generated SVG reads from the correct file.Here is the SVG produced for
\sum_{n\geq1} \frac{1}{n^2} = \pi^2/6, which looks like this. The problem is that operator symbols are somehow not working. I would need some assistance to figure out how to fix this -- where does the code look for these tables? (My guess is that the automatically generatedsymbols.rssomehow is not working.)