1// Copyright 2019 Google LLC.
2
3#include "modules/skparagraph/include/DartTypes.h"
4#include "modules/skparagraph/include/ParagraphStyle.h"
5#include "modules/skparagraph/src/ParagraphUtil.h"
6
7namespace skia {
8namespace textlayout {
9
10StrutStyle::StrutStyle() {
11 fFontStyle = SkFontStyle::Normal();
12 fFontSize = 14;
13 fHeight = 1;
14 fLeading = -1;
15 fForceHeight = false;
16 fHeightOverride = false;
17 fEnabled = false;
18}
19
20ParagraphStyle::ParagraphStyle() {
21 fTextAlign = TextAlign::kStart;
22 fTextDirection = TextDirection::kLtr;
23 fLinesLimit = std::numeric_limits<size_t>::max();
24 fHeight = 1;
25 fTextHeightBehavior = TextHeightBehavior::kAll;
26 fHintingIsOn = true;
27}
28
29TextAlign ParagraphStyle::effective_align() const {
30 if (fTextAlign == TextAlign::kStart) {
31 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kLeft : TextAlign::kRight;
32 } else if (fTextAlign == TextAlign::kEnd) {
33 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kRight : TextAlign::kLeft;
34 } else {
35 return fTextAlign;
36 }
37}
38
39void ParagraphStyle::setEllipsis(const std::u16string& ellipsis) {
40 fEllipsis = SkStringFromU16String(ellipsis);
41}
42} // namespace textlayout
43} // namespace skia
44