Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
txt Namespace Reference

Namespaces

namespace  testing
 

Classes

class  AssetFontManager
 
class  DynamicFontManager
 
class  FontAssetProvider
 
class  FontCollection
 
class  FontFeatures
 
class  FontVariations
 
class  LineMetrics
 
class  Paragraph
 
class  ParagraphBuilder
 
class  ParagraphBuilderSkia
 ParagraphBuilder implementation using Skia's text layout module. More...
 
class  ParagraphSkia
 
class  ParagraphStyle
 
class  PlaceholderRun
 
class  RunMetrics
 
class  SkiaParagraphBuilderTests
 
class  TestFontManager
 
class  TextShadow
 
class  TextStyle
 
class  TypefaceFontAssetProvider
 
class  TypefaceFontStyleSet
 

Typedefs

using PaintID = skt::ParagraphPainter::PaintID
 

Enumerations

enum class  FontStyle { normal , italic }
 
enum class  FontWeight {
  w100 , w200 , w300 , w400 ,
  w500 , w600 , w700 , w800 ,
  w900
}
 
enum class  TextAlign {
  left , right , center , justify ,
  start , end
}
 
enum class  TextDirection { rtl , ltr }
 
enum  TextHeightBehavior { kAll = 0x0 , kDisableFirstAscent = 0x1 , kDisableLastDescent = 0x2 , kDisableAll = 0x1 | 0x2 }
 
enum class  PlaceholderAlignment {
  kBaseline , kAboveBaseline , kBelowBaseline , kTop ,
  kBottom , kMiddle
}
 Where to vertically align the placeholder relative to the surrounding text. More...
 
enum  TextBaseline { kAlphabetic , kIdeographic }
 
enum  TextDecoration { kNone = 0x0 , kUnderline = 0x1 , kOverline = 0x2 , kLineThrough = 0x4 }
 
enum  TextDecorationStyle {
  kSolid , kDouble , kDotted , kDashed ,
  kWavy
}
 

Functions

std::vector< std::string > GetDefaultFontFamilies ()
 
sk_sp< SkFontMgrGetDefaultFontManager (uint32_t font_initialization_data)
 
void RegisterSystemFonts (const DynamicFontManager &dynamic_font_manager)
 
fml::CFRef< CTFontRef > MatchSystemUIFont (float desired_weight, float size)
 
 TEST_F (SkiaParagraphBuilderTests, ParagraphStrutStyle)
 
const std::string & GetFontDir ()
 
void SetFontDir (const std::string &dir)
 

Variables

const FourCharCode kWeightTag = 'wght'
 
static std::string gFontDir
 

Typedef Documentation

◆ PaintID

using txt::PaintID = typedef skt::ParagraphPainter::PaintID

Definition at line 29 of file paragraph_skia.cc.

Enumeration Type Documentation

◆ FontStyle

enum class txt::FontStyle
strong
Enumerator
normal 
italic 

Definition at line 22 of file font_style.h.

22 {
23 normal,
24 italic,
25};

◆ FontWeight

enum class txt::FontWeight
strong
Enumerator
w100 
w200 
w300 
w400 
w500 
w600 
w700 
w800 
w900 

Definition at line 22 of file font_weight.h.

22 {
23 w100, // Thin
24 w200, // Extra-Light
25 w300, // Light
26 w400, // Normal/Regular
27 w500, // Medium
28 w600, // Semi-bold
29 w700, // Bold
30 w800, // Extra-Bold
31 w900, // Black
32};

◆ PlaceholderAlignment

enum class txt::PlaceholderAlignment
strong

Where to vertically align the placeholder relative to the surrounding text.

Enumerator
kBaseline 

Match the baseline of the placeholder with the baseline.

kAboveBaseline 

Align the bottom edge of the placeholder with the baseline such that the placeholder sits on top of the baseline.

kBelowBaseline 

Align the top edge of the placeholder with the baseline specified in such that the placeholder hangs below the baseline.

kTop 

Align the top edge of the placeholder with the top edge of the font. When the placeholder is very tall, the extra space will hang from the top and extend through the bottom of the line.

kBottom 

Align the bottom edge of the placeholder with the top edge of the font. When the placeholder is very tall, the extra space will rise from the bottom and extend through the top of the line.

