I wonder how the other engines are accomplishing this. In Objective C you can call [UIFont systemFontOfSize:12] or [UIFont fontWithName: @"Helvetica" size:12] etc. It seems they are using UILabels and setting them to the desired system font then rendering them to sprites.
Cocos2d-X has this command:
Quote: "Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
auto ret = new (std::nothrow) Label(hAlignment,vAlignment);
if (ret)
{
ret->setSystemFontName(font);
ret->setSystemFontSize(fontSize);
ret->setDimensions(dimensions.width, dimensions.height);
ret->setString(text);
ret->autorelease();
return ret;
}
return nullptr;
}"
Which calls some others (
source code here).
Both that and
Unity actually automatically substitute custom fonts with system fonts including on iOS when the glyphs are not present, which is desirable to easily support foreign characters.
Quote: "If none of the listed fallback fonts are present and have the requested glyph, Unity will fall back to a hard-coded global list of fallback fonts, which contains various international fonts commonly installed on the current runtime platform."