Stashing fonts, start font registry.
This commit is contained in:
11881
ext/fonts/B612Mono.h
Normal file
11881
ext/fonts/B612Mono.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,2 @@
|
||||
#pragma once
|
||||
namespace kte::Fonts {
|
||||
}}
|
||||
namespace kte::Fonts::FiraCode {}
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
namespace kte::Fonts {
|
||||
namespace kte::Fonts::Go {
|
||||
|
||||
|
||||
// File: 'Go/GoMono-BoldItalic.ttf' (188176 bytes)
|
||||
@@ -8610,4 +8610,4 @@ static const unsigned int DefaultFontRegularCompressedData[101204/4] =
|
||||
0x440002b1, 0x066405b3, 0x00444400, 0x5dfa0500, 0x00ae3bb9,
|
||||
};
|
||||
|
||||
}}
|
||||
}
|
||||
20489
ext/fonts/IBMPlexMono.h
20489
ext/fonts/IBMPlexMono.h
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
4
ext/fonts/README.txt
Normal file
4
ext/fonts/README.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
These are the available fonts. Build the binary_to_compressed_c
|
||||
in ../imgui/misc/fonts and put it on your path. These will build
|
||||
static headers containing the fonts to be placed into fonts/
|
||||
as part of the font registry.
|
||||
File diff suppressed because it is too large
Load Diff
2828
ext/fonts/Syne.h
2828
ext/fonts/Syne.h
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import pdb
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
DEFAULT_FONTS = [
|
||||
'B612_Mono',
|
||||
'B612Mono',
|
||||
'BrassMono',
|
||||
'BrassMonoCode',
|
||||
'FiraCode',
|
||||
@@ -18,16 +19,19 @@ DEFAULT_FONTS = [
|
||||
'Syne',
|
||||
]
|
||||
|
||||
|
||||
def generate_font(header_file, path):
|
||||
symbol_name=os.path.splitext(os.path.basename(path))[0]
|
||||
symbol_name=symbol_name.replace('-', '_')
|
||||
symbol_name=symbol_name.split('_')[1]
|
||||
symbol_name = os.path.splitext(os.path.basename(path))[0]
|
||||
symbol_name = symbol_name.replace('-', '_')
|
||||
symbol_name = symbol_name.split('_', 2)[1]
|
||||
|
||||
output = subprocess.check_output(
|
||||
f'binary_to_compressed_c "{path}" DefaultFont{symbol_name}',
|
||||
shell=True)
|
||||
f'binary_to_compressed_c "{path}" DefaultFont{symbol_name}',
|
||||
shell=True)
|
||||
header_file.write('\n\n')
|
||||
header_file.write(output.decode('utf-8'))
|
||||
|
||||
|
||||
def generate_header(header, guard, files):
|
||||
try:
|
||||
os.remove(header)
|
||||
@@ -37,26 +41,28 @@ def generate_header(header, guard, files):
|
||||
raise
|
||||
with open(header, 'wt') as header_file:
|
||||
header_file.write(f"""#pragma once
|
||||
namespace kte::Fonts {{
|
||||
namespace kte::Fonts::{header.removesuffix('.h')} {{
|
||||
""")
|
||||
for file in files:
|
||||
generate_font(header_file, file)
|
||||
|
||||
header_file.write('}}');
|
||||
header_file.write('}');
|
||||
|
||||
subprocess.call("sed -i '' -e 's/_compressed_size/CompressedSize/' "+
|
||||
subprocess.call("sed -i '' -e 's/_compressed_size/CompressedSize/' " +
|
||||
f"{header_file.name}", shell=True)
|
||||
subprocess.call("sed -i '' -e 's/_compressed_data/CompressedData/' " +
|
||||
subprocess.call("sed -i '' -e 's/_compressed_data/CompressedData/' " +
|
||||
f"{header_file.name}", shell=True)
|
||||
|
||||
|
||||
def generate_dir(path):
|
||||
filelist = [os.path.join(path, file) for file in os.listdir(path)
|
||||
if file.endswith('ttf')]
|
||||
namespace = f'kte::{path}'
|
||||
namespace = f'kte::Fonts::{path}'
|
||||
|
||||
header = f"{path.replace('-', '_')}.h"
|
||||
generate_header(header, namespace, filelist)
|
||||
|
||||
|
||||
def main(fonts=None):
|
||||
if fonts is None:
|
||||
fonts = DEFAULT_FONTS
|
||||
@@ -64,6 +70,7 @@ def main(fonts=None):
|
||||
for font in fonts:
|
||||
generate_dir(font)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fonts = None
|
||||
if len(sys.argv) > 1:
|
||||
|
||||
Reference in New Issue
Block a user