-
Notifications
You must be signed in to change notification settings - Fork 68
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
New feature: BMFont support #18
Conversation
…ATION_CHECK` to save compile time when building fonts with big charaset Current implementation of _duplicated_utf8_characters() is inefficient with time complexity of O(N^2). Project build process will hang for an untolerable long time when many characters exist.The duplication check for fonts with big charaset can be done in font making or converting phase. It is unnecessary to do it in assertion.
…ers and how to import new fonts
First of all, thanks a lot for your work. Butano really needs tools for importing standard font formats, and you have made a tool for a very popular font format. Great stuff. However, I don't understand why it needs to be integrated into the main Butano Makefile ( As far as I understand, your tool generates a And about allowing UTF-8 character collisions, if a collision happens Butano is not going to be able to determine which sprite to render for the involved characters, so the tool should generate a collision free font, instead of allowing collisions in |
… check on fonts with thousands of characters. It may take a really long time in the build process though. Read #18 for more deails.
If it is used as an external tool, each project needs to be released with the external tool to build, so developers needs to mantain many copy of the same scripts. If I update the conversion script, it is hard to update all copies of the script released with projects on the Internet, which makes version control impossible.
I have already explained it in the commit message of 93bca7e. It doesn't disable the check. It adds a config for user to decide the threshold of the character numbers to skip it to avoid project build process from hanging. The check function is just a simple nested loop, which is O(N^2). If there are 2000 characters to check, it needs to compute 5000 x 5000 = 25000000 times, which will take a really long time. And it will exceed the default max times limit for
Of course a user may really wants to do it for thousands of characters and is willing to wait several hours (maybe? idk) for it during project building. Then it is its free to set the config
The tools to make BMFont format fonts ( |
That's a problem that needs to be fixed instead of being hacked out. Could you create a separate issue with a big |
Done. #19. |
…oid overlap with testing texts
…ource-han-sans source-han-sans: https://github.com/adobe-fonts/source-han-sans license: SIL Open Font License v.1.1
…hange breaking change is introduced in 59e3dca
…source font: source-han-serif source-han-sans: https://github.com/adobe-fonts/source-han-serif license: SIL Open Font License v.1.1 btw rename `cn` to `sc` which means Simplified Chinese in font name
It should support both half-width(半角) and full-width(全角) now.
The new font system stores the UTF-8 characters map in ROM instead of WRAM, so it is possible to create `bn::sprite_font` in stack located at IWRAM not only heap located at EWRAM. Chinese's and Japanese's sprite font are creatd via local variables instead of new operator to test that. That optimization is done in 59e3dca It is discussed in #19 (comment)
… source-han-serif) source-han-sans: https://github.com/adobe-fonts/source-han-serif license: SIL Open Font License v.1.1
…+ 6341 characters (open source font: source-han-serif) source-han-sans: https://github.com/adobe-fonts/source-han-serif license: SIL Open Font License v.1.1
…07 common characters (open source font: source-han-serif) source-han-sans: https://github.com/adobe-fonts/source-han-serif license: SIL Open Font License v.1.1
Common fonts for: - Simplified Chinese - Traditional Chinese (Taiwan) - Traditional Chinese (Hong Kong) - Japanese - Korean Source Han Serif (SIL Open Font License 1.1) https://source.typekit.com/source-han-serif/ https://github.com/adobe-fonts/source-han-serif
- to avoid increasing butano's repo size - independent maintain and update from butano main engine - to support more game engines or GBA projects besides butano GValiente/butano#18.
…-free-fonts - to avoid increasing butano's repo size - independent maintain and update from butano main engine - to support more game engines or GBA projects besides butano laqieer/gba-free-fonts@12e3416.
I hope with the new About merging If you need more changes in the core for supporting Again, thanks a lot for your help. |
|
|
External tool is run before the rest, so if that tool generates files with known extensions (like Take a look at the
The tool would generate output files in the |
Yes, you are right. I realized it later so I just marked them with strikeout. I need to add an independant cmd interface for |
New FeatureAuto trim useless characters in fonts to save space. 701e846. Principle
Backward CompatibilityIt is disabled if no path to texts is set in Makefile. Old projects needn't any change to build without the new feature. Example
Note: free font HanaMin A has 51,991 characters including CJK Unified Ideographs (URO, URO+, Ext.A) and CJK Compatibility Ideographs (with Supplement). It is difficult to import all of them into the game without the new feature. However, it is easy-to-use with auto-trim feature. The final game is only 155700 bytes with 154 used characters. Test Result
Built
Built This feature reduces game size from 9MB (25000+ characters) to 0.35MB (569 characters) in this example. |
It is deprecated because it doesn't support new feature auto-trim and wastes much space. It is recommended to include fonts in bmfont format and enable auto-trim feature in your project to save space. GValiente/butano#18 (comment)
Now that we already have the character set, we needn't process all characters in the fonts. If all characters in text files are extracted, it stops reading the current font file. BTW it also removes dupilcated characters in the process.
Font: HanaMin A under SIL Open Font License (OFL) It includes 51,991 characters. GValiente/butano#18
I'll close the pull request. Feel free to create an issue if you need it. |
BMFont is a widely used font format in game engines such as Cocos, Unity, Ren'Py and so on. This pr is to support it. Tools, template, examples and documentation are included. All changes are backward compatible, so old projects needn't any change to build. It will make life easier to import fonts.
BTW It also comes with a variable width Chinese font with 3500 common Hanzi and Japanese font with 1945 common Kanji so that users can use them to print Chinese and Japanese even if they don't want to enable BMFont support. Those fonts are not included or linked unless manually specified, so it won't increase size by default if they are not used. It will solve #6 and #11, and corresonding part in FAQ is also updated.