Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
paragraph_style.cpp
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
5#include "../export.h"
6#include "../wrappers.h"
8
9using namespace skia::textlayout;
10using namespace Skwasm;
11
13 auto style = new ParagraphStyle();
14
15 // This is the default behavior in Flutter
16 style->setReplaceTabCharacters(true);
17
18 // Default text style has a black color
19 TextStyle textStyle;
20 textStyle.setColor(SK_ColorBLACK);
21 style->setTextStyle(textStyle);
22
23 return style;
24}
25
27 delete style;
28}
29
31 TextAlign align) {
32 style->setTextAlign(align);
33}
34
36 TextDirection direction) {
37 style->setTextDirection(direction);
38}
39
41 size_t maxLines) {
42 style->setMaxLines(maxLines);
43}
44
49
51 ParagraphStyle* style,
52 bool applyHeightToFirstAscent,
53 bool applyHeightToLastDescent) {
54 TextHeightBehavior behavior;
55 if (!applyHeightToFirstAscent && !applyHeightToLastDescent) {
56 behavior = kDisableAll;
57 } else if (!applyHeightToLastDescent) {
58 behavior = kDisableLastDescent;
59 } else if (!applyHeightToFirstAscent) {
60 behavior = kDisableFirstAscent;
61 } else {
62 behavior = kAll;
63 }
64 style->setTextHeightBehavior(behavior);
65}
66
68 SkString* ellipsis) {
69 style->setEllipsis(*ellipsis);
70}
71
73 StrutStyle* strutStyle) {
74 style->setStrutStyle(*strutStyle);
75}
76
78 TextStyle* textStyle) {
79 style->setTextStyle(*textStyle);
80}
81
83 bool applyRoundingHack) {
84 style->setApplyRoundingHack(applyRoundingHack);
85}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
void setColor(SkColor color)
Definition TextStyle.h:166
float SkScalar
Definition extension.cpp:12
SKWASM_EXPORT void paragraphStyle_setStrutStyle(ParagraphStyle *style, StrutStyle *strutStyle)
SKWASM_EXPORT void paragraphStyle_setTextStyle(ParagraphStyle *style, TextStyle *textStyle)
SKWASM_EXPORT void paragraphStyle_setTextAlign(ParagraphStyle *style, TextAlign align)
SKWASM_EXPORT void paragraphStyle_setHeight(ParagraphStyle *style, SkScalar height)
SKWASM_EXPORT void paragraphStyle_setMaxLines(ParagraphStyle *style, size_t maxLines)
SKWASM_EXPORT ParagraphStyle * paragraphStyle_create()
SKWASM_EXPORT void paragraphStyle_setEllipsis(ParagraphStyle *style, SkString *ellipsis)
SKWASM_EXPORT void paragraphStyle_setApplyRoundingHack(ParagraphStyle *style, bool applyRoundingHack)
SKWASM_EXPORT void paragraphStyle_setTextDirection(ParagraphStyle *style, TextDirection direction)
SKWASM_EXPORT void paragraphStyle_dispose(ParagraphStyle *style)
SKWASM_EXPORT void paragraphStyle_setTextHeightBehavior(ParagraphStyle *style, bool applyHeightToFirstAscent, bool applyHeightToLastDescent)
int32_t height
void setEllipsis(const std::u16string &ellipsis)
void setTextDirection(TextDirection direction)
void setTextStyle(const TextStyle &textStyle)
void setMaxLines(size_t maxLines)
void setHeight(SkScalar height)
void setStrutStyle(StrutStyle strutStyle)
void setTextHeightBehavior(TextHeightBehavior v)
void setTextAlign(TextAlign align)
#define SKWASM_EXPORT
Definition export.h:10