Flutter Engine
 
Loading...
Searching...
No Matches
paragraph_builder.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
10
11namespace impeller::interop {
12
15
17
19 return !!context_;
20}
21
23 GetBuilder(style.GetParagraphStyle())->PushStyle(style.CreateTextStyle());
24}
25
27 GetBuilder()->Pop();
28}
29
30void ParagraphBuilder::AddText(const uint8_t* data, size_t byte_length) {
31 GetBuilder()->AddText(data, byte_length);
32}
33
35 auto txt_paragraph = GetBuilder()->Build();
36 if (!txt_paragraph) {
37 return nullptr;
38 }
39 txt_paragraph->Layout(width);
40 return Create<Paragraph>(std::move(txt_paragraph));
41}
42
43const std::unique_ptr<txt::ParagraphBuilder>& ParagraphBuilder::GetBuilder(
44 const txt::ParagraphStyle& style) const {
45 if (lazy_builder_) {
46 return lazy_builder_;
47 }
48 lazy_builder_ = std::make_unique<txt::ParagraphBuilderSkia>(
49 style, //
50 context_->GetFontCollection(), //
51 true // is impeller enabled
52 );
53 return lazy_builder_;
54}
55
56const std::unique_ptr<txt::ParagraphBuilder>& ParagraphBuilder::GetBuilder()
57 const {
58 static txt::ParagraphStyle kDefaultStyle;
59 return GetBuilder(kDefaultStyle);
60}
61
62} // namespace impeller::interop
ParagraphBuilder(ScopedObject< TypographyContext > context)
ScopedObject< Paragraph > Build(Scalar width) const
void PushStyle(const ParagraphStyle &style)
void AddText(const uint8_t *data, size_t byte_length)
txt::TextStyle CreateTextStyle() const
const txt::ParagraphStyle & GetParagraphStyle() const
float Scalar
Definition scalar.h:19
Definition ref_ptr.h:261
int32_t width
std::shared_ptr< const fml::Mapping > data