Merge pull request #731 from betrusted-io/fix-fonts

fix broken font rendering in rust 1.91
This commit is contained in:
bunnie 2025-11-18 00:32:40 +08:00 committed by GitHub
commit b64cff6f86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 115 additions and 103 deletions

View file

@ -1,6 +1,6 @@
{ {
"comment": [ "comment": [
"Config for use with main.go. Before making changes here, see config_editor.rb." "Config for use with main.go. Before making changes here, see config_editor.rb. NOTE: the glyph set list MUST be alphabetized since Rust 1.91"
], ],
"loadermod": [ "loadermod": [
"../../../loader/src/fonts.rs" "../../../loader/src/fonts.rs"
@ -9,6 +9,21 @@
"../src/fontmap.rs" "../src/fontmap.rs"
], ],
"glyphSets": [ "glyphSets": [
{
"name": "Bold",
"sprites": "src_data/latin_bold.png",
"size": 15,
"cols": 16,
"gutter": 1,
"border": 1,
"legal": "src_data/chicago_legal.txt",
"index": "src_data/latin_index.json",
"indexType": "json-grid-coord",
"glyphTrim": "proportional",
"rustout": "../src/fonts/bold.rs",
"loaderout": "../../../loader/src/fonts/bold.rs",
"small": true
},
{ {
"name": "Emoji", "name": "Emoji",
"sprites": "src_data/basic_emoji.png", "sprites": "src_data/basic_emoji.png",
@ -24,21 +39,6 @@
"loaderout": "../../../loader/src/fonts/emoji.rs", "loaderout": "../../../loader/src/fonts/emoji.rs",
"small": true "small": true
}, },
{
"name": "zh",
"sprites": "src_data/hanzi.png",
"size": 16,
"cols": 30,
"gutter": 2,
"border": 2,
"legal": "src_data/hanzi_legal.txt",
"index": "src_data/hanzi.codepoints",
"indexType": "txt-row-major",
"glyphTrim": "CJK",
"rustout": "../src/fonts/zh.rs",
"loaderout": "../../../loader/src/fonts/zh.rs",
"small": false
},
{ {
"name": "ja", "name": "ja",
"sprites": "src_data/Izumi16.png", "sprites": "src_data/Izumi16.png",
@ -69,21 +69,6 @@
"loaderout": "../../../loader/src/fonts/kr.rs", "loaderout": "../../../loader/src/fonts/kr.rs",
"small": false "small": false
}, },
{
"name": "Bold",
"sprites": "src_data/latin_bold.png",
"size": 15,
"cols": 16,
"gutter": 1,
"border": 1,
"legal": "src_data/chicago_legal.txt",
"index": "src_data/latin_index.json",
"indexType": "json-grid-coord",
"glyphTrim": "proportional",
"rustout": "../src/fonts/bold.rs",
"loaderout": "../../../loader/src/fonts/bold.rs",
"small": true
},
{ {
"name": "Mono", "name": "Mono",
"sprites": "src_data/latin_mono.png", "sprites": "src_data/latin_mono.png",
@ -114,6 +99,21 @@
"loaderout": "../../../loader/src/fonts/regular.rs", "loaderout": "../../../loader/src/fonts/regular.rs",
"small": true "small": true
}, },
{
"name": "Small",
"sprites": "src_data/latin_small.png",
"size": 12,
"cols": 16,
"gutter": 1,
"border": 1,
"legal": "src_data/geneva_legal.txt",
"index": "src_data/latin_index.json",
"indexType": "json-grid-coord",
"glyphTrim": "proportional",
"rustout": "../src/fonts/small.rs",
"loaderout": "../../../loader/src/fonts/small.rs",
"small": true
},
{ {
"name": "Tall", "name": "Tall",
"sprites": "src_data/latin_tall.png", "sprites": "src_data/latin_tall.png",
@ -130,19 +130,19 @@
"small": true "small": true
}, },
{ {
"name": "Small", "name": "zh",
"sprites": "src_data/latin_small.png", "sprites": "src_data/hanzi.png",
"size": 12, "size": 16,
"cols": 16, "cols": 30,
"gutter": 1, "gutter": 2,
"border": 1, "border": 2,
"legal": "src_data/geneva_legal.txt", "legal": "src_data/hanzi_legal.txt",
"index": "src_data/latin_index.json", "index": "src_data/hanzi.codepoints",
"indexType": "json-grid-coord", "indexType": "txt-row-major",
"glyphTrim": "proportional", "glyphTrim": "CJK",
"rustout": "../src/fonts/small.rs", "rustout": "../src/fonts/zh.rs",
"loaderout": "../../../loader/src/fonts/small.rs", "loaderout": "../../../loader/src/fonts/zh.rs",
"small": true "small": false
} }
] ]
} }

