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": [
"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": [
"../../../loader/src/fonts.rs"
@ -9,6 +9,21 @@
"../src/fontmap.rs"
],
"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",
"sprites": "src_data/basic_emoji.png",
@ -24,21 +39,6 @@
"loaderout": "../../../loader/src/fonts/emoji.rs",
"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",
"sprites": "src_data/Izumi16.png",
@ -69,21 +69,6 @@
"loaderout": "../../../loader/src/fonts/kr.rs",
"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",
"sprites": "src_data/latin_mono.png",
@ -114,6 +99,21 @@
"loaderout": "../../../loader/src/fonts/regular.rs",
"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",
"sprites": "src_data/latin_tall.png",
@ -130,19 +130,19 @@
"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": "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
}
]
}

View file

@ -20,7 +20,7 @@ latin_index_outfile = "src_data/latin_index.json"
config = {
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: [
"../../../../../loader/src/fonts.rs",
@ -29,6 +29,16 @@ config = {
"../../fontmap.rs",
],
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",
sprites: "src_data/basic_emoji.png", size: 16, cols: 30, gutter: 2, border: 2,
@ -39,16 +49,6 @@ config = {
rustout: "../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",
sprites: "src_data/Izumi16.png", size: 16, cols: 30, gutter: 2, border: 2,
@ -69,16 +69,6 @@ config = {
rustout: "../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",
sprites: "src_data/latin_mono.png", size: 15, cols: 16, gutter: 1, border: 1,
@ -99,6 +89,16 @@ config = {
rustout: "../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",
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",
},
{
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: "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",
},
]
}

View file

@ -171,6 +171,10 @@ const loadermodTemplate = `#![cfg_attr(rustfmt, rustfmt_skip)]
// 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.
// 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}}
#[cfg(not(feature = "bao1x"))]
pub mod {{$f.Name}};{{end}}
@ -184,6 +188,8 @@ const fontmapTemplate = `#![cfg_attr(rustfmt, rustfmt_skip)]
#[cfg(not(feature = "bao1x"))]
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"))]
pub const {{$f.Name}}: usize = 0x{{$f.Len}};
{{end}}

View file

@ -6,42 +6,44 @@
#[cfg(not(feature = "bao1x"))]
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"))]
pub const EMOJI_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;
pub const BOLD_OFFSET: usize = 0x0;
#[cfg(not(feature = "bao1x"))]
pub const BOLD_LEN: usize = 0x19e0;
#[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"))]
pub const MONO_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))]
pub const REGULAR_OFFSET: usize = 0x105c80;
pub const REGULAR_OFFSET: usize = 0xc5de0;
#[cfg(not(feature = "bao1x"))]
pub const REGULAR_LEN: usize = 0x19e0;
#[cfg(not(feature = "bao1x"))]
pub const TALL_OFFSET: usize = 0x107660;
#[cfg(not(feature = "bao1x"))]
pub const TALL_LEN: usize = 0x6780;
#[cfg(not(feature = "bao1x"))]
pub const SMALL_OFFSET: usize = 0x10dde0;
pub const SMALL_OFFSET: usize = 0xc77c0;
#[cfg(not(feature = "bao1x"))]
pub const SMALL_LEN: usize = 0x19e0;
#[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;

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.
// 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"))]
pub mod emoji;
#[cfg(not(feature = "bao1x"))]
pub mod zh;
#[cfg(not(feature = "bao1x"))]
pub mod ja;
#[cfg(not(feature = "bao1x"))]
pub mod kr;
#[cfg(not(feature = "bao1x"))]
pub mod bold;
#[cfg(not(feature = "bao1x"))]
pub mod mono;
#[cfg(not(feature = "bao1x"))]
pub mod regular;
#[cfg(not(feature = "bao1x"))]
pub mod small;
#[cfg(not(feature = "bao1x"))]
pub mod tall;
#[cfg(not(feature = "bao1x"))]
pub mod small;
pub mod zh;