aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbungeman <bungeman@google.com>2015-06-17 07:55:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-17 07:56:00 -0700
commit0b1de2626a289ab21bd3b93277ed34d022824b3d (patch)
tree6198a1711ec5344f1eddd27471043ca91c369e1f
parent942e99b9c411d093851db8d12c8357f409563007 (diff)
downloadplatform_external_skqp-0b1de2626a289ab21bd3b93277ed34d022824b3d.tar.gz
platform_external_skqp-0b1de2626a289ab21bd3b93277ed34d022824b3d.tar.bz2
platform_external_skqp-0b1de2626a289ab21bd3b93277ed34d022824b3d.zip
Move FontConfig factory into separate file.
This moves the SkFontMgr::Factory implementation which creates a FontMgr around FontConfig into its own file, and allows the user to create one manually. Review URL: https://codereview.chromium.org/1189753007
-rw-r--r--gyp/ports.gyp9
-rw-r--r--gyp/tools.gyp1
-rw-r--r--include/ports/SkFontMgr_fontconfig.h22
-rw-r--r--src/ports/SkFontMgr_fontconfig.cpp10
-rw-r--r--src/ports/SkFontMgr_fontconfig_factory.cpp13
5 files changed, 48 insertions, 7 deletions
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index f3a3faf68e..954199f14f 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -34,6 +34,7 @@
'../src/ports/SkFontHost_win.cpp',
'../src/ports/SkFontMgr_custom_directory_factory.cpp',
'../src/ports/SkFontMgr_custom_embedded_factory.cpp',
+ '../src/ports/SkFontMgr_fontconfig_factory.cpp',
'../src/ports/SkFontMgr_win_dw.cpp',
'../src/ports/SkFontMgr_win_dw_factory.cpp',
'../src/ports/SkFontMgr_win_gdi_factory.cpp',
@@ -54,9 +55,16 @@
'../src/ports/SkTLS_pthread.cpp',
'../src/ports/SkTLS_win.cpp',
+ '../include/ports/SkAtomics_atomic.h',
+ '../include/ports/SkAtomics_std.h',
+ '../include/ports/SkAtomics_sync.h',
'../include/ports/SkFontConfigInterface.h',
'../include/ports/SkFontMgr.h',
+ '../include/ports/SkFontMgr_custom.h',
+ '../include/ports/SkFontMgr_fontconfig.h',
'../include/ports/SkFontMgr_indirect.h',
+ '../include/ports/SkMutex_pthread.h',
+ '../include/ports/SkMutex_win.h',
'../include/ports/SkRemotableFontMgr.h',
],
'sources/': [
@@ -135,6 +143,7 @@
'../src/ports/SkFontHost_fontconfig.cpp',
'../src/ports/SkFontConfigInterface_direct.cpp',
],
+ 'sources/': [['include', '../src/ports/SkFontMgr_fontconfig_factory.cpp']],
}]
],
}],
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index 3ecdf7ba97..7db66a1fd2 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -641,6 +641,7 @@
'<(skia_include_path)/ports/SkAtomics_std.h',
'<(skia_include_path)/ports/SkAtomics_atomic.h',
'<(skia_include_path)/ports/SkAtomics_sync.h',
+ '<(skia_include_path)/ports/SkFontMgr_fontconfig.h',
'<(skia_include_path)/ports/SkMutex_pthread.h',
'<(skia_include_path)/ports/SkMutex_win.h',
'<(skia_include_path)/ports/SkTypeface_mac.h',
diff --git a/include/ports/SkFontMgr_fontconfig.h b/include/ports/SkFontMgr_fontconfig.h
new file mode 100644
index 0000000000..7a59ff0c46
--- /dev/null
+++ b/include/ports/SkFontMgr_fontconfig.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkFontMgr_fontconfig_DEFINED
+#define SkFontMgr_fontconfig_DEFINED
+
+#include "SkTypes.h"
+#include <fontconfig/fontconfig.h>
+
+class SkFontMgr;
+
+/** Create a font manager around a FontConfig instance.
+ * If 'fc' is NULL, will use a new default config.
+ * Takes ownership of 'fc' and will call FcConfigDestroy on it.
+ */
+SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc);
+
+#endif // #ifndef SkFontMgr_fontconfig_DEFINED
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 3baec41cb5..c3cb26751e 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -590,13 +590,9 @@ class SkFontMgr_fontconfig : public SkFontMgr {
}
public:
- SkFontMgr_fontconfig()
- : fFC(FcInitLoadConfigAndFonts())
- , fFamilyNames(GetFamilyNames(fFC)) { }
-
/** Takes control of the reference to 'config'. */
explicit SkFontMgr_fontconfig(FcConfig* config)
- : fFC(config)
+ : fFC(config ? config : FcInitLoadConfigAndFonts())
, fFamilyNames(GetFamilyNames(fFC)) { }
virtual ~SkFontMgr_fontconfig() {
@@ -873,6 +869,6 @@ protected:
}
};
-SkFontMgr* SkFontMgr::Factory() {
- return SkNEW(SkFontMgr_fontconfig);
+SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
+ return new SkFontMgr_fontconfig(fc);
}
diff --git a/src/ports/SkFontMgr_fontconfig_factory.cpp b/src/ports/SkFontMgr_fontconfig_factory.cpp
new file mode 100644
index 0000000000..b959acbbe2
--- /dev/null
+++ b/src/ports/SkFontMgr_fontconfig_factory.cpp
@@ -0,0 +1,13 @@
+/*
+ * 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 "SkFontMgr.h"
+#include "SkFontMgr_fontconfig.h"
+
+SkFontMgr* SkFontMgr::Factory() {
+ return SkFontMgr_New_FontConfig(NULL);
+}