Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are CLM files and where to get them? #174

Open
afalkenhahn opened this issue May 16, 2024 · 5 comments
Open

What are CLM files and where to get them? #174

afalkenhahn opened this issue May 16, 2024 · 5 comments

Comments

@afalkenhahn
Copy link

When initializing MicroTeX I always need to pass a CLM file as well as an OTF file. I'm currently using the latinmodern-math.clm1 that is part of the MicroTeX distribution and that works just fine but what if I want to use some arbitrary font that is installed on the user's system? There are no CLM files but just OTF/TTF/TTC files in the system's font directory.

So what if I want to use some arbitrary system font? Do I first have to generate a CLM file for that before it can be used with MicroTeX or how does that work? I've never heard of the CLM format before and Google doesn't really help here either. Is CLM a format proprietary to MicroTeX or is it some sort of standard?

Thanks for some clarification!

@sp1ritCS
Copy link
Contributor

clm files contain precalculated metadata needed by µTeX to render glyphs, which we don't want to do at runtime. The name comes from cLaTeXMath, which was the name of the original library (thats whats still in the master branch) altho ironically cLaTeXMath doesn't use those clm files.

Specifically, .clm1 files contain only metadata and .clm2 files contain both meta- and glyph data for usecases where there isn't a library available capably of laying out glyphs from font files.

They can be generated using the otf2clm.py script.

@afalkenhahn
Copy link
Author

Thanks! Have you got some more information about the "use cases" you mentioned, that is which use cases require .clm1 and which require .clm2 files? Is that related to the different backends (cairo, GDI+, Flutter...) supported by MicroTeX or what exacxtly do you mean by "use case"?

@sp1ritCS
Copy link
Contributor

Yes. The backends provide a set of (more or less) primitive vector operations.

MicroTeX doesn't actually read the otf font files, they just get passed to the backend on initialization. This way, characters can be drawn using drawGlyph(codepoint) directly. But not every backend supports that, so characters can also be drawn using the vector operations of the backend.

@afalkenhahn
Copy link
Author

afalkenhahn commented May 17, 2024

Ok, is there an overview which backends require .clm2 and which are fine with .clm1? For example, I'm using the cairo backend. Does that require .clm1 or .clm2? I suppose .clm1 because looking at the backend source it passes the otf font file to fontconfig and then converts it into a cairo font face so I suppose the cairo backend doesn't require .clm2? But what about the other backends? Which ones need .clm1 and which need .clm2?

@sp1ritCS
Copy link
Contributor

Im not sure, the whole backend situation gets even more complicated, as some backend builds on top of others.
AFAIK, there is gtk which uses cairo; qt, skia and gdi are independent and flutter and wasm build ontop of wrapper, which serializes draw calls first.

While all backends seem to have implemented drawGlyph, I suspect some backends can't load arbitrary fonts (at least wasm can't)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants