• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Google LLC.
2 #include <string>
3 #include "modules/skparagraph/include/ParagraphStyle.h"
4 #include "unicode/unistr.h"
5 
6 namespace skia {
7 namespace textlayout {
8 
StrutStyle()9 StrutStyle::StrutStyle() {
10     fFontStyle = SkFontStyle::Normal();
11     fFontSize = 14;
12     fHeight = 1;
13     fLeading = -1;
14     fForceHeight = false;
15     fHeightOverride = false;
16     fEnabled = false;
17 }
18 
ParagraphStyle()19 ParagraphStyle::ParagraphStyle() {
20     fTextAlign = TextAlign::kStart;
21     fTextDirection = TextDirection::kLtr;
22     fLinesLimit = std::numeric_limits<size_t>::max();
23     fHeight = 1;
24     fHintingIsOn = true;
25 }
26 
effective_align() const27 TextAlign ParagraphStyle::effective_align() const {
28     if (fTextAlign == TextAlign::kStart) {
29         return (fTextDirection == TextDirection::kLtr) ? TextAlign::kLeft : TextAlign::kRight;
30     } else if (fTextAlign == TextAlign::kEnd) {
31         return (fTextDirection == TextDirection::kLtr) ? TextAlign::kRight : TextAlign::kLeft;
32     } else {
33         return fTextAlign;
34     }
35 }
36 
setEllipsis(const std::u16string & ellipsis)37 void ParagraphStyle::setEllipsis(const std::u16string& ellipsis) {
38     icu::UnicodeString unicode;
39     unicode.setTo((UChar*)ellipsis.data());
40     std::string str;
41     unicode.toUTF8String(str);
42     fEllipsis = SkString(str.c_str());
43 }
44 }  // namespace textlayout
45 }  // namespace skia
46