mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 02:40:47 +02:00
Compress font data
This commit is contained in:
BIN
data/font.bz2
Normal file
BIN
data/font.bz2
Normal file
Binary file not shown.
13479
data/font.cpp
13479
data/font.cpp
File diff suppressed because it is too large
Load Diff
11
data/font.h
11
data/font.h
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
#define FONT_H 12
|
||||
#ifndef FONTEDITOR
|
||||
extern const unsigned char font_data[];
|
||||
extern const unsigned int font_ptrs[];
|
||||
extern const unsigned int font_ranges[][2];
|
||||
#else
|
||||
extern unsigned char *font_data;
|
||||
extern unsigned int *font_ptrs;
|
||||
extern unsigned int (*font_ranges)[2];
|
||||
#endif
|
@@ -1,9 +1,15 @@
|
||||
to_array = generator(
|
||||
import('python').find_installation('python3'),
|
||||
output: [ '@BASENAME@.cpp', '@BASENAME@.h' ],
|
||||
arguments: [ join_paths(meson.current_source_dir(), 'to_array.py'), '@BUILD_DIR@', '@OUTPUT0@', '@OUTPUT1@', '@INPUT@', '@EXTRA_ARGS@' ]
|
||||
)
|
||||
|
||||
data_files = files(
|
||||
'font.cpp',
|
||||
'hmap.cpp',
|
||||
'icon.cpp',
|
||||
'images.cpp',
|
||||
)
|
||||
data_files += to_array.process('font.bz2', extra_args: 'compressed_font_data')
|
||||
|
||||
powder_files += data_files
|
||||
render_files += data_files
|
||||
|
16
data/to_array.py
Normal file
16
data/to_array.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
|
||||
build_dir = sys.argv[1]
|
||||
output_cpp = sys.argv[2]
|
||||
output_h = sys.argv[3]
|
||||
input_any = sys.argv[4]
|
||||
symbol_name = sys.argv[5]
|
||||
|
||||
with open(input_any, 'rb') as input_any_f:
|
||||
data = input_any_f.read()
|
||||
|
||||
with open(output_cpp, 'w') as output_cpp_f:
|
||||
output_cpp_f.write('#include "{0}"\nconst unsigned char {1}[] = {{ {2} }}; const unsigned int {1}_size = {3};\n'.format(output_h, symbol_name, ','.join([ str(b) for b in data ]), len(data)))
|
||||
|
||||
with open(output_h, 'w') as output_h_f:
|
||||
output_h_f.write('#pragma once\nextern const unsigned char {0}[]; extern const unsigned int {0}_size;\n'.format(symbol_name))
|
Reference in New Issue
Block a user