kMiddle 

Align the middle of the placeholder with the middle of the text. When the placeholder is very tall, the extra space will grow equally from the top and bottom of the line.

Definition at line 25 of file placeholder_run.h.

25 {
26 /// Match the baseline of the placeholder with the baseline.
27 kBaseline,
28
29 /// Align the bottom edge of the placeholder with the baseline such that the
30 /// placeholder sits on top of the baseline.
31 kAboveBaseline,
32
33 /// Align the top edge of the placeholder with the baseline specified in
34 /// such that the placeholder hangs below the baseline.
35 kBelowBaseline,
36
37 /// Align the top edge of the placeholder with the top edge of the font.
38 /// When the placeholder is very tall, the extra space will hang from
39 /// the top and extend through the bottom of the line.
40 kTop,
41
42 /// Align the bottom edge of the placeholder with the top edge of the font.
43 /// When the placeholder is very tall, the extra space will rise from
44 /// the bottom and extend through the top of the line.
45 kBottom,
46
47 /// Align the middle of the placeholder with the middle of the text. When the
48 /// placeholder is very tall, the extra space will grow equally from
49 /// the top and bottom of the line.
50 kMiddle,
51};

◆ TextAlign

enum class txt::TextAlign
strong
Enumerator
left 
right 
center 
justify 
start 
end 

Definition at line 29 of file paragraph_style.h.

29 {
30 left,
31 right,
32 center,
33 justify,
34 start,
35 end,
36};
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
static SkScalar center(float pos0, float pos1)
glong glong end

◆ TextBaseline

Enumerator
kAlphabetic 
kIdeographic 

Definition at line 22 of file text_baseline.h.

22 {
25};
@ kIdeographic
@ kAlphabetic

◆ TextDecoration

Enumerator
kNone 
kUnderline 
kOverline 
kLineThrough 

Definition at line 24 of file text_decoration.h.

24 {
25 kNone = 0x0,
26 kUnderline = 0x1,
27 kOverline = 0x2,
28 kLineThrough = 0x4,
29};

◆ TextDecorationStyle

Enumerator
kSolid 
kDouble 
kDotted 
kDashed 
kWavy 

Definition at line 31 of file text_decoration.h.

31{ kSolid, kDouble, kDotted, kDashed, kWavy };

◆ TextDirection

enum class txt::TextDirection
strong
Enumerator
rtl 
ltr 

Definition at line 38 of file paragraph_style.h.

◆ TextHeightBehavior

Enumerator
kAll 
kDisableFirstAscent 
kDisableLastDescent 
kDisableAll 

Definition at line 57 of file paragraph_style.h.

57 {
58 kAll = 0x0,
59 kDisableFirstAscent = 0x1,
60 kDisableLastDescent = 0x2,
61 kDisableAll = 0x1 | 0x2,
62};

Function Documentation

◆ GetDefaultFontFamilies()

std::vector< std::string > txt::GetDefaultFontFamilies ( )

Definition at line 13 of file platform.cc.

13 {
14 return {"Arial"};
15}

◆ GetDefaultFontManager()

sk_sp< SkFontMgr > txt::GetDefaultFontManager ( uint32_t  font_initialization_data = 0)

Definition at line 17 of file platform.cc.

17 {
18#if defined(SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE)
20#else
22#endif
23 return mgr;
24}
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
static sk_sp< SkFontMgr > RefEmpty()

◆ GetFontDir()

const std::string & txt::GetFontDir ( )

Definition at line 23 of file txt_test_utils.cc.

23 {
24 return gFontDir;
25}
static std::string gFontDir

◆ MatchSystemUIFont()

fml::CFRef< CTFontRef > txt::MatchSystemUIFont ( float  desired_weight,
float  size 
)

Definition at line 46 of file platform_mac.mm.

