Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add font glyph fallback mechanism to the tiles build #36326

Merged
merged 5 commits into from
Dec 22, 2019

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Dec 21, 2019

Summary

SUMMARY: Interface "Fallback fonts can now be specified for the tiles build"

Purpose of change

The font currently shipped with the game (unifont) has the merit of wide unicode support, but its pixelated glyphs doesn't actually look pretty. Other fonts with prettier glyphs, however, often support only a very limited subset of unicode glyphs. This PR implements font fallback mechanism for the tiles build, so the user can specify the main font to display the most common glyphs, and fallback fonts to display rare glyphs correctly when the main font doesn't provide these glyphs.

Describe the solution

The "typeface" value in config/fonts.json can now be an array specifying multiple typefaces. A new child class of Font, FontFallbackList, is added, which loads the specified typefaces and checks if a given glyph is provided with the typefaces. The first typeface from the array that provides the glyph is used to render the glyph.

Testing

Changed the typeface list and started the game, observed that glyphs not provided with the main font are correctly rendered with the glyphs from the fallback font.

Additional context

This is only for the tiles build. For the curses build, font fallback probably can only be achieved by configuring the terminal software.

image

In the above screen shot, the Latin/Cyrillic characters are rendered with UbuntuMono (bold), and the CJK characters are rendered with unifont as the fallback font.

src/font_loader.h Outdated Show resolved Hide resolved
src/sdltiles.cpp Outdated Show resolved Hide resolved
src/sdltiles.cpp Outdated Show resolved Hide resolved
src/sdltiles.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. SDL: Tiles / Sound Tiles visual interface and sounds. labels Dec 22, 2019
@ZhilkinSerg ZhilkinSerg merged commit 9b57370 into CleverRaven:master Dec 22, 2019
@Qrox Qrox deleted the fallback-font branch December 23, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. SDL: Tiles / Sound Tiles visual interface and sounds.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants