Flutter Engine
The Flutter Engine
Functions
UnicodeTest.cpp File Reference
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "src/base/SkUTF.h"
#include "src/core/SkFontPriv.h"
#include "tests/Test.h"
#include "tools/fonts/FontToolUtils.h"
#include <cstdint>
#include <cstring>
#include <string>

Go to the source code of this file.

Functions

 DEF_TEST (Unicode_textencodings, reporter)
 
 DEF_TEST (glyphs_to_unichars, reporter)
 

Function Documentation

◆ DEF_TEST() [1/2]

DEF_TEST ( glyphs_to_unichars  ,
reporter   
)

Definition at line 53 of file UnicodeTest.cpp.

53 {
55
56 const int N = 52;
57 SkUnichar uni[N];
58 for (int i = 0; i < 26; ++i) {
59 uni[i + 0] = i + 'A';
60 uni[i + 26] = i + 'a';
61 }
62 uint16_t glyphs[N];
63 font.textToGlyphs(uni, sizeof(uni), SkTextEncoding::kUTF32, glyphs, N);
64
65 SkUnichar uni2[N];
67 REPORTER_ASSERT(reporter, memcmp(uni, uni2, sizeof(uni)) == 0);
68}
reporter
Definition: FontMgrTest.cpp:39
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
@ kUTF32
uses four byte words to represent all of Unicode
int32_t SkUnichar
Definition: SkTypes.h:175
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define N
Definition: beziers.cpp:19
static void GlyphsToUnichars(const SkFont &, const uint16_t glyphs[], int count, SkUnichar[])
Definition: SkFont.cpp:396
Definition: SkFont.h:35
SkFont DefaultFont()
font
Font Metadata and Metrics.

◆ DEF_TEST() [2/2]

DEF_TEST ( Unicode_textencodings  ,
reporter   
)

Definition at line 22 of file UnicodeTest.cpp.

22 {
23 const char text8[] = "ABCDEFGabcdefg0123456789";
24 uint16_t text16[sizeof(text8)];
25 int32_t text32[sizeof(text8)];
26 size_t len8 = strlen(text8);
27 size_t len16 = len8 * 2;
28 size_t len32 = len8 * 4;
29
30 // expand our 8bit chars to 16 and 32
31 for (size_t i = 0; i < len8; ++i) {
32 text32[i] = text16[i] = text8[i];
33 }
34
35 uint16_t glyphs8[sizeof(text8)];
36 uint16_t glyphs16[sizeof(text8)];
37 uint16_t glyphs32[sizeof(text8)];
38
40
41 int count8 = font.textToGlyphs(text8, len8, SkTextEncoding::kUTF8, glyphs8, std::size(glyphs8));
42 int count16 = font.textToGlyphs(text16, len16, SkTextEncoding::kUTF16, glyphs16, std::size(glyphs16));
43 int count32 = font.textToGlyphs(text32, len32, SkTextEncoding::kUTF32, glyphs32, std::size(glyphs32));
44
45 REPORTER_ASSERT(reporter, (int)len8 == count8);
46 REPORTER_ASSERT(reporter, (int)len8 == count16);
47 REPORTER_ASSERT(reporter, (int)len8 == count32);
48
49 REPORTER_ASSERT(reporter, !memcmp(glyphs8, glyphs16, count8 * sizeof(uint16_t)));
50 REPORTER_ASSERT(reporter, !memcmp(glyphs8, glyphs32, count8 * sizeof(uint16_t)));
51}
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kUTF16
uses two byte words to represent most of Unicode
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