Regularize SkFontMgr for CoreText build.
Move SkFontHost_mac.cpp into an 'optional' like the other fontmgr build rules. This allows building with other fontmgrs on Mac and makes the lib dependencies explicit. In the future this helps with splitting the out the default factory. Change-Id: Iecef9e428acb69f89b54afa00b4e779f5858c61a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294076 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
06f3d088e1
commit
d13487e71b
38
BUILD.gn
38
BUILD.gn
@ -361,6 +361,31 @@ optional("fontmgr_fuchsia") {
|
||||
]
|
||||
}
|
||||
|
||||
optional("fontmgr_mac") {
|
||||
enabled = skia_use_fonthost_mac
|
||||
|
||||
sources = [ "src/ports/SkFontHost_mac.cpp" ]
|
||||
|
||||
if (is_mac) {
|
||||
libs = [
|
||||
# AppKit symbols NSFontWeightXXX may be dlsym'ed.
|
||||
"AppKit.framework",
|
||||
"ApplicationServices.framework",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_ios) {
|
||||
libs = [
|
||||
"CoreFoundation.framework",
|
||||
"CoreGraphics.framework",
|
||||
"CoreText.framework",
|
||||
|
||||
# UIKit symbols UIFontWeightXXX may be dlsym'ed.
|
||||
"UIKit.framework",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
optional("fontmgr_wasm") {
|
||||
enabled = target_cpu == "wasm"
|
||||
deps = []
|
||||
@ -879,6 +904,7 @@ component("skia") {
|
||||
":fontmgr_empty",
|
||||
":fontmgr_fontconfig",
|
||||
":fontmgr_fuchsia",
|
||||
":fontmgr_mac",
|
||||
":fontmgr_wasm",
|
||||
":fontmgr_win",
|
||||
":fontmgr_win_gdi",
|
||||
@ -997,10 +1023,6 @@ component("skia") {
|
||||
}
|
||||
}
|
||||
|
||||
if (skia_use_fonthost_mac) {
|
||||
sources += [ "src/ports/SkFontHost_mac.cpp" ]
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
sources += [
|
||||
"src/ports/SkDebug_stdio.cpp",
|
||||
@ -1008,8 +1030,6 @@ component("skia") {
|
||||
"src/ports/SkImageGeneratorCG.cpp",
|
||||
]
|
||||
libs += [
|
||||
# AppKit symbols NSFontWeightXXX may be dlsym'ed.
|
||||
"AppKit.framework",
|
||||
"ApplicationServices.framework",
|
||||
"OpenGL.framework",
|
||||
]
|
||||
@ -1018,19 +1038,13 @@ component("skia") {
|
||||
if (is_ios) {
|
||||
sources += [
|
||||
"src/ports/SkDebug_stdio.cpp",
|
||||
"src/ports/SkFontHost_mac.cpp",
|
||||
"src/ports/SkImageEncoder_CG.cpp",
|
||||
"src/ports/SkImageGeneratorCG.cpp",
|
||||
]
|
||||
libs += [
|
||||
"CoreFoundation.framework",
|
||||
"CoreGraphics.framework",
|
||||
"CoreText.framework",
|
||||
"ImageIO.framework",
|
||||
"MobileCoreServices.framework",
|
||||
|
||||
# UIKit symbols UIFontWeightXXX may be dlsym'ed.
|
||||
"UIKit.framework",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ declare_args() {
|
||||
skia_use_ffmpeg = false
|
||||
skia_use_fixed_gamma_text = is_android
|
||||
skia_use_fontconfig = is_linux
|
||||
skia_use_fonthost_mac = is_mac
|
||||
skia_use_fonthost_mac = is_mac || is_ios
|
||||
skia_use_freetype = is_android || is_fuchsia || is_linux
|
||||
skia_use_harfbuzz = true
|
||||
skia_use_gl = !is_fuchsia
|
||||
|
@ -16,7 +16,10 @@ if (skia_enable_skshaper) {
|
||||
if (is_component_build) {
|
||||
defines += [ "SKSHAPER_DLL" ]
|
||||
}
|
||||
if (skia_use_icu) {
|
||||
if (skia_use_fonthost_mac) {
|
||||
defines += [ "SK_SHAPER_CORETEXT_AVAILABLE" ]
|
||||
}
|
||||
if (skia_use_icu && skia_use_harfbuzz) {
|
||||
defines += [ "SK_SHAPER_HARFBUZZ_AVAILABLE" ]
|
||||
}
|
||||
}
|
||||
@ -29,6 +32,9 @@ if (skia_enable_skshaper) {
|
||||
deps = [ "../..:skia" ]
|
||||
defines = [ "SKSHAPER_IMPLEMENTATION=1" ]
|
||||
sources = skia_shaper_primitive_sources
|
||||
if (skia_use_fonthost_mac) {
|
||||
sources += skia_shaper_coretext_sources
|
||||
}
|
||||
if (skia_use_icu && skia_use_harfbuzz) {
|
||||
sources += skia_shaper_harfbuzz_sources
|
||||
deps += [
|
||||
|
@ -54,8 +54,9 @@ public:
|
||||
static std::unique_ptr<SkShaper> MakeShapeThenWrap(sk_sp<SkFontMgr> = nullptr);
|
||||
static std::unique_ptr<SkShaper> MakeShapeDontWrapOrReorder(sk_sp<SkFontMgr> = nullptr);
|
||||
#endif
|
||||
// Returns nullptr if not supported
|
||||
#ifdef SK_SHAPER_CORETEXT_AVAILABLE
|
||||
static std::unique_ptr<SkShaper> MakeCoreText();
|
||||
#endif
|
||||
|
||||
static std::unique_ptr<SkShaper> Make(sk_sp<SkFontMgr> = nullptr);
|
||||
|
||||
|
@ -11,7 +11,7 @@ skia_shaper_public = [ "$_include/SkShaper.h" ]
|
||||
|
||||
skia_shaper_primitive_sources = [
|
||||
"$_src/SkShaper.cpp",
|
||||
"$_src/SkShaper_coretext.cpp",
|
||||
"$_src/SkShaper_primitive.cpp",
|
||||
]
|
||||
skia_shaper_harfbuzz_sources = [ "$_src/SkShaper_harfbuzz.cpp" ]
|
||||
skia_shaper_coretext_sources = [ "$_src/SkShaper_coretext.cpp" ]
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include "modules/skshaper/include/SkShaper.h"
|
||||
|
||||
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
|
||||
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
@ -287,9 +285,3 @@ void SkShaper_CoreText::shape(const char* utf8, size_t utf8Bytes,
|
||||
handler->commitLine();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
std::unique_ptr<SkShaper> SkShaper::MakeCoreText() {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
@ -114,7 +114,7 @@ private:
|
||||
};
|
||||
|
||||
DEF_SAMPLE( return new TextBoxView([](){ return SkShaper::Make(); }, "default"); );
|
||||
#ifdef SK_BUILD_FOR_MAC
|
||||
#ifdef SK_SHAPER_CORETEXT_AVAILABLE
|
||||
DEF_SAMPLE( return new TextBoxView(SkShaper::MakeCoreText, "coretext"); );
|
||||
#endif
|
||||
|
||||
@ -176,7 +176,9 @@ protected:
|
||||
for (SkScalar size = 30; size <= 30; size += 10) {
|
||||
this->drawTest(canvas, text, size, SkShaper::Make());
|
||||
canvas->translate(0, size + 5);
|
||||
#ifdef SK_SHAPER_CORETEXT_AVAILABLE
|
||||
this->drawTest(canvas, text, size, SkShaper::MakeCoreText());
|
||||
#endif
|
||||
canvas->translate(0, size*2);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,11 @@
|
||||
#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
|
||||
|
||||
sk_sp<SkFontMgr> SkFontMgr::Factory() {
|
||||
|
Loading…
Reference in New Issue
Block a user