Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkOTTable_name.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 SkOTTable_name_DEFINED
9#define SkOTTable_name_DEFINED
10
12#include "src/base/SkEndian.h"
14
15#pragma pack(push, 1)
16
18 static const SK_OT_CHAR TAG0 = 'n';
19 static const SK_OT_CHAR TAG1 = 'a';
20 static const SK_OT_CHAR TAG2 = 'm';
21 static const SK_OT_CHAR TAG3 = 'e';
23
26 /** Format 1 was added in OpenType 1.6 (April 2009). */
28
29 /** The number of name records which follow. */
31
32 /** Offset in SK_OT_BYTEs to start of string storage area (from start of table). */
34
35 struct Record {
36 /** The platform ID specifies how to interpret the encoding and language ID. */
46
47 union EncodingID {
49
50 /** Always UTF-16BE. */
62
63 /** These are Mac encodings, see http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/
64 * for their mappings to unicode.
65 * Name table strings using PlatformID::Macintosh must use Roman.
66 */
104
105 /** Deprecated, use Unicode instead. */
113
114 /** Name table strings using PlatformID::Windows must use Symbol, UnicodeBMPUCS2, or
115 * UnicodeUCS4. Symbol and UnicodeBMPUCS2 are both UCS2-BE, UnicodeUCS4 is actually
116 * UTF-16BE.
117 */
118 struct Windows {
120 Symbol = SkTEndian_SwapBE16(0), // UCS2-BE, but don't use this font to display it's own name.
121 UnicodeBMPUCS2 = SkTEndian_SwapBE16(1), // UCS2-BE, Windows default
127 UnicodeUCS4 = SkTEndian_SwapBE16(10), // UTF-16BE. It means UCS4 in charmaps.
131
132 /** LanguageIDs <= 0x7FFF are predefined.
133 * LanguageIDs > 0x7FFF are indexes into the langTagRecord array
134 * (in format 1 name tables, see SkOTTableName::format).
135 */
137 /** A value greater than 0x7FFF.
138 * languageTagID - 0x8000 is an index into the langTagRecord array.
139 */
141
142 /** These are known as Language Designators.
143 * Apple now uses BCP 47 (post OSX10.4), so there will be no new entries.
144 */
145 struct Macintosh {
267
268 /** These are known as LCIDs.
269 * On Windows the current set can be had from EnumSystemLocalesEx and LocaleNameToLCID.
270 */
271 struct Windows {
481
482 /** NameIDs <= 0xFF are predefined. Those > 0xFF are font specific. */
513
514 /** The length of the string in SK_OT_BYTEs. */
516
517 /** Offset in SK_OT_BYTEs from start of string storage area
518 * (see SkOTTableName::stringOffset).
519 */
521 }; //nameRecord[count];
522
523 struct Format1Ext {
524 /** The number of languageTagRecords which follow. */
526
527 /** The encoding of a langTagRecord string is always UTF-16BE.
528 * The content should follow IETF specification BCP 47.
529 */
531 /** The length of the string in SK_OT_BYTEs. */
533
534 /** Offset in SK_OT_BYTEs from start of string storage area
535 * (see SkOTTableName::stringOffset).
536 */
538 }; //langTagRecord[langTagCount]
539 }; //format1ext (if format == format_1)
540
541// The iterator should not be packed.
542#pragma pack(pop)
543
544 class Iterator {
545 public:
546 Iterator(const uint8_t* nameTable, size_t size)
547 : fNameTable(nameTable), fNameTableSize(size), fIndex(0), fType(-1) { }
548 Iterator(const uint8_t* nameTable, size_t size, SK_OT_USHORT type)
549 : fNameTable(nameTable), fNameTableSize(size), fIndex(0), fType(type)
550 { }
551
553 fIndex = 0;
554 fType = type;
555 }
556
562 bool next(Record&);
563
564 private:
565 const uint8_t* fNameTable;
566 const size_t fNameTableSize;
567 size_t fIndex;
568 int fType;
569 };
570};
571
572
573static_assert(sizeof(SkOTTableName) == 6, "sizeof(SkOTTableName) not 6");
574static_assert(sizeof(SkOTTableName::Format1Ext) == 2, "sizeof(SkOTTableNameF1) not 2");
575static_assert(sizeof(SkOTTableName::Format1Ext::LangTagRecord) == 4, "sizeof(SkOTTableNameLangTagRecord) not 4");
576static_assert(sizeof(SkOTTableName::Record) == 12, "sizeof(SkOTTableNameRecord) not 12");
577
578#endif
#define SkTEndian_SwapBE16(n)
Definition SkEndian.h:142
uint16_t SK_OT_USHORT
uint32_t SK_OT_ULONG
int8_t SK_OT_CHAR
Iterator(const uint8_t *nameTable, size_t size, SK_OT_USHORT type)
void reset(SK_OT_USHORT type)
Iterator(const uint8_t *nameTable, size_t size)
enum SkOTTableName::Record::EncodingID::ISO::Value value
enum SkOTTableName::Record::EncodingID::Macintosh::Value value
enum SkOTTableName::Record::EncodingID::Unicode::Value value
enum SkOTTableName::Record::EncodingID::Windows::Value value
enum SkOTTableName::Record::LanguageID::Macintosh::Value value
enum SkOTTableName::Record::LanguageID::Windows::Value value
enum SkOTTableName::Record::NameID::Predefined::Value value
enum SkOTTableName::Record::PlatformID::Value value
struct SkOTTableName::Record::PlatformID platformID
union SkOTTableName::Record::NameID nameID
union SkOTTableName::Record::LanguageID languageID
union SkOTTableName::Record::EncodingID encodingID
static const SK_OT_CHAR TAG1
static const SK_OT_USHORT format_0
SK_OT_USHORT stringOffset
static const SK_OT_CHAR TAG3
static const SK_OT_CHAR TAG2
SK_OT_USHORT format
static const SK_OT_ULONG TAG
static const SK_OT_CHAR TAG0
static const SK_OT_USHORT format_1
SK_OT_USHORT count
struct SkOTTableName::Record::EncodingID::ISO iso
struct SkOTTableName::Record::EncodingID::Windows windows
struct SkOTTableName::Record::EncodingID::Unicode unicode
struct SkOTTableName::Record::EncodingID::Macintosh macintosh
struct SkOTTableName::Record::LanguageID::Windows windows
struct SkOTTableName::Record::LanguageID::Macintosh macintosh
struct SkOTTableName::Record::NameID::Predefined predefined