html font names

This commit is contained in:
goksu 2023-07-05 14:00:12 +03:00
parent e536bca36f
commit 1afa5619ba
No known key found for this signature in database
2 changed files with 9 additions and 4 deletions

View File

@ -3,6 +3,7 @@ FTBENCH_DIR = $(TOP_DIR)/src/tools/ftbench
FTBENCH_SRC = $(FTBENCH_DIR)/ftbench.c
FTBENCH_BIN = $(OBJ_DIR)/bench.o
FTBENCH_FLAG ?= -c 200
INCLUDES = -I$(TOP_DIR)/include
FONTS = $(wildcard $(FTBENCH_DIR)/fonts/*.ttf)
BASELINE = $(addprefix $(FTBENCH_DIR)/baseline/, $(notdir $(FONTS:.ttf=.txt)))
BENCHMARK = $(addprefix $(FTBENCH_DIR)/benchmark/, $(notdir $(FONTS:.ttf=.txt)))
@ -15,13 +16,12 @@ HTMLFILE = $(TOP_DIR)/benchmark.html
# Create directories for baseline and benchmark
$(OBJ_DIR) $(BASELINE_DIR) $(BENCHMARK_DIR):
@echo "Creating directory..."
@mkdir -p $@
# Build ftbench
$(FTBENCH_BIN): $(FTBENCH_SRC) | $(OBJ_DIR)
@echo "Building ftbench..."
@$(CC) -I$(TOP_DIR)/include -lfreetype $< -o $@
$(CC) $(INCLUDES) $< -lfreetype -o $@
# Create a baseline
.PHONY: baseline

View File

@ -43,12 +43,17 @@ with open(benchmark_html, 'w') as html_file:
# Traverse through the 'baseline' directory
for filename in os.listdir(baseline_dir):
if filename != 'info.txt':
# If it's not the info file, it's a font file
fontname = filename.split('.')[0]
with open(os.path.join(baseline_dir, filename), 'r') as f:
baseline_results = f.readlines()
with open(os.path.join(benchmark_dir, filename), 'r') as f:
benchmark_results = f.readlines()
# Get font name from within the .txt file
for line in baseline_results:
if line.startswith("ftbench results for font"):
fontname = line.split('/')[-1].strip("'")[:-2]
# Write results to HTML
html_file.write('<h2>Results for {}</h2>\n'.format(fontname))