question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem rendering fonts with Katex

See original GitHub issue

I tried quite hard to find the solution to this problem somewhere else but I couldn’t. I’m working on Windows. I’m converting the following text:

Hello: $`x`$

to PDF and this is my result:

image

If I save the resulting html from Python Markdown and open it as a html file, it renders correctly. The following code is my configuration for Python Markdown:

        html = markdown.markdown(text, extensions=['markdown_katex', ], extension_configs={
            'markdown_katex': {
                'no_inline_svg': True,      # fix for WeasyPrint
                'insert_fonts_css': True,
            },
        })
        HTML(string=html).write_pdf(self.exportPath)

I wonder if I’m missing something. I tried to get the PDF using both the CDN provided by Katex and downloading the CSS and adding a font configuration in the python code.

Here is the result when trying to convert from the saved html file (renders correctly) to pdf using WeasyPrint console command in verbose mode:

INFO: Step 1 - Fetching and parsing HTML - filename.html
INFO: Step 2 - Fetching and parsing CSS - https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css
WARNING: Ignored `text-rendering:auto` at 1:4793, unknown property.
WARNING: Ignored `width:min-content` at 1:5147, invalid value.
WARNING: Ignored `display:-ms-inline-flexbox` at 1:6812, invalid value.
WARNING: Ignored `fill:currentColor` at 1:20842, unknown property.
WARNING: Ignored `stroke:currentColor` at 1:20860, unknown property.
WARNING: Ignored `fill-rule:nonzero` at 1:20880, unknown property.
WARNING: Ignored `fill-opacity:1` at 1:20898, unknown property.
WARNING: Ignored `stroke-width:1` at 1:20913, unknown property.
WARNING: Ignored `stroke-linecap:butt` at 1:20928, unknown property.
WARNING: Ignored `stroke-linejoin:miter` at 1:20948, unknown property.
WARNING: Ignored `stroke-miterlimit:4` at 1:20970, unknown property.
WARNING: Ignored `stroke-dasharray:none` at 1:20990, unknown property.
WARNING: Ignored `stroke-dashoffset:0` at 1:21012, unknown property.
WARNING: Ignored `stroke-opacity:1` at 1:21032, unknown property.
WARNING: Ignored `stroke:none` at 1:21065, unknown property.
INFO: Step 2 - Fetching and parsing CSS - CSS string
INFO: Step 3 - Applying CSS
INFO: Step 4 - Creating formatting structure
INFO: Step 5 - Creating layout - Page 1
INFO: Step 6 - Drawing
INFO: Step 7 - Adding PDF metadata

There was a previous conversation with the markdown-katex creator here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
liZecommented, Oct 21, 2020

Hello!

Thanks a lot for your bug report. This bug is actually a duplicate of #1237 (even if it’s older, life’s unfair 😉). You can follow its resolution, and don’t hesitate to complain if it doesn’t fix your problem!

0reactions
dvdmccommented, Sep 22, 2020

I finally managed to render the document with the proper font. The only way I found so far is to install the fonts system-wide in the computer and delete a cached file in C:\msys64\mingw64\var\cache\fontconfig. However, I would really like to know if the only way of using fonts in Windows is through installation or I can use local fonts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Issues
When displaying fractions one above another in these vertical layouts there may not be enough space between rows for people who are used...
Read more >
Katex fonts not correctly included (#214722) - GitLab.org
When rendering matrices on Gitlab's wiki, the matrices are not rendered correctly. This is due to the katex stylesheet (katex.min.css) not being ...
Read more >
html - Katex not displaying correctly
I'm trying to write some basic maths in html. I have included the script to auto-render at the top of my html file...
Read more >
Rendering issue with big brackets
BTW, may be you can help me with one more problem: I use the custom CSS .katex-eq {font-size: 93%;} to match KaTex font...
Read more >
jwist/visualizeR: inst/visu/node_modules/katex/dist/README.md
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. ... Make sure to include the CSS and font...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found