Replacing fonts?

Is there a quick-and-easy way to replace a font–by which I mean not merely loading a new font and assigning it to the variable that held the old one, but having it take the place of that old font in objects that use it?

To explain, I’m working on language support, and each language specifies the fonts that it uses. This way, if one of the default fonts lacks characters, a new font can be specified that includes them.

Naturally, I can do the font-replacement per GUI-object (after all, I’m already accessing them to change their text when switching languages). However, it would be nice if there were a less-tedious method. ^^;

(I’ve already done a little searching, but haven’t turned up anything promising.)

I’m not sure that there is an easy way to do replace an existing font (would make for a good feature request—it probably wouldn’t be very hard to add a read() call to DynamicTextFont). That said, it should be fairly straightforward to merge your fonts into one using a program like FontForge.

That sounds good to me! :slight_smile:

[edit] Should I post the request somewhere in particular, or just take it as requested? [/edit]

Hmm… That would mean issuing an updated font with any and all translations. But let’s say that the game really takes off, and I have multiple translations available. That means that each translation would provide a font that includes its own glyphs, but not those of other translations. If someone were to install two translations, one would overwrite the other.

Of course, that’s likely a somewhat unusual case.

Still, it seems preferable to me to simply have a new set of fonts for languages that have glyphs not present in the default fonts.

@Thaumaturge Sorry for the late reply. Feature requests like this should be posted on the GitHub issue tracker.

An alternative feature request could be to allow setting a “fallback” font to be used if a given font doesn’t provide glyphs for some characters, which you could then set to a font that supports most character sets such as from the Noto family.

That said, I think it would be easiest all around to have a single font that covered all scripts that are intended to be targeted, either by choosing an appropriate font that provides those scripts or by merging multiple fonts into one.

Not a problem, and fair enough! :slight_smile:

[edit] I’ve added the feature request. [/edit]

Hmm… The thing is, I don’t know what languages might be called for. This is a feature that I’m putting in so that language support is available should it become feasible–of if it doesn’t, for potential use in future projects. I don’t currently have a set of intended languages.

Thus I’d prefer that each language nominate its own set of fonts. These can be the current default fonts if those include all of the desired glyphs, but might be other fonts for cases in which the defaults don’t include them.