Flutter Engine
The Flutter Engine
SkFontConfigInterface.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkFontConfigInterface_DEFINED
9#define SkFontConfigInterface_DEFINED
10
15
16class SkFontMgr;
17
18/**
19 * \class SkFontConfigInterface
20 *
21 * A simple interface for remotable font management.
22 * The global instance can be found with RefGlobal().
23 */
25public:
26
27 /**
28 * Returns the global SkFontConfigInterface instance. If it is not
29 * nullptr, calls ref() on it. The caller must balance this with a call to
30 * unref(). The default SkFontConfigInterface is the result of calling
31 * GetSingletonDirectInterface.
32 */
33 static sk_sp<SkFontConfigInterface> RefGlobal();
34
35 /**
36 * Replace the current global instance with the specified one.
37 */
38 static void SetGlobal(sk_sp<SkFontConfigInterface> fc);
39
40 /**
41 * This should be treated as private to the impl of SkFontConfigInterface.
42 * Callers should not change or expect any particular values. It is meant
43 * to be a union of possible storage types to aid the impl.
44 */
45 struct FontIdentity {
46 FontIdentity() : fID(0), fTTCIndex(0) {}
47
48 bool operator==(const FontIdentity& other) const {
49 return fID == other.fID &&
50 fTTCIndex == other.fTTCIndex &&
51 fString == other.fString;
52 }
53 bool operator!=(const FontIdentity& other) const {
54 return !(*this == other);
55 }
56
57 uint32_t fID;
58 int32_t fTTCIndex;
61
62 // If buffer is NULL, just return the number of bytes that would have
63 // been written. Will pad contents to a multiple of 4.
64 size_t writeToMemory(void* buffer = nullptr) const;
65
66 // Recreate from a flattened buffer, returning the number of bytes read.
67 size_t readFromMemory(const void* buffer, size_t length);
68 };
69
70 /**
71 * Given a familyName and style, find the best match.
72 *
73 * If a match is found, return true and set its outFontIdentifier.
74 * If outFamilyName is not null, assign the found familyName to it
75 * (which may differ from the requested familyName).
76 * If outStyle is not null, assign the found style to it
77 * (which may differ from the requested style).
78 *
79 * If a match is not found, return false, and ignore all out parameters.
80 */
81 virtual bool matchFamilyName(const char familyName[],
82 SkFontStyle requested,
83 FontIdentity* outFontIdentifier,
84 SkString* outFamilyName,
85 SkFontStyle* outStyle) = 0;
86
87 /**
88 * Given a FontRef, open a stream to access its data, or return null
89 * if the FontRef's data is not available. The caller is responsible for
90 * deleting the stream when it is done accessing the data.
91 */
93
94 /**
95 * Return an SkTypeface for the given FontIdentity.
96 *
97 * The default implementation simply returns a new typeface built using data obtained from
98 * openStream() using the provided SkFontMgr, but derived classes may implement more
99 * complex caching schemes.
100 */
101 virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity, sk_sp<SkFontMgr> mgr);
102
103 /**
104 * Return a singleton instance of a direct subclass that calls into
105 * libfontconfig. This does not affect the refcnt of the returned instance.
106 */
107 static SkFontConfigInterface* GetSingletonDirectInterface();
108
110};
111
112#endif
#define SK_API
Definition: SkAPI.h:35
virtual SkStreamAsset * openStream(const FontIdentity &)=0
virtual bool matchFamilyName(const char familyName[], SkFontStyle requested, FontIdentity *outFontIdentifier, SkString *outFamilyName, SkFontStyle *outStyle)=0
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
bool operator==(const FontIdentity &other) const
bool operator!=(const FontIdentity &other) const