From e97d82b6e58f417546c738edba40e7ede4f41ea3 Mon Sep 17 00:00:00 2001 From: Greg Humphreys Date: Wed, 8 Oct 2014 12:04:20 -0400 Subject: [PATCH] In the generated fiddle, set the portable fonts flag first. BUG=skia: TBR=jcgregorio Review URL: https://codereview.chromium.org/635373002 --- experimental/webtry/build | 1 + experimental/webtry/webtry.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/experimental/webtry/build b/experimental/webtry/build index ace33b1..0dc6b63 100755 --- a/experimental/webtry/build +++ b/experimental/webtry/build @@ -20,6 +20,7 @@ cd ${SKIA_ROOT}/include echo "Creating compile template..." find core effects pathops -maxdepth 1 -name "*.h" | sed "s/.*\///" | sed "s/\(.*\)/#include \"\1\"/" | sort > ${WEBTRY_ROOT}/templates/template.cpp echo '#include "sk_tool_utils.h"' >> ${WEBTRY_ROOT}/templates/template.cpp +echo '#include "SkCommandLineFlags.h"' >> ${WEBTRY_ROOT}/templates/template.cpp echo '' >> ${WEBTRY_ROOT}/templates/template.cpp echo "SkBitmap source;" >> ${WEBTRY_ROOT}/templates/template.cpp echo "{{.Code}}" >> ${WEBTRY_ROOT}/templates/template.cpp diff --git a/experimental/webtry/webtry.go b/experimental/webtry/webtry.go index 36c7afe..947eca7 100644 --- a/experimental/webtry/webtry.go +++ b/experimental/webtry/webtry.go @@ -372,11 +372,12 @@ func expandCode(code string, source int) (string, error) { // TODO(humper): Make this more robust, supporting things like setTypeface inputCodeLines := strings.Split(code, "\n") - outputCodeLines := []string{} + outputCodeLines := []string{"DECLARE_bool(portableFonts);"} for _, line := range inputCodeLines { outputCodeLines = append(outputCodeLines, line) - if strings.HasPrefix(strings.TrimSpace(line), "SkPaint ") { - outputCodeLines = append(outputCodeLines, "sk_tool_utils::set_portable_typeface(&p);") + if strings.HasPrefix(strings.TrimSpace(line), "SkPaint p") { + outputCodeLines = append(outputCodeLines, "FLAGS_portableFonts = true;") + outputCodeLines = append(outputCodeLines, "sk_tool_utils::set_portable_typeface(&p, \"Helvetica\", SkTypeface::kNormal);") } } -- 2.7.4