gjtorikian / mathematical

Convert mathematical equations to SVGs, PNGs, or MathML. A general wrapper to Lasem and mtex2MML.
https://gjtorikian.github.io/mathematical/
MIT License
166 stars 31 forks source link

Fonts rendering differently between macOS and Ubuntu #113

Open mudge opened 1 year ago

mudge commented 1 year ago

Given the following test script:

require 'mathematical'

renderer = Mathematical.new(format: :png, ppi: 300.0)
File.write('test.png', renderer.render('$x$').fetch(:data))

Running it on macOS 13.2.1 with 1.6.14 produces the following image:

test

Running it on Ubuntu 22.04, Ubuntu 20.04 and Ubuntu 18.04 with 1.6.14 produces the following image:

test

I tested macOS by installing the dependencies with Homebrew and installing the required fonts as detailed in the README:

brew install glib gdk-pixbuf cairo pango cmake

I tested Ubuntu using the ubuntu:22.04, ubuntu:20.04 and ubuntu:18.04 Docker images and installing the necessary dependencies with the following:

apt update
apt install -qq -y ruby ruby-dev bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev fonts-lyx cmake g++ libwebp-dev libzstd-dev
gem install mathematical --no-document

I can confirm the LyX fonts are installed with:

# fc-list | grep lyx
/usr/share/fonts/truetype/lyx/msbm10.ttf: msbm10:style=LyX
/usr/share/fonts/truetype/lyx/cmr10.ttf: cmr10:style=LyX
/usr/share/fonts/truetype/lyx/eufm10.ttf: eufm10:style=LyX
/usr/share/fonts/truetype/lyx/rsfs10.ttf: rsfs10:style=LyX
/usr/share/fonts/truetype/lyx/cmex10.ttf: cmex10:style=LyX
/usr/share/fonts/truetype/lyx/cmmi10.ttf: cmmi10:style=LyX
/usr/share/fonts/truetype/lyx/cmsy10.ttf: cmsy10:style=LyX
/usr/share/fonts/truetype/lyx/msam10.ttf: msam10:style=LyX
/usr/share/fonts/truetype/lyx/wasy10.ttf: wasy10:style=LyX
/usr/share/fonts/truetype/lyx/esint10.ttf: esint10:style=LyX
/usr/share/fonts/truetype/lyx/stmary10.ttf: stmary10:style=LyX

I also tried compiling the gem on Ubuntu from source but it still produced the same output.