[canvaskit] Allow users to load their own fonts
Instead of using the test font(s), now ship with a small
(100k) Monospace font. This can be disabled by:
compile.sh no_font ...
This saves about 350k (164k gzipped) in binary size.
Bug: skia:
Change-Id: I195e3b35bea86d0f096066c1c6a44a4b602571f3
Reviewed-on: https://skia-review.googlesource.com/c/176580
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/experimental/canvaskit/compile.sh b/experimental/canvaskit/compile.sh
index a7eea23..b915599 100755
--- a/experimental/canvaskit/compile.sh
+++ b/experimental/canvaskit/compile.sh
@@ -96,6 +96,19 @@
HTML_CANVAS_API=""
fi
+BUILTIN_FONT="$BASE_DIR/fonts/NotoMono-Regular.ttf.cpp"
+if [[ $@ == *no_font* ]]; then
+ echo "Omitting the built-in font(s)"
+ BUILTIN_FONT=""
+else
+ # Generate the font's binary file (which is covered by .gitignore)
+ python tools/embed_resources.py \
+ --name SK_EMBEDDED_FONTS \
+ --input $BASE_DIR/fonts/NotoMono-Regular.ttf \
+ --output $BASE_DIR/fonts/NotoMono-Regular.ttf.cpp \
+ --align 4
+fi
+
# Turn off exiting while we check for ninja (which may not be on PATH)
set +e
NINJA=`which ninja`
@@ -191,9 +204,8 @@
--pre-js $BASE_DIR/helper.js \
--pre-js $BASE_DIR/interface.js \
$HTML_CANVAS_API \
+ $BUILTIN_FONT \
$BASE_DIR/canvaskit_bindings.cpp \
- tools/fonts/SkTestFontMgr.cpp \
- tools/fonts/SkTestTypeface.cpp \
$WASM_SKOTTIE \
$WASM_MANAGED_SKOTTIE \
$BUILD_DIR/libskia.a \