View file

@ -20,7 +20,7 @@ latin_index_outfile = "src_data/latin_index.json"
config = { config = {
comment: [ comment: [
"Config for use with main.go. Before making changes here, see config_editor.rb.", "Config for use with main.go. Before making changes here, see config_editor.rb. NOTE: the glyph set list MUST be alphabetized since Rust 1.91",
], ],
loadermod: [ loadermod: [
"../../../../../loader/src/fonts.rs", "../../../../../loader/src/fonts.rs",
@ -29,6 +29,16 @@ config = {
"../../fontmap.rs", "../../fontmap.rs",
], ],
glyphSets: [ glyphSets: [
{
name: "Bold",
sprites: "src_data/latin_bold.png", size: 15, cols: 16, gutter: 1, border: 1,
legal: "src_data/chicago_legal.txt",
index: latin_index_outfile,
indexType: "json-grid-coord",
glyphTrim: "proportional",
rustout: "../fonts/bold.rs",
loaderout: "../../../../../loader/src/fonts/bold.rs",
},
{ {
name: "Emoji", name: "Emoji",
sprites: "src_data/basic_emoji.png", size: 16, cols: 30, gutter: 2, border: 2, sprites: "src_data/basic_emoji.png", size: 16, cols: 30, gutter: 2, border: 2,
@ -39,16 +49,6 @@ config = {
rustout: "../fonts/emoji.rs", rustout: "../fonts/emoji.rs",
loaderout: "../../../../../loader/src/fonts/emoji.rs", loaderout: "../../../../../loader/src/fonts/emoji.rs",
}, },
{
name: "zh",
sprites: "src_data/hanzi.png", size: 16, cols: 30, gutter: 2, border: 2,
legal: "src_data/hanzi_legal.txt",
index: "src_data/hanzi.codepoints",
indexType: "txt-row-major",
glyphTrim: "CJK",
rustout: "../fonts/zh.rs",
loaderout: "../../../../../loader/src/fonts/zh.rs",
},
{ {
name: "ja", name: "ja",
sprites: "src_data/Izumi16.png", size: 16, cols: 30, gutter: 2, border: 2, sprites: "src_data/Izumi16.png", size: 16, cols: 30, gutter: 2, border: 2,
@ -69,16 +69,6 @@ config = {
rustout: "../fonts/kr.rs", rustout: "../fonts/kr.rs",
loaderout: "../../../../../loader/src/fonts/kr.rs", loaderout: "../../../../../loader/src/fonts/kr.rs",
}, },
{
name: "Bold",
sprites: "src_data/latin_bold.png", size: 15, cols: 16, gutter: 1, border: 1,
legal: "src_data/chicago_legal.txt",
index: latin_index_outfile,
indexType: "json-grid-coord",
glyphTrim: "proportional",
rustout: "../fonts/bold.rs",
loaderout: "../../../../../loader/src/fonts/bold.rs",
},
{ {
name: "Mono", name: "Mono",
sprites: "src_data/latin_mono.png", size: 15, cols: 16, gutter: 1, border: 1, sprites: "src_data/latin_mono.png", size: 15, cols: 16, gutter: 1, border: 1,
@ -99,6 +89,16 @@ config = {
rustout: "../fonts/regular.rs", rustout: "../fonts/regular.rs",
loaderout: "../../../../../loader/src/fonts/regular.rs", loaderout: "../../../../../loader/src/fonts/regular.rs",
}, },
{
name: "Small",
sprites: "src_data/latin_small.png", size: 12, cols: 16, gutter: 1, border: 1,
legal: "src_data/geneva_legal.txt",
index: latin_index_outfile,
indexType: "json-grid-coord",
glyphTrim: "proportional",
rustout: "../fonts/small.rs",
loaderout: "../../../../../loader/src/fonts/small.rs",
},
{ {
name: "Tall", name: "Tall",
sprites: "src_data/latin_tall.png", size: 19, cols: 30, gutter: 1, border: 1, sprites: "src_data/latin_tall.png", size: 19, cols: 30, gutter: 1, border: 1,
@ -110,15 +110,15 @@ config = {
loaderout: "../../../../../loader/src/fonts/tall.rs", loaderout: "../../../../../loader/src/fonts/tall.rs",
}, },
{ {
name: "Small", name: "zh",
sprites: "src_data/latin_small.png", size: 12, cols: 16, gutter: 1, border: 1, sprites: "src_data/hanzi.png", size: 16, cols: 30, gutter: 2, border: 2,
legal: "src_data/geneva_legal.txt", legal: "src_data/hanzi_legal.txt",
index: latin_index_outfile, index: "src_data/hanzi.codepoints",
indexType: "json-grid-coord", indexType: "txt-row-major",
glyphTrim: "proportional", glyphTrim: "CJK",
rustout: "../fonts/small.rs", rustout: "../fonts/zh.rs",
loaderout: "../../../../../loader/src/fonts/small.rs", loaderout: "../../../../../loader/src/fonts/zh.rs",
} },
] ]
} }

View file

@ -171,6 +171,10 @@ const loadermodTemplate = `#![cfg_attr(rustfmt, rustfmt_skip)]
// DO NOT MAKE EDITS HERE because this file is automatically generated. // DO NOT MAKE EDITS HERE because this file is automatically generated.
// The order of these modules affects the link order in the loader, which is referred to in the graphics engine. // The order of these modules affects the link order in the loader, which is referred to in the graphics engine.
// To make changes, see <xous_root>/libs/blitstr2/codegen/main.go // To make changes, see <xous_root>/libs/blitstr2/codegen/main.go
// NOTE: this list must be in alphabetical order since Rust 1.91.0. If it is not alphabetized,
// the linker will re-order them into allphabetical order, messing up the offsets.
{{range $f := .FontDir}} {{range $f := .FontDir}}
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod {{$f.Name}};{{end}} pub mod {{$f.Name}};{{end}}
@ -184,6 +188,8 @@ const fontmapTemplate = `#![cfg_attr(rustfmt, rustfmt_skip)]
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const FONT_BASE: usize = 0x2053_0000; pub const FONT_BASE: usize = 0x2053_0000;
// NOTE: this list must be in alphabetical order since Rust 1.91.0. If it is not alphabetized,
// the linker will re-order them into allphabetical order, messing up the offsets.
{{range $f := .FontDir}}#[cfg(not(feature = "bao1x"))] {{range $f := .FontDir}}#[cfg(not(feature = "bao1x"))]
pub const {{$f.Name}}: usize = 0x{{$f.Len}}; pub const {{$f.Name}}: usize = 0x{{$f.Len}};
{{end}} {{end}}

View file

@ -6,42 +6,44 @@
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const FONT_BASE: usize = 0x2053_0000; pub const FONT_BASE: usize = 0x2053_0000;
// NOTE: this list must be in alphabetical order since Rust 1.91.0. If it is not alphabetized,
// the linker will re-order them into allphabetical order, messing up the offsets.
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const EMOJI_OFFSET: usize = 0x0; pub const BOLD_OFFSET: usize = 0x0;
#[cfg(not(feature = "bao1x"))]
pub const EMOJI_LEN: usize = 0xab00;
#[cfg(not(feature = "bao1x"))]
pub const ZH_OFFSET: usize = 0xab00;
#[cfg(not(feature = "bao1x"))]
pub const ZH_LEN: usize = 0x3fea0;
#[cfg(not(feature = "bao1x"))]
pub const JA_OFFSET: usize = 0x4a9a0;
#[cfg(not(feature = "bao1x"))]
pub const JA_LEN: usize = 0x56920;
#[cfg(not(feature = "bao1x"))]
pub const KR_OFFSET: usize = 0xa12c0;
#[cfg(not(feature = "bao1x"))]
pub const KR_LEN: usize = 0x61600;
#[cfg(not(feature = "bao1x"))]
pub const BOLD_OFFSET: usize = 0x1028c0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const BOLD_LEN: usize = 0x19e0; pub const BOLD_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const MONO_OFFSET: usize = 0x1042a0; pub const EMOJI_OFFSET: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))]
pub const EMOJI_LEN: usize = 0xab00;
#[cfg(not(feature = "bao1x"))]
pub const JA_OFFSET: usize = 0xc4e0;
#[cfg(not(feature = "bao1x"))]
pub const JA_LEN: usize = 0x56920;
#[cfg(not(feature = "bao1x"))]
pub const KR_OFFSET: usize = 0x62e00;
#[cfg(not(feature = "bao1x"))]
pub const KR_LEN: usize = 0x61600;
#[cfg(not(feature = "bao1x"))]
pub const MONO_OFFSET: usize = 0xc4400;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const MONO_LEN: usize = 0x19e0; pub const MONO_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const REGULAR_OFFSET: usize = 0x105c80; pub const REGULAR_OFFSET: usize = 0xc5de0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const REGULAR_LEN: usize = 0x19e0; pub const REGULAR_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const TALL_OFFSET: usize = 0x107660; pub const SMALL_OFFSET: usize = 0xc77c0;
#[cfg(not(feature = "bao1x"))]
pub const TALL_LEN: usize = 0x6780;
#[cfg(not(feature = "bao1x"))]
pub const SMALL_OFFSET: usize = 0x10dde0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const SMALL_LEN: usize = 0x19e0; pub const SMALL_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub const TALL_OFFSET: usize = 0xc91a0;
#[cfg(not(feature = "bao1x"))]
pub const TALL_LEN: usize = 0x6780;
#[cfg(not(feature = "bao1x"))]
pub const ZH_OFFSET: usize = 0xcf920;
#[cfg(not(feature = "bao1x"))]
pub const ZH_LEN: usize = 0x3fea0;
#[cfg(not(feature = "bao1x"))]
pub const FONT_TOTAL_LEN: usize = 0x10f7c0; pub const FONT_TOTAL_LEN: usize = 0x10f7c0;

View file

@ -3,21 +3,25 @@
// The order of these modules affects the link order in the loader, which is referred to in the graphics engine. // The order of these modules affects the link order in the loader, which is referred to in the graphics engine.
// To make changes, see <xous_root>/libs/blitstr2/codegen/main.go // To make changes, see <xous_root>/libs/blitstr2/codegen/main.go
// NOTE: this list must be in alphabetical order since Rust 1.91.0. If it is not alphabetized,
// the linker will re-order them into allphabetical order, messing up the offsets.
#[cfg(not(feature = "bao1x"))]
pub mod bold;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod emoji; pub mod emoji;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod zh;
#[cfg(not(feature = "bao1x"))]
pub mod ja; pub mod ja;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod kr; pub mod kr;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod bold;
#[cfg(not(feature = "bao1x"))]
pub mod mono; pub mod mono;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod regular; pub mod regular;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod small;
#[cfg(not(feature = "bao1x"))]
pub mod tall; pub mod tall;
#[cfg(not(feature = "bao1x"))] #[cfg(not(feature = "bao1x"))]
pub mod small; pub mod zh;