ftbench demo with seperate makefile

GSoC-2023-Ahmet
goksu 2 years ago
parent 562f348192
commit 9dd15018c2
No known key found for this signature in database
  1. 1
      .gitignore
  2. 40
      src/tools/ftbench/Makefile
  3. BIN
      src/tools/ftbench/fonts/Arial_subset.ttf
  4. BIN
      src/tools/ftbench/fonts/Roboto_subset.ttf
  5. BIN
      src/tools/ftbench/fonts/Tahoma_subset.ttf
  6. BIN
      src/tools/ftbench/fonts/TimesNewRoman_subset.ttf
  7. BIN
      src/tools/ftbench/fonts/Verdana_subset.ttf
  8. 15
      src/tools/ftbench/fonts/sub.sh
  9. 1613
      src/tools/ftbench/ftbench.c
  10. 44
      src/tools/ftbench/mlgetopt.h

1
.gitignore vendored

@ -5,3 +5,4 @@ src/dlg/dlg.c
subprojects/*
!subprojects/*.wrap
/tests/data/*
.DS_Store

@ -0,0 +1,40 @@
# Variables
FTBENCH_SRC = ftbench.c
FTBENCH_BIN = bench.out
FTBENCH_FLAGS = $(shell pkg-config --cflags freetype2) -lfreetype
FONTS = $(wildcard fonts/*.ttf)
BASELINES = $(addprefix baselines/, $(notdir $(FONTS)))
BENCHMARKS = $(addprefix benchmarks/, $(notdir $(FONTS)))
# Default target
all: $(FTBENCH_BIN)
# Build ftbench
$(FTBENCH_BIN): $(FTBENCH_SRC)
gcc $(FTBENCH_FLAGS) $(FTBENCH_SRC) -o $(FTBENCH_BIN)
# Create directories for baselines and benchmarks
baselines/ benchmarks/:
mkdir -p $@
# Create a baseline
.PHONY: baseline
baseline: $(FTBENCH_BIN) baselines/
$(foreach font, $(FONTS), \
./$(FTBENCH_BIN) $(font) > baselines/$(notdir $(font)).txt; \
)
# Benchmark and compare to baseline
.PHONY: benchmark
benchmark: $(FTBENCH_BIN) benchmarks/
$(foreach font, $(FONTS), \
./$(FTBENCH_BIN) $(font) > benchmarks/$(notdir $(font)).txt; \
)
$(foreach font, $(FONTS), \
diff baselines/$(notdir $(font)).txt benchmarks/$(notdir $(font)).txt; \
)
.PHONY: clean
clean:
rm -f $(FTBENCH_BIN)
rm -rf baselines/ benchmarks/

@ -0,0 +1,15 @@
#!/bin/bash
# Define the Unicode range
unicodes="U+0021-007E"
# Loop over all .ttf files in the current directory
for fontfile in *.ttf
do
# Generate the output filename
output="${fontfile%.ttf}_subset.ttf"
# Run the pyftsubset command
pyftsubset "$fontfile" --unicodes=$unicodes --output-file="$output"
done

File diff suppressed because it is too large Load Diff

@ -0,0 +1,44 @@
/*
* This is a cheap replacement for getopt() because that routine is not
* available on some platforms and behaves differently on other platforms.
*
* This code is hereby expressly placed in the public domain.
* mleisher@crl.nmsu.edu (Mark Leisher)
* 10 October 1997
*/
#ifndef MLGETOPT_H_
#define MLGETOPT_H_
#ifdef VMS
#include <stdio.h>
#define getopt local_getopt
#define optind local_optind
#define opterr local_opterr
#define optarg local_optarg
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int opterr;
extern int optind;
extern char* optarg;
extern int getopt(
#ifdef __STDC__
int argc,
char* const* argv,
const char* pattern
#endif
);
#ifdef __cplusplus
}
#endif
#endif /* MLGETOPT_H_ */
/* End */
Loading…
Cancel
Save