Flutter Engine
The Flutter Engine
Classes | Functions | Variables
SkOTTable_name.cpp File Reference
#include "src/sfnt/SkOTTable_name.h"
#include "src/base/SkEndian.h"
#include "src/base/SkTSearch.h"
#include "src/base/SkUTF.h"
#include "src/core/SkStringUtils.h"

Go to the source code of this file.

Classes

struct  BCP47FromLanguageId
 

Functions

static SkUnichar next_unichar_UTF16BE (const uint8_t **srcPtr, size_t *length)
 
static void SkString_from_UTF16BE (const uint8_t *utf16be, size_t length, SkString &utf8)
 
static void SkStringFromMacRoman (const uint8_t *macRoman, size_t length, SkString &utf8)
 

Variables

static const uint16_t UnicodeFromMacRoman [0x80]
 
static const struct BCP47FromLanguageId BCP47FromLanguageID []
 

Function Documentation

◆ next_unichar_UTF16BE()

static SkUnichar next_unichar_UTF16BE ( const uint8_t **  srcPtr,
size_t *  length 
)
static

Definition at line 15 of file SkOTTable_name.cpp.

15 {
16 SkASSERT(srcPtr && *srcPtr && length);
17 SkASSERT(*length > 0);
18
19 uint16_t leading;
20 if (*length < sizeof(leading)) {
21 *length = 0;
22 return 0xFFFD;
23 }
24 memcpy(&leading, *srcPtr, sizeof(leading));
25 *srcPtr += sizeof(leading);
26 *length -= sizeof(leading);
27 SkUnichar c = SkEndian_SwapBE16(leading);
28
30 return 0xFFFD;
31 }
33 uint16_t trailing;
34 if (*length < sizeof(trailing)) {
35 *length = 0;
36 return 0xFFFD;
37 }
38 memcpy(&trailing, *srcPtr, sizeof(trailing));
39 SkUnichar c2 = SkEndian_SwapBE16(trailing);
41 return 0xFFFD;
42 }
43 *srcPtr += sizeof(trailing);
44 *length -= sizeof(trailing);
45
46 c = (c << 10) + c2 + (0x10000 - (0xD800 << 10) - 0xDC00);
47 }
48 return c;
49}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkEndian_SwapBE16(n)
Definition: SkEndian.h:135
int32_t SkUnichar
Definition: SkTypes.h:175
size_t length
static bool IsTrailingSurrogateUTF16(uint16_t c)
Definition: SkUTF.h:97
static bool IsLeadingSurrogateUTF16(uint16_t c)
Definition: SkUTF.h:91

◆ SkString_from_UTF16BE()

static void SkString_from_UTF16BE ( const uint8_t *  utf16be,
size_t  length,
SkString utf8 
)
static

Definition at line 51 of file SkOTTable_name.cpp.

51 {
52 // Note that utf16be may not be 2-byte aligned.
53 SkASSERT(utf16be != nullptr);
54
55 utf8.reset();
56 while (length) {
57 utf8.appendUnichar(next_unichar_UTF16BE(&utf16be, &length));
58 }
59}
static SkUnichar next_unichar_UTF16BE(const uint8_t **srcPtr, size_t *length)

◆ SkStringFromMacRoman()

static void SkStringFromMacRoman ( const uint8_t *  macRoman,
size_t  length,
SkString utf8 
)
static

Definition at line 85 of file SkOTTable_name.cpp.

85 {
86 utf8.reset();
87 for (size_t i = 0; i < length; ++i) {
88 utf8.appendUnichar(macRoman[i] < 0x80 ? macRoman[i]
89 : UnicodeFromMacRoman[macRoman[i] - 0x80]);
90 }
91}
static const uint16_t UnicodeFromMacRoman[0x80]

Variable Documentation

◆ BCP47FromLanguageID

const struct BCP47FromLanguageId BCP47FromLanguageID[]
static

The Mac and Windows values do not conflict, so this is currently one single table.

◆ UnicodeFromMacRoman

const uint16_t UnicodeFromMacRoman[0x80]
static
Initial value:
= {
0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7,
}

UnicodeFromMacRoman[macRomanPoint - 0x80] -> unicodeCodePoint. Derived from http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT . In MacRoman the first 128 code points match ASCII code points. This maps the second 128 MacRoman code points to unicode code points.

Definition at line 66 of file SkOTTable_name.cpp.