Flutter Engine
 
Loading...
Searching...
No Matches
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  FontWeight : int { normal = 400 }
 
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< SkFontMgr > GetDefaultFontManager (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 21 of file paragraph_skia.cc.

Enumeration Type Documentation

◆ FontStyle

enum class txt::FontStyle
strong
Enumerator
normal 
italic 

Definition at line 10 of file font_style.h.

10 {
11 // NOLINTBEGIN(readability-identifier-naming)
12 normal,
13 italic,
14 // NOLINTEND(readability-identifier-naming)
15};
@ normal
Definition font_weight.h:12

◆ FontWeight

enum txt::FontWeight : int
Enumerator
normal 

Definition at line 10 of file font_weight.h.

10 : int {
11 // NOLINTBEGIN(readability-identifier-naming)
12 normal = 400, // Normal/Regular
13 // NOLINTEND(readability-identifier-naming)
14};

◆ 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 13 of file placeholder_run.h.

13 {
14 /// Match the baseline of the placeholder with the baseline.
16
17 /// Align the bottom edge of the placeholder with the baseline such that the
18 /// placeholder sits on top of the baseline.
20
21 /// Align the top edge of the placeholder with the baseline specified in
22 /// such that the placeholder hangs below the baseline.
24
25 /// Align the top edge of the placeholder with the top edge of the font.
26 /// When the placeholder is very tall, the extra space will hang from
27 /// the top and extend through the bottom of the line.
28 kTop,
29
30 /// Align the bottom edge of the placeholder with the top edge of the font.
31 /// When the placeholder is very tall, the extra space will rise from
32 /// the bottom and extend through the top of the line.
33 kBottom,
34
35 /// Align the middle of the placeholder with the middle of the text. When the
36 /// placeholder is very tall, the extra space will grow equally from
37 /// the top and bottom of the line.
38 kMiddle,
39};
@ kBaseline
Match the baseline of the placeholder with the baseline.

◆ TextAlign

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

Definition at line 17 of file paragraph_style.h.

17 {
18 // NOLINTBEGIN(readability-identifier-naming)
19 left,
20 right,
21 center,
22 justify,
23 start,
24 end,
25 // NOLINTEND(readability-identifier-naming)
26};
const size_t start
const size_t end

◆ TextBaseline

Enumerator
kAlphabetic 
kIdeographic 

Definition at line 10 of file text_baseline.h.

10 {
13};
@ kIdeographic
@ kAlphabetic

◆ TextDecoration

Enumerator
kNone 
kUnderline 
kOverline 
kLineThrough 

Definition at line 12 of file text_decoration.h.

12 {
13 kNone = 0x0,
14 kUnderline = 0x1,
15 kOverline = 0x2,
16 kLineThrough = 0x4,
17};
@ kNone
Definition layer.h:43
@ kLineThrough

◆ TextDecorationStyle

Enumerator
kSolid 
kDouble 
kDotted 
kDashed 
kWavy 

Definition at line 19 of file text_decoration.h.

◆ TextDirection

enum class txt::TextDirection
strong
Enumerator
rtl 
ltr 

Definition at line 28 of file paragraph_style.h.

28 {
29 // NOLINTBEGIN(readability-identifier-naming)
30 rtl,
31 ltr,
32 // NOLINTEND(readability-identifier-naming)
33};

◆ TextHeightBehavior

Enumerator
kAll 
kDisableFirstAscent 
kDisableLastDescent 
kDisableAll 

Definition at line 49 of file paragraph_style.h.

49 {
50 kAll = 0x0,
53 kDisableAll = 0x1 | 0x2,
54};
@ kDisableAll
@ kDisableLastDescent
@ kDisableFirstAscent

Function Documentation

◆ GetDefaultFontFamilies()

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

Definition at line 13 of file platform.cc.

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

Referenced by txt::FontCollection::CreateSktFontCollection().

◆ GetDefaultFontManager()

◆ GetFontDir()

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

Definition at line 11 of file txt_test_utils.cc.

11 {
12 return gFontDir;
13}
static std::string gFontDir

References gFontDir.

Referenced by BENCHMARK_DEFINE_F(), main(), and SkParagraphFixture::SetUp().

◆ 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

References kNormalWeightValue, kWeightTag, and flutter::size.

Referenced by RegisterSystemFonts().

◆ 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

References txt::DynamicFontManager::font_provider(), i, kSFProDisplayBreakPoint, kSFProDisplayName, MatchSystemUIFont(), and txt::TypefaceFontAssetProvider::RegisterTypeface().

Referenced by txt::testing::TEST_F().

◆ SetFontDir()

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

Definition at line 15 of file txt_test_utils.cc.

15 {
16 gFontDir = dir;
17}

References gFontDir.

Referenced by main().

◆ TEST_F()

txt::TEST_F ( SkiaParagraphBuilderTests  ,
ParagraphStrutStyle   
)

Definition at line 21 of file paragraph_builder_skia_tests.cc.

21 {
23 auto collection = std::make_shared<FontCollection>();
24 auto builder = ParagraphBuilderSkia(style, collection, false);
25
26 auto strut_style = builder.TxtToSkia(style).getStrutStyle();
27 ASSERT_FALSE(strut_style.getHalfLeading());
28
29 style.strut_half_leading = true;
30 strut_style = builder.TxtToSkia(style).getStrutStyle();
31 ASSERT_TRUE(strut_style.getHalfLeading());
32}
ParagraphBuilder implementation using Skia's text layout module.

References txt::ParagraphStyle::strut_half_leading.

Variable Documentation

◆ gFontDir

std::string txt::gFontDir
static

Definition at line 9 of file txt_test_utils.cc.

Referenced by GetFontDir(), and SetFontDir().

◆ kWeightTag

const FourCharCode txt::kWeightTag = 'wght'

Definition at line 31 of file platform_mac.mm.

Referenced by MatchSystemUIFont().