mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
generate loader files for the new font
also sort the font files in alphabetical order now, instead of relying on arbitrary ordering of os.listdir() :P
This commit is contained in:
parent
fc9cb5af8c
commit
4454dffe4e
3 changed files with 29 additions and 30 deletions
|
|
@ -9,7 +9,7 @@ from collections import OrderedDict
|
|||
|
||||
"""
|
||||
This script should be run whenever the fonts are updated inside the blitstr dependency. The
|
||||
thought is that this is a rare event, and therefore it's better to run this on the rare occassions
|
||||
thought is that this is a rare event, and therefore it's better to run this on the rare occasions
|
||||
that this happens and vendor in the font files as references to their location in the FLASH
|
||||
memory map.
|
||||
|
||||
|
|
@ -27,39 +27,37 @@ same level as xous-core, but this can be changed with the `-d` command line argu
|
|||
def main():
|
||||
parser = argparse.ArgumentParser(description="Build the Betrusted SoC")
|
||||
parser.add_argument(
|
||||
"-d", "--dir", default="../../../blitstr", help="Location of the blitstr source files", type=str
|
||||
"-d", "--dir", default="../../services/graphics-server/src/blitstr2", help="Location of the blitstr source files", type=str
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
fontdir = args.dir + '/src/fonts'
|
||||
fontdir = args.dir + '/fonts'
|
||||
fontdict = OrderedDict([]) # we want a deterministic dict
|
||||
filter = re.compile('.*DATA.*u32.*[0-9]*.*')
|
||||
with os.scandir(fontdir) as listOfEntries:
|
||||
for entry in listOfEntries:
|
||||
if entry.is_file():
|
||||
print("Processing " + entry.name)
|
||||
modulename = entry.name.split('.')[0]
|
||||
with open(entry) as infile, open('fonts/' + entry.name, 'w') as outfile:
|
||||
outfile.write(
|
||||
"// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
||||
outfile.write("#[allow(dead_code)]\n")
|
||||
outfile.write("#[link_section=\".fontdata\"]\n")
|
||||
outfile.write("#[no_mangle]\n")
|
||||
outfile.write("#[used]\n")
|
||||
filter = re.compile('.*GLYPHS.*u32.*[0-9]*.*')
|
||||
for entry in sorted(os.listdir(fontdir)):
|
||||
print("Processing " + entry)
|
||||
modulename = entry.split('.')[0]
|
||||
with open(fontdir + "/" + entry) as infile, open('fonts/' + entry, 'w') as outfile:
|
||||
outfile.write(
|
||||
"// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
||||
outfile.write("#[allow(dead_code)]\n")
|
||||
outfile.write("#[link_section=\".fontdata\"]\n")
|
||||
outfile.write("#[no_mangle]\n")
|
||||
outfile.write("#[used]\n")
|
||||
copy = False
|
||||
for line in infile:
|
||||
if line.strip().startswith('pub const GLYPHS'):
|
||||
copy = True
|
||||
if copy:
|
||||
fixup = line.replace('pub const', 'pub static')
|
||||
matched = filter.match(fixup)
|
||||
if matched:
|
||||
arraylen = re.findall('\d+', matched.group().split(';')[1])[0]
|
||||
fontdict[modulename] = arraylen
|
||||
fixup = fixup.replace('GLYPHS', 'DATA_' + modulename.upper())
|
||||
outfile.write(fixup)
|
||||
if line.strip() == "];":
|
||||
copy = False
|
||||
for line in infile:
|
||||
if line.strip() == "/// Packed glyph pattern data.":
|
||||
copy = True
|
||||
if copy:
|
||||
fixup = line.replace('pub const', 'pub static')
|
||||
matched = filter.match(fixup)
|
||||
if matched:
|
||||
arraylen = re.findall('\d+', matched.group().split(';')[1])[0]
|
||||
fontdict[modulename] = arraylen
|
||||
fixup = fixup.replace('DATA', 'DATA_' + modulename.upper())
|
||||
outfile.write(fixup)
|
||||
if line.strip() == "];":
|
||||
copy = False
|
||||
print(fontdict)
|
||||
with open('fonts.rs', 'w') as modfile:
|
||||
modfile.write("// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ debugprint = []
|
|||
braille = []
|
||||
gfx-testing = []
|
||||
ditherpunk = []
|
||||
default = ["gfx-testing"]
|
||||
default = []
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ fn map_fonts() -> MemoryRange {
|
|||
blitstr2::fonts::regular::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::REGULAR_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||
blitstr2::fonts::small::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::SMALL_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||
blitstr2::fonts::zh::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::ZH_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||
blitstr2::fonts::tall::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::TALL_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||
|
||||
fontregion
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue