Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Enumerations | Functions
FontTest.cpp File Reference
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkAutoMalloc.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkPtrRecorder.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkWriteBuffer.h"
#include "tests/Test.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"
#include <cstddef>

Go to the source code of this file.

Enumerations

enum  {
  kForceAutoHinting = 1 << 0 , kEmbeddedBitmaps = 1 << 1 , kSubpixel = 1 << 2 , kLinearMetrics = 1 << 3 ,
  kEmbolden = 1 << 4 , kBaselineSnap = 1 << 5 , kAllBits = 0x3F
}
 

Functions

static SkFont serialize_deserialize (const SkFont &font, skiatest::Reporter *reporter)
 
static void apply_flags (SkFont *font, unsigned flags)
 
 DEF_TEST (Font_flatten, reporter)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kForceAutoHinting 
kEmbeddedBitmaps 
kSubpixel 
kLinearMetrics 
kEmbolden 
kBaselineSnap 
kAllBits 

Definition at line 54 of file FontTest.cpp.

54 {
55 kForceAutoHinting = 1 << 0,
56 kEmbeddedBitmaps = 1 << 1,
57 kSubpixel = 1 << 2,
58 kLinearMetrics = 1 << 3,
59 kEmbolden = 1 << 4,
60 kBaselineSnap = 1 << 5,
61
62 kAllBits = 0x3F,
63};
@ kForceAutoHinting
Definition FontTest.cpp:55
@ kSubpixel
Definition FontTest.cpp:57
@ kBaselineSnap
Definition FontTest.cpp:60
@ kEmbeddedBitmaps
Definition FontTest.cpp:56
@ kAllBits
Definition FontTest.cpp:62
@ kLinearMetrics
Definition FontTest.cpp:58
@ kEmbolden
Definition FontTest.cpp:59

Function Documentation

◆ apply_flags()

static void apply_flags ( SkFont font,
unsigned  flags 
)
static

Definition at line 65 of file FontTest.cpp.

65 {
66 font->setForceAutoHinting(SkToBool(flags & kForceAutoHinting));
67 font->setEmbeddedBitmaps( SkToBool(flags & kEmbeddedBitmaps));
68 font->setSubpixel( SkToBool(flags & kSubpixel));
69 font->setLinearMetrics( SkToBool(flags & kLinearMetrics));
70 font->setEmbolden( SkToBool(flags & kEmbolden));
71 font->setBaselineSnap( SkToBool(flags & kBaselineSnap));
72}
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
FlutterSemanticsFlag flags
font
Font Metadata and Metrics.

◆ DEF_TEST()

DEF_TEST ( Font_flatten  ,
reporter   
)

Definition at line 74 of file FontTest.cpp.

74 {
75 const float sizes[] = {0, 0.001f, 1, 10, 10.001f, 100000.01f};
76 const float scales[] = {-5, 0, 1, 5};
77 const float skews[] = {-5, 0, 5};
78 const SkFont::Edging edges[] = {
80 };
81 const SkFontHinting hints[] = {
83 };
84 const unsigned int flags[] = {
87 };
88 const sk_sp<SkTypeface> typefaces[] = {
90 };
91
93 for (float size : sizes) {
94 font.setSize(size);
95 for (float scale : scales) {
96 font.setScaleX(scale);
97 for (float skew : skews) {
98 font.setSkewX(skew);
99 for (auto edge : edges) {
100 font.setEdging(edge);
101 for (auto hint : hints) {
102 font.setHinting(hint);
103 for (auto flag : flags) {
104 apply_flags(&font, flag);
105 for (const sk_sp<SkTypeface>& typeface : typefaces) {
106 font.setTypeface(typeface);
108 REPORTER_ASSERT(reporter, font == clone);
109 }
110 }
111 }
112 }
113 }
114 }
115 }
116}
reporter
static SkFont serialize_deserialize(const SkFont &font, skiatest::Reporter *reporter)
Definition FontTest.cpp:25
static void apply_flags(SkFont *font, unsigned flags)
Definition FontTest.cpp:65
SkFontHinting
Definition SkFontTypes.h:18
@ kNone
glyph outlines unchanged
@ kFull
modifies glyph outlines for maximum constrast
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
Edging
Definition SkFont.h:39
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
FlutterSemanticsFlag flag
sk_sp< SkTypeface > SampleUserTypeface()
const Scalar scale

◆ serialize_deserialize()

static SkFont serialize_deserialize ( const SkFont font,
skiatest::Reporter reporter 
)
static

Definition at line 25 of file FontTest.cpp.

25 {
26 sk_sp<SkRefCntSet> typefaces = sk_make_sp<SkRefCntSet>();
28 wb.setTypefaceRecorder(typefaces);
29
30 SkFontPriv::Flatten(font, wb);
31 size_t size = wb.bytesWritten();
32 SkAutoMalloc storage(size);
33 wb.writeToMemory(storage.get());
34
35 int count = typefaces->count();
36 SkASSERT((!font.getTypeface() && count == 0) ||
37 ( font.getTypeface() && count == 1));
38 if (count) {
39 SkTypeface* typeface;
40 typefaces->copyToArray((SkRefCnt**)&typeface);
41 SkASSERT(typeface == font.getTypeface());
42 }
43
44 SkReadBuffer rb(storage.get(), size);
45 sk_sp<SkTypeface> cloneTypeface = font.refTypeface();
46 if (count) {
47 rb.setTypefaceArray(&cloneTypeface, 1);
48 }
49 SkFont clone;
51 return clone;
52}
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
void setTypefaceRecorder(sk_sp< SkRefCntSet >)
static void Flatten(const SkFont &, SkWriteBuffer &buffer)
static bool Unflatten(SkFont *, SkReadBuffer &buffer)
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