blob: 4e3094f472148c9e927e877b6e4b867ff208e80d [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"
Julia Lavrovab6b7fff2020-09-11 13:59:49 +00005#include "modules/skshaper/src/SkUnicode.h"
6#include "src/core/SkStringUtils.h"
7#include "src/utils/SkUTF.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -04008
9namespace skia {
10namespace textlayout {
11
12StrutStyle::StrutStyle() {
13 fFontStyle = SkFontStyle::Normal();
14 fFontSize = 14;
15 fHeight = 1;
16 fLeading = -1;
Julia Lavrovadb9f6692019-08-01 16:02:17 -040017 fForceHeight = false;
Julia Lavrovac2228562019-08-08 16:51:27 -040018 fHeightOverride = false;
Julia Lavrovadb9f6692019-08-01 16:02:17 -040019 fEnabled = false;
Julia Lavrovaa3552c52019-05-30 16:12:56 -040020}
21
22ParagraphStyle::ParagraphStyle() {
23 fTextAlign = TextAlign::kStart;
24 fTextDirection = TextDirection::kLtr;
25 fLinesLimit = std::numeric_limits<size_t>::max();
26 fHeight = 1;
Julia Lavrova9588a642020-04-30 11:31:25 -040027 fTextHeightBehavior = TextHeightBehavior::kAll;
Julia Lavrovaa3552c52019-05-30 16:12:56 -040028 fHintingIsOn = true;
29}
30
31TextAlign ParagraphStyle::effective_align() const {
32 if (fTextAlign == TextAlign::kStart) {
33 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kLeft : TextAlign::kRight;
34 } else if (fTextAlign == TextAlign::kEnd) {
35 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kRight : TextAlign::kLeft;
36 } else {
37 return fTextAlign;
38 }
39}
Julia Lavrovaa3552c52019-05-30 16:12:56 -040040} // namespace textlayout
41} // namespace skia