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
This commit is contained in:
bungeman 2015-06-17 07:55:59 -07:00 committed by Commit bot
parent 942e99b9c4
commit 0b1de2626a
5 changed files with 48 additions and 7 deletions

View File

@ -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']],
}]
],
}],

View File

@ -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',

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}