I’m using rmagick to annotate images programatically with text. The text will need to support a range of languages including Chinese, Korean, English among others. The font requirements I’m dealing with are very specific, and the font chosen for English supports a wide variety of western languages, but it doesn’t support Chinese or Korean. I’ll have other fonts for those languages.
The approach I have in mind is to map character ranges to particular fonts and programmatically tell rmagick what font to use based on that. Am I missing anything obvious, or is this a good approach to take?
Here is how I ended up solving this:
That method will take some text and return the path to an appropriate font face. Regex’s character property matching comes in handy here! Then i can use the font_for method inside my rmagick script for annotating an image.
It is worth noting that this simplistic approach wouldn’t handle input with mixed languages.