Conversation
…ting - Add Font.fallback and Font.fallbacks chain with multi-page texture tiles support - Add 4,458-glyph 12px classic Chinese pixel font built into DefaultFont - Remove single-page texture limit in BMFont FontParser (support XML/Text/Binary v3) - Rewrite BDFFont packing algorithm using O(N) Shelf Bin-Packing - Implement CJK line-breaking rules (Kinsoku Shori) in Charset and Text - Fix ModelDatabase conditional compilation on browser JS target
Contributor
|
Please minimize your changes, avoid multiple contribution per PR, and rebase your branch |
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.
📌 Summary / 概述
English:$O(N)$ shelf packing for BDF fonts, and CJK line-breaking rules (Kinsoku Shori) to the Heaps engine. All changes are 100% backward-compatible and require zero code modifications for existing projects.
This PR introduces comprehensive, out-of-the-box native Chinese pixel font support, a font fallback mechanism, multi-page BMFont parsing,
中文:$O(N)$ 货架装箱算法以及 CJK 中文避头尾折行排版法则。所有修改100% 向后兼容,现有项目无需更改任何既有代码。
本 PR 为 Heaps 引擎引入了开箱即用的原生中文像素字体支持、字体回退链(Font Fallback)机制、BMFont 多页贴图解析、针对 BDF 字体的
🎯 Motivation & Problems Solved / 动机与解决的核心痛点
DefaultFontonly contains ASCII 32~126, showing empty/missing glyphs for Unicode Chinese.h2d.Fontlacks a fallback mechanism; missing glyphs cannot fall back to secondary fonts.fallback: Null<Font>&fallbacks: Array<Font>with transparent recursive glyph resolution.FontParserexplicitly rejected multi-page BMFont (BMF format only supports one page at the moment).BDFFontused anh2d.TextandCharsethad no CJK punctuation wrapping rules, breaking lines before commas/periods.ModelDatabase.hxaccessedfs.convertunconditionally, breaking browser JS builds.🛠️ Key Changes / 核心改动细节
1.
h2d/Font.hx- Font Fallback & Multi-Page Texture Supportpublic var fallback : Null<Font>andpublic var fallbacks : Array<Font>.public var tiles : Array<h2d.Tile>for multi-page font textures.getChar(code: Int)andhasChar(code: Int)to seamlessly resolve missing glyphs through the fallback chain.clone()anddispose()for safe multi-page and fallback lifecycle management.2.
h2d/Text.hx&hxd/Charset.hx- CJK Line-Breaking Rules (Kinsoku Shori),。、?!:;”)》】etc.) inCharset.complementChars.isLeadingChar(code: Int)to prevent line-end occurrences for opening brackets and quotation marks (“‘(《【).Text.splitRawTextto safely backtrack to valid line breaks.3.
hxd/fmt/bfnt/FontParser.hx- Multi-Page BMFont Supporttiles[page].4.
hxd/res/BDFFont.hx- Shelf Bin-Packing5.
hxd/res/DefaultFont.hx- Built-in Chinese Pixel FontdefaultFontChinese.png: 1024x1024 lossless RGBA 1:1 pixel atlas.defaultFontChinese.fnt: Compact BMFont binary descriptor.DefaultFont.getChinese().DefaultFont.get()to automatically attachfnt.fallback = getChinese(). Any standardnew h2d.Text(DefaultFont.get())immediately renders Chinese without any extra setup.6.
h3d/prim/ModelDatabase.hx- Cross-Platform JS Fix@:privateAccess fs.convertinside#if (sys || nodejs)to prevent compile errors when targeting browser JavaScript.🧪 Verification & Real-World Validation / 验证与实战落地
🔒 Backward Compatibility / 向后兼容性
fallbackretain their original behavior.