plurimath / plurimath.github.io

Official Plurimath web site
https://www.plurimath.org/
MIT License
0 stars 0 forks source link

Add blog post regarding what fonts to use for accurate math rendering #10

Closed ronaldtse closed 11 months ago

ronaldtse commented 11 months ago

@intelligent2013 can you help here with a blog post? Thanks!

plurimath-constants-fonts.zip

Intelligent2013 commented 11 months ago

@ronaldtse there is a related unassigned ticket here https://github.com/metanorma/mn-native-pdf/issues/528. Currently plurimath-constants-fonts.zip contains STIX Two Math vs. Noto Math comparison. Should we expand this for Cambria Math and Libertinus Math?

ronaldtse commented 11 months ago

Yes we should definitely add the two fonts! Thanks!

Intelligent2013 commented 11 months ago

Done in https://github.com/plurimath/plurimath.github.io/pull/11

Intelligent2013 commented 11 months ago

@ronaldtse I've added the list of glyphs for each font in a YAML file (https://github.com/plurimath/plurimath.github.io/pull/11).

But looks like the site generation (bundle exec jekyll build --trace) doesn't support Liquid markup: image

I'll investigate how to enable the Liquid markup in the blog post.

Intelligent2013 commented 11 months ago

Done: image

Intelligent2013 commented 11 months ago

Further tasks:

ronaldtse commented 11 months ago

@Intelligent2013 can we also add:

Intelligent2013 commented 11 months ago

@ronaldtse the post updated. I've added a comparison for Cambria Math v5.24, not 5.28 (the package pclinuxos_webcore_fonts contains 5.24).

ronaldtse commented 11 months ago

Thanks @Intelligent2013 !

ronaldtse commented 11 months ago

This is fully done, thanks @Intelligent2013 !

ronaldtse commented 11 months ago

@Intelligent2013 can you also help post instructions on how to generate the PDF file comparison and the output of the YAML file? Thanks.

Intelligent2013 commented 11 months ago

How to generate the PDF file comparison and the output of the YAML file

Step 1: generate PDF with fonts comparison table

Source XML file with : Pluramath Latex constants: plurimath_latex_constants.zip

XSL for PDF generation: fonts_comparison.zip

fonts_comparison.xsl generates glyphs for the font Cambria Math v6.99 and 5.24, but Java doesn't allow to register two fonts with the same name. Therefore, in FontForge tool, I've extracted Cambria Math font from cambria.ttc v5.24 and changed the name to Cambria Math 524. The font manifest entries fonts looks so:

STIX Two Math:
  Regular:
    full_name: STIX Two Math Regular
    paths:
    - C:/Users/TestUser/.fontist/fonts/STIXTwoMath-Regular.otf

Cambria Math:
  Regular:
    full_name: Cambria Math
    paths:
    - C:/Windows/Fonts/cambria.ttc

Cambria Math 524:
  Regular:
    full_name: Cambria Math 524
    paths:
    - D:/Work/Metanorma/Fonts/Cambria_5.24_updated/CambriaMath524.ttf 

Noto Sans Math:
  Regular:
    full_name: Noto Sans Math Regular
    paths:
    - C:/Users/TestUser/.fontist/fonts/NotoSansMath-Regular.ttf

Libertinus Math:
  Regular:
    full_name: Libertinus Math Regular
    paths:
    - C:/Users/TestUser/.fontist/fonts/LibertinusMath-Regular.otf

Cambria Math 524 font: CambriaMath524.zip

Generate PDF by mn2pdf tool: java -Xss5m -Xmx2048m -Djava.awt.headless=true -jar mn2pdf.jar -x plurimath_latex_constants.xml -s fonts_comparison.xsl -o plurimath_latex_constants.pdf -m manifest.yml

Step 2: Process PDF generation log plurimath_latex_constants.pdf.err

Copy-paste the lines like these:

Glyph "⥂" (0x2942) not available in font "LibertinusMath-Regular".
Glyph "⥃" (0x2943) not available in font "LibertinusMath-Regular".

to the file missing.xml.

Then in the text editor that supports regular expressions:

Now you get:

<missing>
<char><unicode>&amp;#x2942;</unicode><font>LibertinusMath-Regular</font></char>
<char><unicode>&amp;#x2943;</unicode><font>LibertinusMath-Regular</font></char>
...
</missing>

missing.zip

Step 3: generate YAML file with fonts coverage

XSLT for YAML generation from plurimath_latex_constants.xml and missing.xml: fonts_yaml.zip

Run YAML generation:

java -jar xalan.jar -IN plurimath_latex_constants.xml -XSL fonts_yaml.xsl -OUT 2023-08-15-font_coverage.yml

2023-08-15-font_coverage.zip