Fix #2339: render math text when using path effects

Fixes #2339, and adds unit tests.