Reland "Remove SkFontMgr::RefDefault() and dependent APIs"
This is a reland of commit 3f55be91033222d4b1f174c04f26afc261725b69
Original change's description:
> Remove SkFontMgr::RefDefault() and dependent APIs
>
> To land this in G3, I had to make fontconfig always-on for linux
> builds of skia_public. Since skia_public will soon be going away,
> this should not be too big an issue. I could not turn it only
> on for G3 because some OSes cannot build fontconfig from source.
>
> Will need to remove the things from bazel/common_config_settings/BUILD.bazel
> after G3 is fixed (they are using it in one place)
>
> Bug: b/305780908
> Change-Id: I6eb5c24cc24072575da077278ce28806348f0e7c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/787084
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>
Bug: b/305780908
Change-Id: Idb3c23c589be5e2e64e36ce1210a57016b9abcc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/801656
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/.bazelrc b/.bazelrc
index 123c46a..8e652d4 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -51,7 +51,6 @@
# included when exporting to other projects (CMake, GNI), to
# //bazel/exporter/bazel_query_command.go.
# Public string flags
-build --flag_alias=fontmgr_factory=//bazel/common_config_settings:fontmgr_factory
build --flag_alias=gpu_backend=//src/gpu:gpu_backend
build --flag_alias=include_decoder=//src/codec:include_decoder
build --flag_alias=include_encoder=//src/encode:include_encoder
diff --git a/BUILD.gn b/BUILD.gn
index f48758b..49070d0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -28,14 +28,7 @@
config("skia_public") {
include_dirs = [ "." ]
- defines = [
- "SK_DEFAULT_TYPEFACE_IS_EMPTY",
- "SK_DISABLE_LEGACY_DEFAULT_TYPEFACE",
-
- # TODO(305780908) re-enable after fixing Android and G3
- #"SK_DISABLE_LEGACY_FONTMGR_FACTORY",
- #"SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT",
- ]
+ defines = []
cflags_objcc = []
if (is_component_build) {
defines += [ "SKIA_DLL" ]
@@ -300,15 +293,6 @@
]
}
-group("fontmgr_factory") {
- public_deps = [ skia_fontmgr_factory ]
-}
-
-optional("fontmgr_empty_factory") {
- enabled = true
- sources = [ "src/ports/SkFontMgr_empty_factory.cpp" ]
-}
-
optional("fontmgr_android") {
enabled = skia_enable_fontmgr_android
@@ -325,11 +309,6 @@
]
sources_for_tests = [ "tests/FontMgrAndroidParserTest.cpp" ]
}
-optional("fontmgr_android_factory") {
- enabled = skia_enable_fontmgr_android
- deps = [ ":fontmgr_android" ]
- sources = [ "src/ports/SkFontMgr_android_factory.cpp" ]
-}
optional("fontmgr_custom") {
enabled =
@@ -351,11 +330,6 @@
public = [ "include/ports/SkFontMgr_directory.h" ]
sources = [ "src/ports/SkFontMgr_custom_directory.cpp" ]
}
-optional("fontmgr_custom_directory_factory") {
- enabled = skia_enable_fontmgr_custom_directory
- deps = [ ":fontmgr_custom_directory" ]
- sources = [ "src/ports/SkFontMgr_custom_directory_factory.cpp" ]
-}
optional("fontmgr_custom_embedded") {
enabled = skia_enable_fontmgr_custom_embedded
@@ -366,11 +340,6 @@
]
sources = [ "src/ports/SkFontMgr_custom_embedded.cpp" ]
}
-optional("fontmgr_custom_embedded_factory") {
- enabled = skia_enable_fontmgr_custom_embedded
- deps = [ ":fontmgr_custom_embedded" ]
- sources = [ "src/ports/SkFontMgr_custom_embedded_factory.cpp" ]
-}
optional("fontmgr_custom_empty") {
enabled = skia_enable_fontmgr_custom_empty
@@ -382,11 +351,6 @@
public = [ "include/ports/SkFontMgr_empty.h" ]
sources = [ "src/ports/SkFontMgr_custom_empty.cpp" ]
}
-optional("fontmgr_custom_empty_factory") {
- enabled = skia_enable_fontmgr_custom_empty
- deps = [ ":fontmgr_custom_empty" ]
- sources = [ "src/ports/SkFontMgr_custom_empty_factory.cpp" ]
-}
optional("fontmgr_fontconfig") {
enabled = skia_enable_fontmgr_fontconfig
@@ -399,11 +363,6 @@
sources = [ "src/ports/SkFontMgr_fontconfig.cpp" ]
sources_for_tests = [ "tests/FontMgrFontConfigTest.cpp" ]
}
-optional("fontmgr_fontconfig_factory") {
- enabled = skia_enable_fontmgr_fontconfig
- deps = [ ":fontmgr_fontconfig" ]
- sources = [ "src/ports/SkFontMgr_fontconfig_factory.cpp" ]
-}
optional("fontmgr_FontConfigInterface") {
enabled = skia_enable_fontmgr_FontConfigInterface
@@ -425,11 +384,6 @@
]
sources_for_tests = [ "tests/FCITest.cpp" ]
}
-optional("fontmgr_FontConfigInterface_factory") {
- enabled = skia_enable_fontmgr_FontConfigInterface
- deps = [ ":fontmgr_FontConfigInterface" ]
- sources = [ "src/ports/SkFontMgr_FontConfigInterface_factory.cpp" ]
-}
optional("fontmgr_fuchsia") {
enabled = skia_enable_fontmgr_fuchsia
@@ -484,11 +438,6 @@
]
}
}
-optional("fontmgr_mac_ct_factory") {
- enabled = skia_use_fonthost_mac
- deps = [ ":fontmgr_mac_ct" ]
- sources = [ "src/ports/SkFontMgr_mac_ct_factory.cpp" ]
-}
optional("fontmgr_win") {
enabled = skia_enable_fontmgr_win
@@ -525,11 +474,6 @@
}
}
}
-optional("fontmgr_win_factory") {
- enabled = skia_enable_fontmgr_win
- deps = [ ":fontmgr_win" ]
- sources = [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
-}
optional("fontmgr_win_gdi") {
enabled = skia_enable_fontmgr_win_gdi
@@ -1495,7 +1439,6 @@
deps = [
":android_utils",
":avif",
- ":fontmgr_factory",
":heif",
":hsw",
":jpeg_decode",
diff --git a/bazel/buildrc b/bazel/buildrc
index cae319b..c7490c0 100644
--- a/bazel/buildrc
+++ b/bazel/buildrc
@@ -141,7 +141,7 @@
--include_encoder=jpeg_encode_codec --include_encoder=png_encode_codec \
--include_encoder=webp_encode_codec \
\
- --with_harfbuzz --with_icu --fontmgr_factory=custom_embedded_fontmgr_factory \
+ --with_harfbuzz --with_icu --include_fontmgr=custom_embedded_fontmgr \
--ck_enable_fonts --ck_enable_embedded_font \
\
--disable_tracing --enable_sksl_tracing \
@@ -197,7 +197,7 @@
--gpu_backend=vulkan_ganesh \
--enable_gpu_test_utils \
--include_fontmgr=custom_directory_fontmgr --include_fontmgr=custom_embedded_fontmgr \
- --include_fontmgr=custom_empty_fontmgr --fontmgr_factory=custom_directory_fontmgr_factory \
+ --include_fontmgr=custom_empty_fontmgr \
--include_decoder=avif_decode_codec --include_decoder=gif_decode_codec \
--include_decoder=jpeg_decode_codec --include_decoder=jxl_decode_codec \
--include_decoder=png_decode_codec --include_decoder=raw_decode_codec \
diff --git a/bazel/cc_binary_with_flags.bzl b/bazel/cc_binary_with_flags.bzl
index 2c4527a..798ff0e 100644
--- a/bazel/cc_binary_with_flags.bzl
+++ b/bazel/cc_binary_with_flags.bzl
@@ -26,7 +26,6 @@
]
_string_flags = [
- "//bazel/common_config_settings:fontmgr_factory",
"//src/gpu:with_gl_standard",
"//tools/testrunners/gm/vias:via",
]
diff --git a/bazel/exporter/bazel_query_command.go b/bazel/exporter/bazel_query_command.go
index ff59a65..803e75a 100644
--- a/bazel/exporter/bazel_query_command.go
+++ b/bazel/exporter/bazel_query_command.go
@@ -41,7 +41,6 @@
"--enable_svg_canvas",
"--enable_tracing",
"--enable_vma",
- // "--fontmgr_factory=custom_embedded_fontmgr_factory", // external dependency on ft2build.h
"--gpu_backend=gl_backend",
// "--include_decoder=*", // All decoders have external dependencies.
// "--include_encoder", // All encoders have external dependencies.
diff --git a/defines.bzl b/defines.bzl
index 0b79649..e860a44 100644
--- a/defines.bzl
+++ b/defines.bzl
@@ -7,8 +7,6 @@
GENERAL_DEFINES = [
"SK_GAMMA_APPLY_TO_A8",
- "SK_DEFAULT_TYPEFACE_IS_EMPTY",
- "SK_DISABLE_LEGACY_DEFAULT_TYPEFACE",
] + select({
"//bazel/common_config_settings:debug_build": [
"SK_DEBUG",
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 5dfa134..f95c38c 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1595,9 +1595,6 @@
setbuf(stdout, nullptr);
setup_crash_handler();
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
- ToolUtils::SetDefaultFontMgr();
-#endif
CommonFlags::SetAnalyticAA();
skiatest::SetFontTestDataDirectory();
diff --git a/example/BUILD.bazel b/example/BUILD.bazel
index 9e16fd3..0bfc7aa 100644
--- a/example/BUILD.bazel
+++ b/example/BUILD.bazel
@@ -21,11 +21,6 @@
"with_gl_standard": [
"gl_standard",
],
- # Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
- # as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
- "fontmgr_factory": [
- "custom_directory_fontmgr_factory",
- ],
},
deps = [
"//:skia_public",
@@ -48,11 +43,6 @@
"gpu_backend": [
"vulkan_ganesh",
],
- # Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
- # as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
- "fontmgr_factory": [
- "custom_directory_fontmgr_factory",
- ],
},
deps = [
"//:skia_public",
@@ -72,11 +62,6 @@
"gpu_backend": [
"metal_ganesh",
],
- # Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
- # as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
- "fontmgr_factory": [
- "custom_directory_fontmgr_factory",
- ],
},
deps = [
"//:skia_public",
diff --git a/gn/core.gni b/gn/core.gni
index 509cf35..b834158 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -373,7 +373,6 @@
"$_src/core/SkFontMetricsPriv.cpp",
"$_src/core/SkFontMetricsPriv.h",
"$_src/core/SkFontMgr.cpp",
- "$_src/core/SkFontMgrPriv.h",
"$_src/core/SkFontPriv.h",
"$_src/core/SkFontStream.cpp",
"$_src/core/SkFontStream.h",
diff --git a/gn/skia.gni b/gn/skia.gni
index 8be2f9b..5600916 100644
--- a/gn/skia.gni
+++ b/gn/skia.gni
@@ -171,31 +171,6 @@
skia_libgrapheme_third_party_dir = "//third_party/libgrapheme"
}
-declare_args() {
- # skia_fontmgr_factory should define SkFontMgr::Factory()
- if (skia_enable_fontmgr_empty) {
- skia_fontmgr_factory = ":fontmgr_empty_factory"
- } else if (is_android && skia_enable_fontmgr_android) {
- skia_fontmgr_factory = ":fontmgr_android_factory"
- } else if (is_win && skia_enable_fontmgr_win) {
- skia_fontmgr_factory = ":fontmgr_win_factory"
- } else if ((is_mac || is_ios) && skia_use_fonthost_mac) {
- skia_fontmgr_factory = ":fontmgr_mac_ct_factory"
- } else if (skia_enable_fontmgr_fontconfig) {
- skia_fontmgr_factory = ":fontmgr_fontconfig_factory"
- } else if (skia_enable_fontmgr_custom_directory) {
- skia_fontmgr_factory = ":fontmgr_custom_directory_factory"
- } else if (skia_enable_fontmgr_custom_embedded) {
- skia_fontmgr_factory = ":fontmgr_custom_embedded_factory"
- } else if (skia_enable_fontmgr_custom_empty) {
- skia_fontmgr_factory = ":fontmgr_custom_empty_factory"
- } else {
- #"src/ports/SkFontMgr_FontConfigInterface_factory.cpp" #WontFix
- #"src/ports/SkFontMgr_win_gdi_factory.cpp" # WontFix
- skia_fontmgr_factory = ":fontmgr_empty_factory"
- }
-}
-
assert(!skia_use_dawn || skia_enable_graphite) # Dawn is Graphite-only
# Our tools require static linking (they use non-exported symbols), and the Ganesh backend.
diff --git a/include/core/SkFontMgr.h b/include/core/SkFontMgr.h
index c51b9cd..48f49f6 100644
--- a/include/core/SkFontMgr.h
+++ b/include/core/SkFontMgr.h
@@ -112,11 +112,6 @@
sk_sp<SkTypeface> legacyMakeTypeface(const char familyName[], SkFontStyle style) const;
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- /** Return the default fontmgr. */
- static sk_sp<SkFontMgr> RefDefault();
-#endif
-
/* Returns an empty font manager without any typeface dependencies */
static sk_sp<SkFontMgr> RefEmpty();
@@ -143,12 +138,6 @@
virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const = 0;
virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0;
-
-private:
- /** Implemented by porting layer to return the default factory. */
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
- static sk_sp<SkFontMgr> Factory();
-#endif
};
#endif
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index e195f54..d35396a 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -105,52 +105,9 @@
*/
static bool Equal(const SkTypeface* facea, const SkTypeface* faceb);
-#if !defined(SK_DISABLE_LEGACY_DEFAULT_TYPEFACE)
- /** Returns the default normal typeface, which is never nullptr. */
- static sk_sp<SkTypeface> MakeDefault();
-#endif
/** Returns a non-null typeface which contains no glyphs. */
static sk_sp<SkTypeface> MakeEmpty();
- /** Creates a new reference to the typeface that most closely matches the
- requested familyName and fontStyle. This method allows extended font
- face specifiers as in the SkFontStyle type. Will never return null.
-
- @param familyName May be NULL. The name of the font family.
- @param fontStyle The style of the typeface.
- @return reference to the closest-matching typeface. Call must call
- unref() when they are done.
- Deprecated: call SkFontMgr::matchFamilyStyle or SkFontMgr::legacyMakeTypeface
- */
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static sk_sp<SkTypeface> MakeFromName(const char familyName[], SkFontStyle fontStyle);
-#endif
-
- /** Return a new typeface given a file. If the file does not exist, or is
- not a valid font file, returns nullptr.
- Deprecated: call SkFontMgr::makeFromFile instead
- */
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static sk_sp<SkTypeface> MakeFromFile(const char path[], int index = 0);
-#endif
-
- /** Return a new typeface given a stream and TTC index(pass 0 for none).
- If the stream is not a valid font file, returns nullptr.
- Ownership of the stream is transferred, so the caller must not reference it again.
- Deprecated: call SkFontMgr::makeFromStream instead
- */
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static sk_sp<SkTypeface> MakeFromStream(std::unique_ptr<SkStreamAsset> stream, int index = 0);
-#endif
-
- /** Return a new typeface given a SkData and TTC index (pass 0 for none).
- * If the data is null, or is not a valid font file, returns nullptr.
- * Deprecated: call SkFontMgr::makeFromData instead
- */
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static sk_sp<SkTypeface> MakeFromData(sk_sp<SkData>, int index = 0);
-#endif
-
/** Return a new typeface based on this typeface but parameterized as specified in the
SkFontArguments. If the SkFontArguments does not supply an argument for a parameter
in the font then the value from this typeface will be used as the value for that
@@ -188,9 +145,6 @@
Does not affect ownership of SkStream.
*/
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static sk_sp<SkTypeface> MakeDeserialize(SkStream*);
-#endif
static sk_sp<SkTypeface> MakeDeserialize(SkStream*, sk_sp<SkFontMgr> lastResortMgr);
/**
@@ -466,21 +420,7 @@
friend class SkRandomTypeface; // getAdvancedMetrics
friend class SkPDFFont; // getAdvancedMetrics
- /** Style specifies the intrinsic style attributes of a given typeface */
- enum Style {
- kNormal = 0,
- kBold = 0x01,
- kItalic = 0x02,
-
- // helpers
- kBoldItalic = 0x03
- };
- static SkFontStyle FromOldStyle(Style oldStyle);
- static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
-
- friend class SkFontPriv; // GetDefaultTypeface
- friend class SkPaintPriv; // GetDefaultTypeface
- friend class SkFont; // getGlyphToUnicodeMap
+ friend class SkFontPriv; // getGlyphToUnicodeMap
private:
SkTypefaceID fUniqueID;
diff --git a/include/ports/BUILD.bazel b/include/ports/BUILD.bazel
index 5c9aef7..475ab93 100644
--- a/include/ports/BUILD.bazel
+++ b/include/ports/BUILD.bazel
@@ -43,15 +43,17 @@
name = "fontmgr",
srcs = select_multi(
{
- "//bazel/common_config_settings:uses_android_fontmgr": [":android_fontmgr_hdrs"],
- "//bazel/common_config_settings:uses_custom_directory_fontmgr": [":directory_fontmgr_hdrs"],
- "//bazel/common_config_settings:uses_custom_embedded_fontmgr": [":embedded_fontmgr_hdrs"],
- "//bazel/common_config_settings:uses_custom_empty_fontmgr": [":empty_fontmgr_hdrs"],
- "//bazel/common_config_settings:uses_fontconfig_fontmgr": [":fontconfig_fontmgr_hdrs"],
- "//bazel/common_config_settings:uses_fci_fontmgr": [":fci_fontmgr_hdrs"],
+ "//bazel/common_config_settings:android_fontmgr": [":android_fontmgr_hdrs"],
+ "//bazel/common_config_settings:custom_directory_fontmgr": [":directory_fontmgr_hdrs"],
+ "//bazel/common_config_settings:custom_embedded_fontmgr": [":embedded_fontmgr_hdrs"],
+ "//bazel/common_config_settings:custom_empty_fontmgr": [":empty_fontmgr_hdrs"],
+ "//bazel/common_config_settings:fci_fontmgr": [":fci_fontmgr_hdrs"],
# TODO(kjlubick, bungeman) fuchsia_fontmgr, fontmgr_mac_ct, fontmgr_win
},
- ),
+ ) + select({
+ "@platforms//os:linux": [":fontconfig_fontmgr_hdrs"],
+ "//conditions:default": [],
+ }),
)
skia_filegroup(
diff --git a/include/ports/SkFontConfigInterface.h b/include/ports/SkFontConfigInterface.h
index cd6adca..f8fdca5 100644
--- a/include/ports/SkFontConfigInterface.h
+++ b/include/ports/SkFontConfigInterface.h
@@ -98,9 +98,6 @@
* openStream() using the provided SkFontMgr, but derived classes may implement more
* complex caching schemes.
*/
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity);
-#endif
virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity, sk_sp<SkFontMgr> mgr);
/**
diff --git a/modules/canvaskit/compile.sh b/modules/canvaskit/compile.sh
index 971d740..88b4b46 100755
--- a/modules/canvaskit/compile.sh
+++ b/modules/canvaskit/compile.sh
@@ -118,16 +118,13 @@
ENABLE_FONT="false"
ENABLE_EMBEDDED_FONT="false"
GN_FONT+="skia_enable_fontmgr_custom_embedded=false skia_enable_fontmgr_custom_empty=false "
- GN_FONT+="skia_fontmgr_factory=\":fontmgr_empty_factory\""
elif [[ $@ == *no_embedded_font* ]]; then
echo "Omitting the built-in font(s)"
ENABLE_EMBEDDED_FONT="false"
GN_FONT+="skia_enable_fontmgr_custom_embedded=true skia_enable_fontmgr_custom_empty=true "
- GN_FONT+="skia_fontmgr_factory=\":fontmgr_custom_empty_factory\""
else
# Generate the font's binary file (which is covered by .gitignore)
GN_FONT+="skia_enable_fontmgr_custom_embedded=true skia_enable_fontmgr_custom_empty=false "
- GN_FONT+="skia_fontmgr_factory=\":fontmgr_custom_embedded_factory\""
fi
if [[ $@ == *no_woff2* ]]; then
diff --git a/modules/skottie/BUILD.bazel b/modules/skottie/BUILD.bazel
index d3a1a80..4205594 100644
--- a/modules/skottie/BUILD.bazel
+++ b/modules/skottie/BUILD.bazel
@@ -43,7 +43,7 @@
],
defines = ["CPU_ONLY"],
set_flags = {
- "fontmgr_factory": ["custom_directory_fontmgr_factory"],
+ "include_fontmgr": ["custom_empty_fontmgr"],
"include_decoder": [
"jpeg_decode_codec",
"png_decode_codec",
@@ -68,7 +68,7 @@
defines = ["GPU_ONLY"],
set_flags = {
"enable_gpu_test_utils": ["True"],
- "fontmgr_factory": ["custom_directory_fontmgr_factory"],
+ "include_fontmgr": ["custom_empty_fontmgr"],
"gpu_backend": ["gl_ganesh"],
"include_decoder": [
"jpeg_decode_codec",
diff --git a/modules/skresources/src/SkResources.cpp b/modules/skresources/src/SkResources.cpp
index 4b9e51d..81b6297 100644
--- a/modules/skresources/src/SkResources.cpp
+++ b/modules/skresources/src/SkResources.cpp
@@ -323,11 +323,6 @@
return fFontMgr->makeFromData(std::move(data));
}
}
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
- if (auto data = decode_datauri("data:font/", url)) {
- return SkTypeface::MakeFromData(std::move(data));
- }
-#endif
return this->INHERITED::loadTypeface(name, url);
}
diff --git a/public.bzl b/public.bzl
index 6b0fa90..b6238dd 100644
--- a/public.bzl
+++ b/public.bzl
@@ -481,7 +481,6 @@
"src/core/SkFontMetricsPriv.cpp",
"src/core/SkFontMetricsPriv.h",
"src/core/SkFontMgr.cpp",
- "src/core/SkFontMgrPriv.h",
"src/core/SkFontPriv.h",
"src/core/SkFontStream.cpp",
"src/core/SkFontStream.h",
@@ -1967,7 +1966,6 @@
"src/ports/SkFontMgr_custom_embedded.cpp",
"src/ports/SkFontMgr_custom_empty.cpp",
"src/ports/SkFontMgr_custom.h",
- "src/ports/SkFontMgr_fontconfig_factory.cpp",
"src/ports/SkFontMgr_fontconfig.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkMemory_malloc.cpp",
@@ -1987,7 +1985,6 @@
"src/ports/SkFontHost_FreeType_common.h",
"src/ports/SkFontHost_FreeType.cpp",
"src/ports/SkFontMgr_android.cpp",
- "src/ports/SkFontMgr_android_factory.cpp",
"src/ports/SkFontMgr_android_parser.cpp",
"src/ports/SkFontMgr_android_parser.h",
"src/ports/SkFontMgr_custom.cpp",
@@ -2005,7 +2002,6 @@
PORTS_SRCS_ANDROID_NO_FONT = [
"src/ports/SkDebug_android.cpp",
- "src/ports/SkFontMgr_empty_factory.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkMemory_malloc.cpp",
"src/ports/SkOSFile_posix.cpp",
@@ -2022,7 +2018,6 @@
"src/ports/SkDebug_stdio.cpp",
"src/ports/SkFontMgr_custom.h",
"src/ports/SkFontMgr_mac_ct.cpp",
- "src/ports/SkFontMgr_mac_ct_factory.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkImageGeneratorCG.cpp",
"src/ports/SkMemory_malloc.cpp",
@@ -2050,7 +2045,6 @@
"src/ports/SkFontHost_FreeType.cpp",
"src/ports/SkFontMgr_custom.cpp",
"src/ports/SkFontMgr_custom.h",
- "src/ports/SkFontMgr_empty_factory.cpp",
"src/ports/SkFontMgr_fuchsia.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkMemory_malloc.cpp",
@@ -2075,7 +2069,6 @@
"src/ports/SkFontMgr_custom.h",
"src/ports/SkFontMgr_custom_embedded.cpp",
"src/ports/SkFontMgr_custom_empty.cpp",
- "src/ports/SkFontMgr_empty_factory.cpp",
"src/ports/SkGlobalInitialization_default.cpp",
"src/ports/SkMemory_malloc.cpp",
"src/ports/SkOSFile_posix.cpp",
diff --git a/relnotes/fontmgr.md b/relnotes/fontmgr.md
new file mode 100644
index 0000000..2999bd5
--- /dev/null
+++ b/relnotes/fontmgr.md
@@ -0,0 +1,2 @@
+`SkFontMgr::RefDefault()` has been deleted. Clients should instantiate and manage their own
+`SkFontMgr`s and use them to explicitly create `SkTypeface`s
\ No newline at end of file
diff --git a/src/core/BUILD.bazel b/src/core/BUILD.bazel
index a5696b0..a6de2f6 100644
--- a/src/core/BUILD.bazel
+++ b/src/core/BUILD.bazel
@@ -144,7 +144,6 @@
"SkFontMetricsPriv.cpp",
"SkFontMetricsPriv.h",
"SkFontMgr.cpp",
- "SkFontMgrPriv.h",
"SkFontPriv.h",
"SkFontStream.cpp",
"SkFontStream.h",
@@ -451,7 +450,6 @@
"SkFDot6.h",
"SkFontDescriptor.h",
"SkFontMetricsPriv.h",
- "SkFontMgrPriv.h",
"SkFontPriv.h",
"SkFontStream.h",
"SkGeometry.h",
@@ -839,17 +837,11 @@
"//include/sksl:core_hdrs",
"//include/utils:core_hdrs",
],
- defines = [
- "SK_DISABLE_LEGACY_FONTMGR_FACTORY",
- "SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT",
- "SK_DISABLE_LEGACY_DEFAULT_TYPEFACE",
- ],
features = ["layering_check"],
local_defines = [
"SK_SLUG_DISABLE_LEGACY_DESERIALIZE",
"SK_DISABLE_LEGACY_PNG_WRITEBUFFER",
"SK_DISABLE_LEGACY_IMAGE_READBUFFER",
- "SK_DEFAULT_TYPEFACE_IS_EMPTY",
],
textual_hdrs = [
"//src/opts:textual_hdrs",
diff --git a/src/core/SkFontMgr.cpp b/src/core/SkFontMgr.cpp
index 1378cfb..dd5c420 100644
--- a/src/core/SkFontMgr.cpp
+++ b/src/core/SkFontMgr.cpp
@@ -12,7 +12,6 @@
#include "include/core/SkStream.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
-#include "include/private/base/SkOnce.h"
#include <utility>
@@ -157,27 +156,6 @@
return singleton;
}
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-// A global function pointer that's not declared, but can be overriden at startup by test tools.
-sk_sp<SkFontMgr> (*gSkFontMgr_DefaultFactory)() = nullptr;
-
-sk_sp<SkFontMgr> SkFontMgr::RefDefault() {
- static SkOnce once;
- static sk_sp<SkFontMgr> singleton;
-
- once([]{
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
- sk_sp<SkFontMgr> fm = gSkFontMgr_DefaultFactory ? gSkFontMgr_DefaultFactory()
- : SkFontMgr::Factory();
- singleton = fm ? std::move(fm) : RefEmpty();
-#else
- singleton = RefEmpty();
-#endif
- });
- return singleton;
-}
-#endif // SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT
-
/**
* Width has the greatest priority.
* If the value of pattern.width is 5 (normal) or less,
diff --git a/src/core/SkFontMgrPriv.h b/src/core/SkFontMgrPriv.h
deleted file mode 100644
index cbd7b4a..0000000
--- a/src/core/SkFontMgrPriv.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkFontMgrPriv_DEFINED
-#define SkFontMgrPriv_DEFINED
-
-#include "include/core/SkFontMgr.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-extern sk_sp<SkFontMgr> (*gSkFontMgr_DefaultFactory)();
-
-#endif // SkFontMgrPriv_DEFINED
-
-#endif
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 91cdf7f..e44bacd 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -148,7 +148,11 @@
continue;
}
}
- array[i]->serialize(stream);
+ // With the default serialization and deserialization behavior,
+ // kIncludeDataIfLocal does not always work because there is no default
+ // fontmgr to pass into SkTypeface::MakeDeserialize, so there is no
+ // fontmgr to find a font given the descriptor only.
+ tf->serialize(stream, SkTypeface::SerializeBehavior::kDoIncludeData);
}
}
@@ -347,20 +351,12 @@
tf = procs.fTypefaceProc(&stream, sizeof(stream), procs.fTypefaceCtx);
}
else {
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- tf = SkTypeface::MakeDeserialize(stream, SkFontMgr::RefDefault());
-#else
tf = SkTypeface::MakeDeserialize(stream, nullptr);
-#endif
}
if (!tf) { // failed to deserialize
// fTFPlayback asserts it never has a null, so we plop in
// a default here.
-#if !defined(SK_DISABLE_LEGACY_DEFAULT_TYPEFACE)
- tf = SkTypeface::MakeDefault();
-#else
tf = SkTypeface::MakeEmpty();
-#endif
}
fTFPlayback[i] = std::move(tf);
}
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 42da49e..2c4407b 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -49,7 +49,6 @@
#include <cstddef>
#include <cstring>
-#include <utility>
#include <vector>
using namespace skia_private;
@@ -143,38 +142,6 @@
} // namespace
-SkFontStyle SkTypeface::FromOldStyle(Style oldStyle) {
- return SkFontStyle((oldStyle & SkTypeface::kBold) ? SkFontStyle::kBold_Weight
- : SkFontStyle::kNormal_Weight,
- SkFontStyle::kNormal_Width,
- (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_Slant
- : SkFontStyle::kUpright_Slant);
-}
-
-SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
-#if !defined(SK_DEFAULT_TYPEFACE_IS_EMPTY) && !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
- static SkOnce once[4];
- static sk_sp<SkTypeface> defaults[4];
-
- SkASSERT((int)style < 4);
- once[style]([style] {
- sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
- auto t = fm->legacyMakeTypeface(nullptr, FromOldStyle(style));
- defaults[style] = t ? t : SkEmptyTypeface::Make();
- });
- return defaults[style].get();
-#else
- static sk_sp<SkTypeface> empty = SkEmptyTypeface::Make();
- return empty.get();
-#endif // !defined(SK_DEFAULT_TYPEFACE_IS_EMPTY)
-}
-
-#if !defined(SK_DISABLE_LEGACY_DEFAULT_TYPEFACE)
-sk_sp<SkTypeface> SkTypeface::MakeDefault() {
- return sk_ref_sp(GetDefaultTypeface());
-}
-#endif
-
sk_sp<SkTypeface> SkTypeface::MakeEmpty() {
return SkEmptyTypeface::Make();
}
@@ -220,52 +187,6 @@
} // namespace
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[],
- SkFontStyle fontStyle) {
- if (nullptr == name && (fontStyle.slant() == SkFontStyle::kItalic_Slant ||
- fontStyle.slant() == SkFontStyle::kUpright_Slant) &&
- (fontStyle.weight() == SkFontStyle::kBold_Weight ||
- fontStyle.weight() == SkFontStyle::kNormal_Weight)) {
- return sk_ref_sp(GetDefaultTypeface(static_cast<SkTypeface::Style>(
- (fontStyle.slant() == SkFontStyle::kItalic_Slant ? SkTypeface::kItalic :
- SkTypeface::kNormal) |
- (fontStyle.weight() == SkFontStyle::kBold_Weight ? SkTypeface::kBold :
- SkTypeface::kNormal))));
- }
- return SkFontMgr::RefDefault()->legacyMakeTypeface(name, fontStyle);
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromStream(std::unique_ptr<SkStreamAsset> stream, int index) {
- if (!stream) {
- return nullptr;
- }
- // TODO: Enable this while updating tests (FontHostStream), expectations, and nonativeFonts.
-#if 0
- SkFontArguments args;
- args.setCollectionIndex(index);
- for (const DecoderProc& proc : *decoders()) {
- sk_sp<SkTypeface> typeface = proc.makeFromStream(stream->duplicate(), args);
- if (typeface) {
- return typeface;
- }
- }
-#endif
- return SkFontMgr::RefDefault()->makeFromStream(std::move(stream), index);
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromData(sk_sp<SkData> data, int index) {
- if (!data) {
- return nullptr;
- }
- return SkFontMgr::RefDefault()->makeFromData(std::move(data), index);
-}
-
-sk_sp<SkTypeface> SkTypeface::MakeFromFile(const char path[], int index) {
- return SkFontMgr::RefDefault()->makeFromFile(path, index);
-}
-#endif // !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-
sk_sp<SkTypeface> SkTypeface::makeClone(const SkFontArguments& args) const {
return this->onMakeClone(args);
}
@@ -317,12 +238,6 @@
return stream.detachAsData();
}
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
- return MakeDeserialize(stream, SkFontMgr::RefDefault());
-}
-#endif
-
sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream, sk_sp<SkFontMgr> lastResortMgr) {
SkFontDescriptor desc;
if (!SkFontDescriptor::Deserialize(stream, &desc)) {
diff --git a/src/ports/BUILD.bazel b/src/ports/BUILD.bazel
index 9db5d1d..76aff0b 100644
--- a/src/ports/BUILD.bazel
+++ b/src/ports/BUILD.bazel
@@ -47,35 +47,6 @@
}),
)
-# There can only be one FontMgr Factory, but multiple different types of FontMgr compiled into
-# a single build.
-skia_filegroup(
- name = "fontmgr_factory",
- srcs = selects.with_or({
- "//bazel/common_config_settings:android_fontmgr_factory": [
- ":fontmgr_android_factory",
- ],
- "//bazel/common_config_settings:custom_directory_fontmgr_factory": [
- ":fontmgr_custom_directory_factory",
- ],
- "//bazel/common_config_settings:custom_embedded_fontmgr_factory": [
- ":fontmgr_custom_embedded_factory",
- ],
- "//bazel/common_config_settings:custom_empty_fontmgr_factory": [
- ":fontmgr_custom_empty_factory",
- ],
- "//bazel/common_config_settings:fontconfig_fontmgr_factory": [
- ":fontmgr_fontconfig_factory",
- ],
- "//bazel/common_config_settings:fci_fontmgr_factory": [
- ":fontmgr_fci_factory",
- ],
- ("//bazel/common_config_settings:empty_fontmgr_factory", "//conditions:default"): [
- ":fontmgr_empty_factory",
- ],
- }),
-)
-
skia_filegroup(
name = "fontmgr",
srcs = select_multi(
@@ -84,10 +55,12 @@
"//bazel/common_config_settings:custom_directory_fontmgr": [":fontmgr_custom_directory"],
"//bazel/common_config_settings:custom_embedded_fontmgr": [":fontmgr_custom_embedded"],
"//bazel/common_config_settings:custom_empty_fontmgr": [":fontmgr_custom_empty"],
- "//bazel/common_config_settings:fontconfig_fontmgr": [":legacy_fontmgr_fontconfig"],
"//bazel/common_config_settings:fci_fontmgr": [":fontmgr_fci"],
},
- ),
+ ) + select({
+ "@platforms//os:linux": [":legacy_fontmgr_fontconfig"],
+ "//conditions:default": [],
+ }),
)
skia_filegroup(
@@ -107,14 +80,6 @@
)
skia_filegroup(
- name = "fontmgr_android_factory",
- srcs = [
- "SkFontMgr_android_factory.cpp",
- ":fontmgr_android",
- ],
-)
-
-skia_filegroup(
name = "legacy_fontmgr_custom",
srcs = [
"SkFontMgr_custom.cpp",
@@ -123,13 +88,6 @@
)
skia_filegroup(
- name = "fontmgr_empty_factory",
- srcs = [
- "SkFontMgr_empty_factory.cpp",
- ],
-)
-
-skia_filegroup(
name = "fontmgr_custom_directory",
srcs = [
"SkFontMgr_custom_directory.cpp",
@@ -138,14 +96,6 @@
)
skia_filegroup(
- name = "fontmgr_custom_directory_factory",
- srcs = [
- "SkFontMgr_custom_directory_factory.cpp",
- ":fontmgr_custom_directory",
- ],
-)
-
-skia_filegroup(
name = "fontmgr_custom_embedded",
srcs = [
"SkFontMgr_custom_embedded.cpp",
@@ -154,14 +104,6 @@
)
skia_filegroup(
- name = "fontmgr_custom_embedded_factory",
- srcs = [
- "SkFontMgr_custom_embedded_factory.cpp",
- ":fontmgr_custom_embedded",
- ],
-)
-
-skia_filegroup(
name = "fontmgr_custom_empty",
srcs = [
"SkFontMgr_custom_empty.cpp",
@@ -169,14 +111,6 @@
],
)
-skia_filegroup(
- name = "fontmgr_custom_empty_factory",
- srcs = [
- "SkFontMgr_custom_empty_factory.cpp",
- ":fontmgr_custom_empty",
- ],
-)
-
# Any setting that causes this skia_filegroup to be included also needs to have a dependency on
# fontconfig. See "deps" and "uses_fontconfig" at the bottom of this file.
skia_filegroup(
@@ -187,14 +121,6 @@
],
)
-skia_filegroup(
- name = "fontmgr_fontconfig_factory",
- srcs = [
- "SkFontMgr_fontconfig_factory.cpp",
- ":legacy_fontmgr_fontconfig",
- ],
-)
-
# TODO(bungeman, kjlubick) break this up into the direct and Interface part.
# Alternatively, delete it.
# Any setting that causes this skia_filegroup to be included also needs to have a dependency on
@@ -211,14 +137,6 @@
)
skia_filegroup(
- name = "fontmgr_fci_factory",
- srcs = [
- "SkFontMgr_FontConfigInterface_factory.cpp",
- ":fontmgr_fci",
- ],
-)
-
-skia_filegroup(
name = "global_init",
srcs = ["SkGlobalInitialization_default.cpp"],
)
@@ -269,7 +187,6 @@
srcs = [
":discardable_memory_pool",
":fontmgr",
- ":fontmgr_factory",
":global_init",
":load_dynamic_library",
":malloc",
@@ -294,10 +211,10 @@
"@platforms//os:ios": ["SkOSFile_ios.h"],
"//conditions:default": [],
}) + select({
- "//bazel/common_config_settings:uses_android_fontmgr": [":fontmgr_android_hdrs"],
+ "//bazel/common_config_settings:android_fontmgr": [":fontmgr_android_hdrs"],
"//conditions:default": [],
}) + select({
- "//bazel/common_config_settings:uses_fci_fontmgr": [
+ "//bazel/common_config_settings:fci_fontmgr": [
"SkFontConfigInterface_direct.h",
"SkFontConfigTypeface.h",
],
@@ -314,20 +231,22 @@
selects.config_setting_group(
name = "uses_freetype",
match_any = [
- "//bazel/common_config_settings:uses_android_fontmgr",
- "//bazel/common_config_settings:uses_custom_directory_fontmgr",
- "//bazel/common_config_settings:uses_custom_embedded_fontmgr",
- "//bazel/common_config_settings:uses_custom_empty_fontmgr",
- "//bazel/common_config_settings:uses_fontconfig_fontmgr",
- "//bazel/common_config_settings:uses_fci_fontmgr",
+ "//bazel/common_config_settings:android_fontmgr",
+ "//bazel/common_config_settings:custom_directory_fontmgr",
+ "//bazel/common_config_settings:custom_embedded_fontmgr",
+ "//bazel/common_config_settings:custom_empty_fontmgr",
+ "//bazel/common_config_settings:fontconfig_fontmgr",
+ "//bazel/common_config_settings:fci_fontmgr",
+ "@platforms//os:linux",
],
)
selects.config_setting_group(
name = "uses_fontconfig",
match_any = [
- "//bazel/common_config_settings:uses_fontconfig_fontmgr",
- "//bazel/common_config_settings:uses_fci_fontmgr",
+ "//bazel/common_config_settings:fontconfig_fontmgr",
+ "//bazel/common_config_settings:fci_fontmgr",
+ "@platforms//os:linux",
],
)
@@ -356,7 +275,7 @@
":uses_fontconfig": ["//bazel/external/fontconfig"],
"//conditions:default": [],
}) + select({
- "//bazel/common_config_settings:uses_android_fontmgr": ["@expat"],
+ "//bazel/common_config_settings:android_fontmgr": ["@expat"],
"//conditions:default": [],
}) + select({
"//bazel/common_config_settings:use_fontations_true": ["//src/ports/fontations:deps"],
diff --git a/src/ports/SkFontConfigInterface.cpp b/src/ports/SkFontConfigInterface.cpp
index 860dc3a..bd859ad 100644
--- a/src/ports/SkFontConfigInterface.cpp
+++ b/src/ports/SkFontConfigInterface.cpp
@@ -32,12 +32,6 @@
gFontConfigInterface = fc.release();
}
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
-sk_sp<SkTypeface> SkFontConfigInterface::makeTypeface(const FontIdentity& identity) {
- return makeTypeface(identity, SkFontMgr::RefDefault());
-}
-#endif
-
sk_sp<SkTypeface> SkFontConfigInterface::makeTypeface(const FontIdentity& identity,
sk_sp<SkFontMgr> mgr) {
return mgr->makeFromStream(std::unique_ptr<SkStreamAsset>(this->openStream(identity)),
diff --git a/src/ports/SkFontMgr_FontConfigInterface_factory.cpp b/src/ports/SkFontMgr_FontConfigInterface_factory.cpp
deleted file mode 100644
index dd68827..0000000
--- a/src/ports/SkFontMgr_FontConfigInterface_factory.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkFontConfigInterface.h"
-#include "include/ports/SkFontMgr_FontConfigInterface.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal());
- if (!fci) {
- return nullptr;
- }
- return SkFontMgr_New_FCI(std::move(fci));
-}
-#endif
diff --git a/src/ports/SkFontMgr_android_factory.cpp b/src/ports/SkFontMgr_android_factory.cpp
deleted file mode 100644
index dc24b84..0000000
--- a/src/ports/SkFontMgr_android_factory.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkFontMgr_android.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_Android(nullptr);
-}
-#endif
diff --git a/src/ports/SkFontMgr_custom_directory_factory.cpp b/src/ports/SkFontMgr_custom_directory_factory.cpp
deleted file mode 100644
index 0f926ad..0000000
--- a/src/ports/SkFontMgr_custom_directory_factory.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkFontMgr_directory.h"
-
-#ifndef SK_FONT_FILE_PREFIX
-# if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
-# define SK_FONT_FILE_PREFIX "/System/Library/Fonts/"
-# else
-# define SK_FONT_FILE_PREFIX "/usr/share/fonts/"
-# endif
-#endif
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_Custom_Directory(SK_FONT_FILE_PREFIX);
-}
-#endif
diff --git a/src/ports/SkFontMgr_custom_embedded_factory.cpp b/src/ports/SkFontMgr_custom_embedded_factory.cpp
deleted file mode 100644
index 3179bab..0000000
--- a/src/ports/SkFontMgr_custom_embedded_factory.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-struct SkEmbeddedResource { const uint8_t* data; size_t size; };
-struct SkEmbeddedResourceHeader { const SkEmbeddedResource* entries; int count; };
-sk_sp<SkFontMgr> SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header);
-
-extern "C" const SkEmbeddedResourceHeader SK_EMBEDDED_FONTS;
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_Custom_Embedded(&SK_EMBEDDED_FONTS);
-}
-#endif
diff --git a/src/ports/SkFontMgr_custom_empty_factory.cpp b/src/ports/SkFontMgr_custom_empty_factory.cpp
deleted file mode 100644
index 172fc45..0000000
--- a/src/ports/SkFontMgr_custom_empty_factory.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkFontMgr_empty.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_Custom_Empty();
-}
-#endif
diff --git a/src/ports/SkFontMgr_empty_factory.cpp b/src/ports/SkFontMgr_empty_factory.cpp
deleted file mode 100644
index a4c4673..0000000
--- a/src/ports/SkFontMgr_empty_factory.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2008 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- // Always return nullptr, an empty SkFontMgr will be used.
- return nullptr;
-}
-#endif
diff --git a/src/ports/SkFontMgr_fontconfig_factory.cpp b/src/ports/SkFontMgr_fontconfig_factory.cpp
deleted file mode 100644
index 5bf3051..0000000
--- a/src/ports/SkFontMgr_fontconfig_factory.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkFontMgr.h"
-#include "include/core/SkTypes.h"
-#include "include/ports/SkFontMgr_fontconfig.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_FontConfig(nullptr);
-}
-#endif
diff --git a/src/ports/SkFontMgr_mac_ct_factory.cpp b/src/ports/SkFontMgr_mac_ct_factory.cpp
deleted file mode 100644
index bd4fc41..0000000
--- a/src/ports/SkFontMgr_mac_ct_factory.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkTypes.h"
-#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkFontMgr_mac_ct.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_CoreText(nullptr);
-}
-#endif
-
-#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/ports/SkFontMgr_win_dw_factory.cpp b/src/ports/SkFontMgr_win_dw_factory.cpp
deleted file mode 100644
index 9dd952a..0000000
--- a/src/ports/SkFontMgr_win_dw_factory.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "include/core/SkTypes.h"
-#if defined(SK_BUILD_FOR_WIN) // And !SKIA_GDI?
-
-#include "include/core/SkFontMgr.h"
-#include "include/ports/SkTypeface_win.h"
-
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-sk_sp<SkFontMgr> SkFontMgr::Factory() {
- return SkFontMgr_New_DirectWrite();
-}
-#endif
-
-#endif//defined(SK_BUILD_FOR_WIN)
diff --git a/tests/MultiPictureDocumentTest.cpp b/tests/MultiPictureDocumentTest.cpp
index e4bce00..a968c1b 100644
--- a/tests/MultiPictureDocumentTest.cpp
+++ b/tests/MultiPictureDocumentTest.cpp
@@ -174,7 +174,8 @@
auto surf = SkSurfaces::Raster(info);
surf->getCanvas()->drawPicture(frame.fPicture);
auto img = surf->makeImageSnapshot();
- REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img.get(), expectedImages[i].get()));
+ REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img.get(), expectedImages[i].get()),
+ "Frame %d is wrong", i);
i++;
}
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 6fd549b..95c683b 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -816,7 +816,18 @@
sk_sp<SkImage> img0 = render(*pict);
sk_sp<SkImage> img1 = render(*readPict);
if (img0 && img1) {
- REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img0.get(), img1.get()));
+ bool ok = ToolUtils::equal_pixels(img0.get(), img1.get());
+ REPORTER_ASSERT(reporter, ok, "before and after image did not match");
+ if (!ok) {
+ auto left = SkFILEWStream("before_serialize.png");
+ sk_sp<SkData> d = SkPngEncoder::Encode(nullptr, img0.get(), {});
+ left.write(d->data(), d->size());
+ left.fsync();
+ auto right = SkFILEWStream("after_serialize.png");
+ d = SkPngEncoder::Encode(nullptr, img1.get(), {});
+ right.write(d->data(), d->size());
+ right.fsync();
+ }
}
}
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
index f03b97b..5094eb5 100644
--- a/tools/ToolUtils.cpp
+++ b/tools/ToolUtils.cpp
@@ -452,7 +452,14 @@
//////////////////////////////////////////////////////////////////////////////////////////////
bool equal_pixels(const SkPixmap& a, const SkPixmap& b) {
- if (a.width() != b.width() || a.height() != b.height() || a.colorType() != b.colorType()) {
+ if (a.width() != b.width() || a.height() != b.height()) {
+ SkDebugf("[ToolUtils::equal_pixels] Dimensions do not match (%d x %d) != (%d x %d)\n",
+ a.width(), a.height(), b.width(), b.height());
+ }
+
+ if (a.colorType() != b.colorType()) {
+ SkDebugf("[ToolUtils::equal_pixels] colorType does not match %d != %d\n",
+ (int) a.colorType(), (int) b.colorType());
return false;
}
@@ -460,6 +467,7 @@
const char* aptr = (const char*)a.addr(0, y);
const char* bptr = (const char*)b.addr(0, y);
if (0 != memcmp(aptr, bptr, a.width() * a.info().bytesPerPixel())) {
+ SkDebugf("[ToolUtils::equal_pixels] row %d does not match byte for byte\n", y);
return false;
}
}
diff --git a/tools/fonts/FontToolUtils.cpp b/tools/fonts/FontToolUtils.cpp
index b7b0369..fe1c484 100644
--- a/tools/fonts/FontToolUtils.cpp
+++ b/tools/fonts/FontToolUtils.cpp
@@ -21,7 +21,6 @@
#include "include/private/base/SkMutex.h"
#include "include/utils/SkCustomTypeface.h"
#include "src/base/SkUTF.h"
-#include "src/core/SkFontMgrPriv.h"
#include "src/core/SkOSFile.h"
#include "tools/Resources.h"
#include "tools/flags/CommandLineFlags.h"
@@ -274,17 +273,4 @@
return SkFont(DefaultTypeface(), 12);
}
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-void SetDefaultFontMgr() {
- if (!FLAGS_nativeFonts) {
- gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
- }
-#if defined(SK_BUILD_FOR_WIN) && defined(SK_FONTMGR_GDI_AVAILABLE)
- if (FLAGS_gdi) {
- gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI;
- }
-#endif
-}
-#endif
-
} // namespace ToolUtils
diff --git a/tools/fonts/FontToolUtils.h b/tools/fonts/FontToolUtils.h
index 1e14d11..11ecf8a 100644
--- a/tools/fonts/FontToolUtils.h
+++ b/tools/fonts/FontToolUtils.h
@@ -75,11 +75,6 @@
// This returns a font using DefaultTypeface()
SkFont DefaultFont();
-#if !defined(SK_DISABLE_LEGACY_FONTMGR_FACTORY)
-// Temporary hack to set the global for non-migrated uses of SkFontMgr::RefDefault()
-void SetDefaultFontMgr();
-#endif
-
} // namespace ToolUtils
#endif
diff --git a/tools/viewer/BUILD.bazel b/tools/viewer/BUILD.bazel
index f2d755d..16bc4aa 100644
--- a/tools/viewer/BUILD.bazel
+++ b/tools/viewer/BUILD.bazel
@@ -52,9 +52,7 @@
"with_gl_standard": [
"gl_standard",
],
- "fontmgr_factory": [
- "custom_directory_fontmgr_factory",
- ],
+ "include_fontmgr": ["custom_directory_fontmgr"],
"enable_gpu_test_utils": ["True"],
"enable_svg_canvas": ["True"],
"enable_sksl_tracing": ["True"],