hypothesis / client

The Hypothesis web-based annotation client.
Other
634 stars 196 forks source link

KaTeX fonts not loading properly (math rendering issue with cases) #6526

Closed mforbes closed 1 month ago

mforbes commented 1 month ago

Bug report form

Steps to reproduce

Enter the following expression into an annotation:

$$
\begin{cases}
1 & r<1\\
0 & \text{otherwise}
\end{cases}
$$

Expected behaviour

$$ \begin{cases} 1 & r<1\ 0 & \text{otherwise} \end{cases} $$ or

image

Actual behaviour

image

Browser/system information

Brave with Hypothes.is extension 1.1512.0.0 on Mac OS X 14.6.1. Same issue using Safari.

Additional details

As far as I can see from various discussions, hypothes.is should be using KaTeX which renders this properly, so not sure where the issue is.

Your solution

Properly implement KaTeX. (It is also annoying that inline equations need to start with the LaTeX delimiters \( and \) while the TeX delimiter $ does not work, but block equations use the TeX delimiters $$ and now the LaTeX delimiters \[ and \] don't work. I could not find a discussion - let me know if I should open another issue about this.

Add tags - did you add labels?

If this a customer requested feature, make sure to add that label.

robertknight commented 1 month ago

I could not find a discussion - let me know if I should open another issue about this.

Let's focus this issue on the cases rendering problem.

It looks like there is a problem with loading some of the KaTeX custom fonts which is causing the issue.

I can reproduce the expected rendering in the demo widget on https://katex.org. There it looks like the { glyph is rendered with the KaTeX_Size4 font. In the Hypothesis client it is rendered with the Times font however. In Chrome devtools I see an error reported about decoding of the fonts:

KaTeX font decoding
robertknight commented 1 month ago

Thanks for the report. The issue will be resolved in the next extension update.