[svg] Allow clients to pass a custom SkFontMgr
Introduce a Builder helper and plumb the client-provided SkFontMgr for
font resolution.
Also clean up some of the legacy SkSVGDom factories.
Bug: skia:10840
Change-Id: I6e1eabe7c257cb75dfdb5bf67054f93f25769027
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333577
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/src/SkSVGText.cpp b/modules/svg/src/SkSVGText.cpp
index 6cbf5d6..357e778 100644
--- a/modules/svg/src/SkSVGText.cpp
+++ b/modules/svg/src/SkSVGText.cpp
@@ -62,8 +62,11 @@
ctx.lengthContext().resolve(ctx.presentationContext().fInherited.fFontSize->size(),
SkSVGLengthContext::LengthType::kVertical);
- // TODO: allow clients to pass an external fontmgr.
- SkFont font(SkTypeface::MakeFromName(family.c_str(), style), size);
+ // TODO: we likely want matchFamilyStyle here, but switching away from legacyMakeTypeface
+ // changes all the results when using the default fontmgr.
+ auto tf = ctx.fontMgr()->legacyMakeTypeface(family.c_str(), style);
+
+ SkFont font(std::move(tf), size);
font.setHinting(SkFontHinting::kNone);
font.setSubpixel(true);
font.setLinearMetrics(true);