-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace MDI_ defines with a map (that gets constructed into memory, s…
…adly)
- Loading branch information
Showing
6 changed files
with
87 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,16 @@ font_mdi_c = xxd_generator.process( | |
extra_args: 'mdi_ttf', | ||
) | ||
|
||
mdimap_prog = find_program('scripts/mdimap.py', required: true) | ||
mdimap_generator = generator( | ||
mdimap_prog, | ||
output: '@[email protected]', | ||
arguments: ['@INPUT@', '@OUTPUT@'], | ||
) | ||
mdimap_cpp = mdimap_generator.process( | ||
'src/fonts/MaterialDesign-Webfont/scss/_variables.scss', | ||
) | ||
|
||
brew_prefix = '/opt/homebrew/include' | ||
brew = find_program('brew', required: false) | ||
if brew.found() | ||
|
@@ -241,6 +251,7 @@ if get_option('front-lvgl').enabled() | |
font_mdi_c, | ||
'src/generated/domains.hpp', | ||
version_file, | ||
mdimap_cpp, | ||
], | ||
install: true, | ||
dependencies: [ | ||
|
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 @@ | ||
#!/usr/bin/env python3 | ||
import re | ||
import sys | ||
|
||
infile = open(sys.argv[1]) | ||
outfile = open(sys.argv[2], 'w') # FIXME tempfile+rename | ||
|
||
# skip until $mdi-icons | ||
for line in infile: | ||
if line.startswith("$mdi-icons"): | ||
break | ||
|
||
icons = dict() | ||
|
||
# now handle all icons | ||
for line in infile: | ||
if not line.startswith(" "): | ||
break | ||
# "ab-testing": F01C9,\n | ||
line = line.strip() | ||
|
||
# "ab-testing": F01C9, | ||
if line.endswith(","): | ||
line = line[:-1] | ||
|
||
# "ab-testing": F01C9 | ||
k, v = line.split(":") | ||
|
||
# k = "ab-testing" (INCLUDING quotes) | ||
# v = F01C9 (no quotes, leading space) | ||
v = v.strip() | ||
|
||
# k = "ab-testing" (INCLUDING quotes) | ||
# v = F01C9 (no quotes, no leading space) | ||
v = repr(chr(int(v, 16)).encode('utf-8'))[2:-1] | ||
|
||
# k = "ab-testing" (INCLUDING quotes) | ||
# v = \\xf3\\xb0\\x87\\x89 (no quotes) | ||
|
||
icons[k] = v | ||
|
||
outfile.write(f"""#include "uicomponents/mdimap.hpp" | ||
static std::map<std::string, std::string> map_name2id = {{ | ||
""") | ||
|
||
|
||
for k, v in icons.items(): | ||
outfile.write(f' {{{k}, "{v}"}},\n') | ||
|
||
outfile.write(""" | ||
}; | ||
// making _name a ref is tempting but currently some code tries to pass simple static "foo" (char array) in | ||
std::string voorkant::mdi::name2id(std::string _name) { | ||
return map_name2id.at(_name); | ||
} | ||
\n""") |
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
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,12 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
namespace voorkant | ||
{ | ||
namespace mdi | ||
{ | ||
std::string name2id(std::string _name); | ||
} | ||
} |
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