46 {
48 CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr));
49
50 if (desired_weight == kNormalWeightValue) {
51 return ct_font;
52 }
53
54 fml::CFRef<CFMutableDictionaryRef> variations(CFDictionaryCreateMutable(
55 kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks,
56 &kCFTypeDictionaryValueCallBacks));
57
58 auto add_axis_to_variations = [&variations](const FourCharCode tag,
59 float desired_value,
60 float normal_value) {
61 if (desired_value != normal_value) {
62 fml::CFRef<CFNumberRef> tag_number(
63 CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &tag));
64 fml::CFRef<CFNumberRef> value_number(CFNumberCreate(
65 kCFAllocatorDefault, kCFNumberFloatType, &desired_value));
66 CFDictionarySetValue(variations, tag_number, value_number);
67 }
68 };
69 add_axis_to_variations(kWeightTag, desired_weight, kNormalWeightValue);
70
71 fml::CFRef<CFMutableDictionaryRef> attributes(CFDictionaryCreateMutable(
72 kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks,
73 &kCFTypeDictionaryValueCallBacks));
74 CFDictionarySetValue(attributes, kCTFontVariationAttribute, variations);
75
77 CTFontDescriptorCreateWithAttributes(attributes));
78
80 CTFontCreateCopyWithAttributes(ct_font, size, nullptr, var_font_desc));
81}
float kNormalWeightValue

◆ RegisterSystemFonts()

void txt::RegisterSystemFonts ( const DynamicFontManager dynamic_font_manager)

Definition at line 83 of file platform_mac.mm.

83 {
84 // iOS loads different system fonts when size is greater than 28 or lower
85 // than 17. The "familyName" property returned from CoreText stays the same
86 // despite the typeface is different.
87 //
88 // Below code manually loads and registers the larger font. The existing
89 // fallback correctly loads the smaller font. The code also iterates through
90 // the possible font weights from 100 - 900 to correctly load all of them, as
91 // a CTFont object for the large system font does not include all of the font
92 // weights by default.
93 //
94 // Darwin system fonts from 17 to 28 also have dynamic spacing based on sizes.
95 // These two fonts do not match the spacings when sizes are from 17 to 28.
96 // The spacing should be handled by the app or the framework.
97 //
98 // See https://www.wwdcnotes.com/notes/wwdc20/10175/ for Apple's document on
99 // this topic.
100 auto register_weighted_font = [&dynamic_font_manager](const int weight) {
101 sk_sp<SkTypeface> large_system_font_weighted = SkMakeTypefaceFromCTFont(
103 if (large_system_font_weighted) {
104 dynamic_font_manager.font_provider().RegisterTypeface(
105 large_system_font_weighted, kSFProDisplayName);
106 }
107 };
108 for (int i = 0; i < 8; i++) {
109 const int font_weight = i * 100;
110 register_weighted_font(font_weight);
111 }
112 // The value 780 returns a font weight of 800.
113 register_weighted_font(780);
114 // The value of 810 returns a font weight of 900.
115 register_weighted_font(810);
116}
TypefaceFontAssetProvider & font_provider() const
void RegisterTypeface(sk_sp< SkTypeface > typeface)
fml::CFRef< CTFontRef > MatchSystemUIFont(float desired_weight, float size)
static const std::string kSFProDisplayName
static const CGFloat kSFProDisplayBreakPoint

◆ SetFontDir()

void txt::SetFontDir ( const std::string &  dir)

Definition at line 27 of file txt_test_utils.cc.

27 {
28 gFontDir = dir;
29}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition switches.h:145

◆ TEST_F()

txt::TEST_F ( SkiaParagraphBuilderTests  ,
ParagraphStrutStyle   
)

Definition at line 33 of file paragraph_builder_skia_tests.cc.

33 {
35 auto collection = std::make_shared<FontCollection>();
36 auto builder = ParagraphBuilderSkia(style, collection, false);
37
38 auto strut_style = builder.TxtToSkia(style).getStrutStyle();
39 ASSERT_FALSE(strut_style.getHalfLeading());
40
41 style.strut_half_leading = true;
42 strut_style = builder.TxtToSkia(style).getStrutStyle();
43 ASSERT_TRUE(strut_style.getHalfLeading());
44}
ParagraphBuilder implementation using Skia's text layout module.

Variable Documentation

◆ gFontDir

std::string txt::gFontDir
static

Definition at line 21 of file txt_test_utils.cc.

◆ kWeightTag

const FourCharCode txt::kWeightTag = 'wght'

Definition at line 31 of file platform_mac.mm.