mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +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
|
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
|
that this happens and vendor in the font files as references to their location in the FLASH
|
||||||
memory map.
|
memory map.
|
||||||
|
|
||||||
|
|
@ -27,39 +27,37 @@ same level as xous-core, but this can be changed with the `-d` command line argu
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Build the Betrusted SoC")
|
parser = argparse.ArgumentParser(description="Build the Betrusted SoC")
|
||||||
parser.add_argument(
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
fontdir = args.dir + '/src/fonts'
|
fontdir = args.dir + '/fonts'
|
||||||
fontdict = OrderedDict([]) # we want a deterministic dict
|
fontdict = OrderedDict([]) # we want a deterministic dict
|
||||||
filter = re.compile('.*DATA.*u32.*[0-9]*.*')
|
filter = re.compile('.*GLYPHS.*u32.*[0-9]*.*')
|
||||||
with os.scandir(fontdir) as listOfEntries:
|
for entry in sorted(os.listdir(fontdir)):
|
||||||
for entry in listOfEntries:
|
print("Processing " + entry)
|
||||||
if entry.is_file():
|
modulename = entry.split('.')[0]
|
||||||
print("Processing " + entry.name)
|
with open(fontdir + "/" + entry) as infile, open('fonts/' + entry, 'w') as outfile:
|
||||||
modulename = entry.name.split('.')[0]
|
outfile.write(
|
||||||
with open(entry) as infile, open('fonts/' + entry.name, 'w') as outfile:
|
"// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
||||||
outfile.write(
|
outfile.write("#[allow(dead_code)]\n")
|
||||||
"// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
outfile.write("#[link_section=\".fontdata\"]\n")
|
||||||
outfile.write("#[allow(dead_code)]\n")
|
outfile.write("#[no_mangle]\n")
|
||||||
outfile.write("#[link_section=\".fontdata\"]\n")
|
outfile.write("#[used]\n")
|
||||||
outfile.write("#[no_mangle]\n")
|
copy = False
|
||||||
outfile.write("#[used]\n")
|
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
|
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)
|
print(fontdict)
|
||||||
with open('fonts.rs', 'w') as modfile:
|
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")
|
modfile.write("// This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit.\n")
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,4 @@ debugprint = []
|
||||||
braille = []
|
braille = []
|
||||||
gfx-testing = []
|
gfx-testing = []
|
||||||
ditherpunk = []
|
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::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::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::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
|
fontregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue