aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontConfigInterface_direct.h
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2015-12-01 11:12:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-01 11:12:05 -0800
commit2211a7bdd1680003a4decbebef76f153cd0a28fa (patch)
treede998b224538b319b8e5c1c522d3cd82bb5247e4 /src/ports/SkFontConfigInterface_direct.h
parent001e74426672e00f3f2783ccf728031662d4a358 (diff)
Fix Google3 fonts. Use fontconfig rather than custom_directory_factory. Add Google3 font caching.
Some future dependents require these changes. Depends on internal cl/108287941. Review URL: https://codereview.chromium.org/1471033002
Diffstat (limited to 'src/ports/SkFontConfigInterface_direct.h')
-rw-r--r--src/ports/SkFontConfigInterface_direct.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/ports/SkFontConfigInterface_direct.h b/src/ports/SkFontConfigInterface_direct.h
new file mode 100644
index 0000000000..450a3f0c31
--- /dev/null
+++ b/src/ports/SkFontConfigInterface_direct.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009-2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
+
+#include "SkFontConfigInterface.h"
+#include "SkMutex.h"
+
+#include <fontconfig/fontconfig.h>
+
+class SkFontConfigInterfaceDirect : public SkFontConfigInterface {
+public:
+ SkFontConfigInterfaceDirect();
+ ~SkFontConfigInterfaceDirect() override;
+
+ bool matchFamilyName(const char familyName[],
+ SkTypeface::Style requested,
+ FontIdentity* outFontIdentifier,
+ SkString* outFamilyName,
+ SkTypeface::Style* outStyle) override;
+ SkStreamAsset* openStream(const FontIdentity&) override;
+
+ // new APIs
+ SkDataTable* getFamilyNames() override;
+ bool matchFamilySet(const char inFamilyName[],
+ SkString* outFamilyName,
+ SkTArray<FontIdentity>*) override;
+
+protected:
+ virtual bool isAccessible(const char* filename);
+
+private:
+ SkMutex mutex_;
+
+ bool isValidPattern(FcPattern* pattern);
+ FcPattern* MatchFont(FcFontSet* font_set, const char* post_config_family,
+ const SkString& family);
+ typedef SkFontConfigInterface INHERITED;
+};