-
-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add arg to gen_font.py to gen C data
- usage with `--gen-c` - default is now Rust [no changelog]
- Loading branch information
Showing
3 changed files
with
239 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! This file is generated by core/tools/codegen/gen_font.py | ||
#![cfg_attr(any(), rustfmt::skip)] | ||
#![allow(non_upper_case_globals)] | ||
// Each glyph: | ||
// - first two bytes: width, height | ||
// - next three bytes: advance, bearingX, bearingY | ||
// - rest is packed ${bpp}-bit glyph data | ||
|
||
use crate::ui::display::font::FontInfo; | ||
|
||
% for g in glyphs: | ||
/// '${g["char"]}' (ASCII ${g["ascii"]}) | ||
const ${g["var_name"]}: [u8; ${g["arr_len"]}] = [ ${g["arr_content"]} ]; | ||
|
||
% endfor | ||
/// Nonprintable glyph (inverse colors of '?') | ||
const ${nonprintable["var_name"]}: [u8; ${nonprintable["arr_len"]}] = [ ${nonprintable["arr_content"]} ]; | ||
% if gen_normal: | ||
|
||
/// Array of references for '${name}' normal ASCII glyphs | ||
const Font_${name}: [&[u8]; ${len(glyph_array)}] = [ | ||
% for ref in glyph_array: | ||
${ref}, | ||
% endfor | ||
]; | ||
% endif | ||
% if gen_upper: | ||
|
||
/// Array of references for '${name}' ASCII glyphs (forced uppercase) | ||
const Font_${name}_upper: [&[u8]; ${len(glyph_array_upper)}] = [ | ||
% for ref in glyph_array_upper: | ||
${ref}, | ||
% endfor | ||
]; | ||
% endif | ||
% if gen_normal: | ||
|
||
/// FontInfo struct for normal ASCII usage | ||
pub const Font_${name}_info: FontInfo = FontInfo { | ||
translation_blob_idx: ${font_info["translation_blob_idx"]}, | ||
height: ${font_info["height"]}, | ||
max_height: ${font_info["max_height"]}, | ||
baseline: ${font_info["baseline"]}, | ||
glyph_data: &${font_info["glyph_array"]}, | ||
glyph_nonprintable: &${font_info["nonprintable"]}, | ||
}; | ||
% endif | ||
% if gen_upper: | ||
|
||
/// FontInfo struct for forced uppercase usage | ||
pub const Font_${name}_upper_info: FontInfo = FontInfo { | ||
translation_blob_idx: ${font_info_upper["translation_blob_idx"]}, | ||
height: ${font_info_upper["height"]}, | ||
max_height: ${font_info_upper["max_height"]}, | ||
baseline: ${font_info_upper["baseline"]}, | ||
glyph_data: &${font_info_upper["glyph_array"]}, | ||
glyph_nonprintable: &${font_info_upper["nonprintable"]}, | ||
}; | ||
% endif |
This file contains 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