Full (yet lightweight) Unicode Plane 0 support (60000+ characters!)#46
Open
syimyuzya wants to merge 12 commits intopyrollo:masterfrom
Open
Full (yet lightweight) Unicode Plane 0 support (60000+ characters!)#46syimyuzya wants to merge 12 commits intopyrollo:masterfrom
syimyuzya wants to merge 12 commits intopyrollo:masterfrom
Conversation
This is for naming consistency among other font def params like `linespacing`, `margintop` etc.
Now the file name has the correct `<modname>_` prefix.
Thomas--S
reviewed
Dec 4, 2021
unifont/init.lua
Outdated
| end | ||
| local x = codepoint % 256 | ||
| local y = math.floor(codepoint / 256) | ||
| return string.format("unifont_sheet.png^[sheet:256x256:%d,%d", x, y) |
Contributor
There was a problem hiding this comment.
You might want to consider renaming unifont_sheet.png to something shorter, e.g. unifont.png in order to keep the resulting texture strings as short as possible (important for reducing the network load).
Author
There was a problem hiding this comment.
I have now split the sheet into 256 pages, filenames are now unif_XX.png.
This also fixes the ~1sec freeze on initial texture loading. Mod size is now ~2MB, though.
Now 256 sheets, 16x16 chars each (same as Minecraft), instead of one huge sheet. This greatly improves performance on initial texture loading (total size also grows to ~2MB, though). Filenames are now `unif_XX.png` (XX for codepoint's higher byte in hex form).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(See screenshot in unifont/README.md)
This PR adds support for compact, texture sheet based font to
font_api, and includes a new font modunifontthat supports 60000+ Unicode characters and weighs only~1MB (even smaller than Metro!). Edit: ~2MB now in order to improve rendering performace.Changes made to
font_api(also documented in font_api/API.md):A new optional parameter
getglyphin font registration: It allows a font mod to construct its own glyph texture string (e.g. using^[sheet) instead of the defaultfont_{name}_{codepoint}.png.This allows large, compact (and better compressed) sheets to be used instead of individual glyph files for a very large number of glyphs. (In comparison, the
font_jp_notomod weighs ~31MB with ~20000 chars)The texture string returned by
Font:render, when used in formspec, are now required to be escaped (minetest.formspec_escape).This should have been done already even before this PR since texture strings, by its nature, might confuse the formspec parser anyway.
The newly added font "unifont" uses GNU Unifont, the same font also used in Minecraft (and also in texture sheet form) for Unicode display.