diff --git a/dm/DM.cpp b/dm/DM.cpp index 6d48bc86f9..9db3154884 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -23,7 +23,6 @@ #include "SkDebugfTracer.h" #include "SkDocument.h" #include "SkFontMgr.h" -#include "SkFontMgrPriv.h" #include "SkGraphics.h" #include "SkHalf.h" #include "SkICC.h" @@ -37,7 +36,6 @@ #include "SkTaskGroup.h" #include "SkTypeface_win.h" #include "Test.h" -#include "TestFontMgr.h" #include "ToolUtils.h" #include "ios_utils.h" @@ -98,8 +96,6 @@ static DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execu static DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821 -static DEFINE_bool(gdi, false, "On Windows, use GDI instead of DirectWrite for font rendering."); - static DEFINE_bool(checkF16, false, "Ensure that F16Norm pixels are clamped."); static DEFINE_string(colorImages, "", @@ -1533,16 +1529,6 @@ int main(int argc, char** argv) { #endif CommandLineFlags::Parse(argc, argv); - if (!FLAGS_nativeFonts) { - gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; - } - -#if defined(SK_BUILD_FOR_WIN) - if (FLAGS_gdi) { - gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI; - } -#endif - initializeEventTracingForTools(); #if !defined(SK_BUILD_FOR_GOOGLE3) && defined(SK_BUILD_FOR_IOS) @@ -1551,6 +1537,7 @@ int main(int argc, char** argv) { setbuf(stdout, nullptr); setup_crash_handler(); + ToolUtils::SetDefaultFontMgr(); SetAnalyticAAFromCommonFlags(); if (FLAGS_forceRasterPipeline) { diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp index 5fc5f2248b..ec413b569a 100644 --- a/tools/ToolUtils.cpp +++ b/tools/ToolUtils.cpp @@ -6,12 +6,14 @@ */ #include "ToolUtils.h" +#include "CommandLineFlags.h" #include "SkBitmap.h" #include "SkBlendMode.h" #include "SkCanvas.h" #include "SkColorData.h" #include "SkColorPriv.h" #include "SkFloatingPoint.h" +#include "SkFontMgrPriv.h" #include "SkFontPriv.h" #include "SkImage.h" #include "SkMatrix.h" @@ -24,6 +26,8 @@ #include "SkShader.h" #include "SkSurface.h" #include "SkTextBlob.h" +#include "SkTypeface_win.h" +#include "TestFontMgr.h" #include #include @@ -436,4 +440,24 @@ sk_sp makeSurface(SkCanvas* canvas, } return surf; } + +static DEFINE_bool(nativeFonts, true, + "If true, use native font manager and rendering. " + "If false, fonts will draw as portably as possible."); +#if defined(SK_BUILD_FOR_WIN) + static DEFINE_bool(gdi, false, + "Use GDI instead of DirectWrite for font rendering."); +#endif + +void SetDefaultFontMgr() { + if (!FLAGS_nativeFonts) { + gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; + } +#if defined(SK_BUILD_FOR_WIN) + if (FLAGS_gdi) { + gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI; + } +#endif +} + } // namespace ToolUtils diff --git a/tools/ToolUtils.h b/tools/ToolUtils.h index f01244821b..383c1d2121 100644 --- a/tools/ToolUtils.h +++ b/tools/ToolUtils.h @@ -69,6 +69,12 @@ static inline sk_sp create_portable_typeface() { return create_portable_typeface(nullptr, SkFontStyle()); } +/** + * Turn on portable (--nonativeFonts) or GDI font rendering (--gdi). + */ +void SetDefaultFontMgr(); + + void get_text_path(const SkFont&, const void* text, size_t length, diff --git a/tools/flags/CommonFlags.cpp b/tools/flags/CommonFlags.cpp index 7bdd86bc00..7d42204418 100644 --- a/tools/flags/CommonFlags.cpp +++ b/tools/flags/CommonFlags.cpp @@ -36,11 +36,6 @@ DEFINE_string(skps, "skps", "Directory to read skps from."); DEFINE_string(lotties, "lotties", "Directory to read (Bodymovin) jsons from."); #endif -DEFINE_bool(nativeFonts, - true, - "If true, use native font manager and rendering. " - "If false, fonts will draw as portably as possible."); - DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file."); DEFINE_int_2(threads, diff --git a/tools/flags/CommonFlags.h b/tools/flags/CommonFlags.h index 3207a62347..04581e0e96 100644 --- a/tools/flags/CommonFlags.h +++ b/tools/flags/CommonFlags.h @@ -17,7 +17,6 @@ DECLARE_bool(quiet); DECLARE_string(skps); DECLARE_string(lotties); DECLARE_string(svgs); -DECLARE_bool(nativeFonts); DECLARE_int(threads); DECLARE_string(resourcePath); DECLARE_bool(verbose); diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index fe9fef6f57..6cad26e398 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -20,7 +20,6 @@ #include "SampleSlide.h" #include "SkCanvas.h" #include "SkColorSpacePriv.h" -#include "SkFontMgrPriv.h" #include "SkGraphics.h" #include "SkImagePriv.h" #include "SkJSONWriter.h" @@ -36,7 +35,7 @@ #include "SkTo.h" #include "SlideDir.h" #include "SvgSlide.h" -#include "TestFontMgr.h" +#include "ToolUtils.h" #include "ccpr/GrCoverageCountingPathRenderer.h" #include @@ -245,9 +244,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData) SetResourcePath("/data/local/tmp/resources"); #endif - if (!FLAGS_nativeFonts) { - gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr; - } + ToolUtils::SetDefaultFontMgr(); initializeEventTracingForTools(); static SkTaskGroup::Enabler kTaskGroupEnabler(FLAGS_threads);