blob: c40372dce029f8e96af4b95c6bd32b27367a33d6 [file] [log] [blame]
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001// Copyright 2019 Google LLC.
Ben Wagnerb985b4b2020-05-28 15:59:42 -04002
3#include "modules/skparagraph/include/DartTypes.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -04004#include "modules/skparagraph/include/ParagraphStyle.h"
Ben Wagnerb985b4b2020-05-28 15:59:42 -04005#include "modules/skparagraph/src/ParagraphUtil.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -04006
7namespace skia {
8namespace textlayout {
9
10StrutStyle::StrutStyle() {
11 fFontStyle = SkFontStyle::Normal();
12 fFontSize = 14;
13 fHeight = 1;
14 fLeading = -1;
Julia Lavrovadb9f6692019-08-01 16:02:17 -040015 fForceHeight = false;
Julia Lavrovac2228562019-08-08 16:51:27 -040016 fHeightOverride = false;
Julia Lavrovadb9f6692019-08-01 16:02:17 -040017 fEnabled = false;
Julia Lavrovaa3552c52019-05-30 16:12:56 -040018}
19
20ParagraphStyle::ParagraphStyle() {
21 fTextAlign = TextAlign::kStart;
22 fTextDirection = TextDirection::kLtr;
23 fLinesLimit = std::numeric_limits<size_t>::max();
24 fHeight = 1;
Julia Lavrova9588a642020-04-30 11:31:25 -040025 fTextHeightBehavior = TextHeightBehavior::kAll;
Julia Lavrovaa3552c52019-05-30 16:12:56 -040026 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) {
Ben Wagnerb985b4b2020-05-28 15:59:42 -040040 fEllipsis = SkStringFromU16String(ellipsis);
Julia Lavrovaa3552c52019-05-30 16:12:56 -040041}
42} // namespace textlayout
43} // namespace skia