All examples By author By category About

timelyportfolio

play with MathJax svg fonts in R with rvest and htmltools

Rabbit Hole of the Day | SVG Fonts as Paths

While working on my htmlwidget of the week katexR, I learned that MathJax can render in SVG. I know, I know, how did I not know that? Nevertheless once I made the discovery, I had the thought that I could render the SVG font glyphs (think beyond MathJax here) in R with rvest and htmltools. To get it to work requires very little effort after you work through a couple of kinks. The primary kink is that font glyphs are flipped, so you'll need a transform = scale( 1, -1 ), but even better I used transform = scale( 0.75, -0.75 ) to fit the glyph in the small little window I gave it.

To replicate, check out the code.