Flutter Engine
The Flutter Engine
SkOTUtils.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 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 SkOTUtils_DEFINED
9#define SkOTUtils_DEFINED
10
15
16class SkData;
17class SkStream;
19
20struct SkOTUtils {
21 /**
22 * Calculates the OpenType checksum for data.
23 */
24 static uint32_t CalcTableChecksum(SK_OT_ULONG *data, size_t length);
25
26 /**
27 * Renames an sfnt font. On failure (invalid data or not an sfnt font)
28 * returns nullptr.
29 *
30 * Essentially, this removes any existing 'name' table and replaces it
31 * with a new one in which FontFamilyName, FontSubfamilyName,
32 * UniqueFontIdentifier, FullFontName, and PostscriptName are fontName.
33 *
34 * The new 'name' table records will be written with the Windows,
35 * UnicodeBMPUCS2, and English_UnitedStates settings.
36 *
37 * fontName and fontNameLen must be specified in terms of ASCII chars.
38 *
39 * Does not affect fontData's ownership.
40 */
41 static SkData* RenameFont(SkStreamAsset* fontData, const char* fontName, int fontNameLen);
42
43 /** An implementation of LocalizedStrings which obtains it's data from a 'name' table. */
45 public:
46 /** Takes ownership of the nameTableData and will free it with SK_DELETE. */
47 LocalizedStrings_NameTable(std::unique_ptr<uint8_t[]> nameTableData, size_t size,
48 SK_OT_USHORT types[],
49 int typesCount)
50 : fTypes(types), fTypesCount(typesCount), fTypesIndex(0)
51 , fNameTableData(std::move(nameTableData))
52 , fFamilyNameIter(fNameTableData.get(), size, fTypes[fTypesIndex])
53 { }
54
55 /** Creates an iterator over all data in the 'name' table of a typeface.
56 * If no valid 'name' table can be found, returns nullptr.
57 */
59 const SkTypeface& typeface,
60 SK_OT_USHORT types[],
61 int typesCount);
62
63 /** Creates an iterator over all the family names in the 'name' table of a typeface.
64 * If no valid 'name' table can be found, returns nullptr.
65 */
67
68 bool next(SkTypeface::LocalizedString* localizedString) override;
69 private:
70 static SK_OT_USHORT familyNameTypes[3];
71
72 SK_OT_USHORT* fTypes;
73 int fTypesCount;
74 int fTypesIndex;
75 std::unique_ptr<uint8_t[]> fNameTableData;
76 SkOTTableName::Iterator fFamilyNameIter;
77 };
78
79 /** An implementation of LocalizedStrings which has one name. */
81 public:
83 : fName(std::move(name)), fLanguage(std::move(language)), fHasNext(true) {}
84
85 bool next(SkTypeface::LocalizedString* localizedString) override {
86 localizedString->fString = fName;
87 localizedString->fLanguage = fLanguage;
88
89 bool hadNext = fHasNext;
90 fHasNext = false;
91 return hadNext;
92 }
93
94 private:
95 SkString fName;
96 SkString fLanguage;
97 bool fHasNext;
98 };
99
102};
103
104#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
uint16_t SK_OT_USHORT
uint32_t SK_OT_ULONG
Definition: SkData.h:25
bool next(SkTypeface::LocalizedString *localizedString) override
Definition: SkOTUtils.cpp:197
static sk_sp< LocalizedStrings_NameTable > Make(const SkTypeface &typeface, SK_OT_USHORT types[], int typesCount)
Definition: SkOTUtils.cpp:170
static sk_sp< LocalizedStrings_NameTable > MakeForFamilyNames(const SkTypeface &typeface)
Definition: SkOTUtils.cpp:191
LocalizedStrings_NameTable(std::unique_ptr< uint8_t[]> nameTableData, size_t size, SK_OT_USHORT types[], int typesCount)
Definition: SkOTUtils.h:47
bool next(SkTypeface::LocalizedString *localizedString) override
Definition: SkOTUtils.h:85
LocalizedStrings_SingleName(SkString name, SkString language)
Definition: SkOTUtils.h:82
size_t length
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
const myers::Point & get(const myers::Segment &)
Definition: ref_ptr.h:256
static uint32_t CalcTableChecksum(SK_OT_ULONG *data, size_t length)
Definition: SkOTUtils.cpp:22
static SkData * RenameFont(SkStreamAsset *fontData, const char *fontName, int fontNameLen)
Definition: SkOTUtils.cpp:31
static void SetAdvancedTypefaceFlags(SkOTTableOS2_V4::Type fsType, SkAdvancedTypefaceMetrics *info)
Definition: SkOTUtils.cpp:219
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63