NanoMichael / MicroTeX

A dynamic, cross-platform, and embeddable LaTeX rendering library
MIT License
399 stars 66 forks source link

Using New Computer Modern fonts #173

Open kpeeters opened 1 month ago

kpeeters commented 1 month ago

I am trying to use the New Computer Modern fonts (https://www.ctan.org/pkg/newcomputermodern) with the openmath branch, as I would like to have a set of fonts that includes AMS symbols (among others). Unfortunately, after converting with otf2clm, microtex does not recognise any of these to be a math font. Is there something I should do with otf2clm in order to make it flag its output as math font?

Alternatively, is there some ready-to-run clm font set somewhere that includes all of Computer Modern and the AMS fonts?

sp1ritCS commented 1 month ago

Is there something I should do with otf2clm in order to make it flag its output as math font?

No, the otf2clm script uses the python api from fontforge that provides whether a font is a math font or not.

is there some ready-to-run clm font set somewhere that includes all of Computer Modern and the AMS fonts?

What is missing in Latin Modern?

kpeeters commented 1 month ago

Hmm, this may be a different issue. I tried typesetting (with the microtex-qt-example) \square, and that produces a red question mark along with a complaint that There's no glyph was found with (unicode = 9723, id = -1), use '?' instead.. However, if I typeset \square\square I get two squares. So the character is there indeed, probably a bug in microtex.

sp1ritCS commented 1 month ago

Hmm, I can reproduce this with Latin Modern (and the two other math fonts) but not with XITS...

https://nanomichael.github.io/MicroTeX/?tex=\square\square\\\square

kpeeters commented 1 month ago

Interesting. A workaround that will do the job for me for the time being is to use \square~ or if necessary \square~\!. But someone with more knowledge about how this works internally might want to have a look at it. Various other symbols have the same problem.

sp1ritCS commented 1 month ago

I did some digging and it appears that the symbol inserted by \square is U+25FB (WHITE MEDIUM SQUARE), which is available in XITS but not in the other fonts. image

if you check the the svg code generated by the demo, you'll see that the \square\square from XITS is produced as a PATH, where as it is a

<text [...]>◻◻</text>

element when using Latin Modern. I think this means it'll use the system font provider (for cairo [and prob. qt too] that'll be fontconfig, which will fall back to whatever font that has that glyph available), but I'll assume that fallback mechanism doesn't work correctly if there is just a single glyph in the line.

kpeeters commented 1 month ago

Ok. In that case my original question still stands: is there anyone with a microtex-compatible OTF font that includes all of the Computer Modern Math and AMS Math fonts? Or a way to obtain those from the New Computer Modern set using otf2clm?

sp1ritCS commented 1 month ago

No. You could either investigate why fontforge is not detecting your font as math font or maybe look into merging the missing symbols into Latin Modern Math and generate the clm file for that.