Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 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 | |
| 9 | StrutStyle::StrutStyle() { |
| 10 | fFontStyle = SkFontStyle::Normal(); |
| 11 | fFontSize = 14; |
| 12 | fHeight = 1; |
| 13 | fLeading = -1; |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 14 | fForceHeight = false; |
Julia Lavrova | c222856 | 2019-08-08 16:51:27 -0400 | [diff] [blame] | 15 | fHeightOverride = false; |
Julia Lavrova | db9f669 | 2019-08-01 16:02:17 -0400 | [diff] [blame] | 16 | fEnabled = false; |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | ParagraphStyle::ParagraphStyle() { |
| 20 | fTextAlign = TextAlign::kStart; |
| 21 | fTextDirection = TextDirection::kLtr; |
| 22 | fLinesLimit = std::numeric_limits<size_t>::max(); |
| 23 | fHeight = 1; |
Julia Lavrova | 9588a64 | 2020-04-30 11:31:25 -0400 | [diff] [blame^] | 24 | fTextHeightBehavior = TextHeightBehavior::kAll; |
Julia Lavrova | a3552c5 | 2019-05-30 16:12:56 -0400 | [diff] [blame] | 25 | fHintingIsOn = true; |
| 26 | } |
| 27 | |
| 28 | TextAlign ParagraphStyle::effective_align() const { |
| 29 | if (fTextAlign == TextAlign::kStart) { |
| 30 | return (fTextDirection == TextDirection::kLtr) ? TextAlign::kLeft : TextAlign::kRight; |
| 31 | } else if (fTextAlign == TextAlign::kEnd) { |
| 32 | return (fTextDirection == TextDirection::kLtr) ? TextAlign::kRight : TextAlign::kLeft; |
| 33 | } else { |
| 34 | return fTextAlign; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | void ParagraphStyle::setEllipsis(const std::u16string& ellipsis) { |
| 39 | icu::UnicodeString unicode; |
| 40 | unicode.setTo((UChar*)ellipsis.data()); |
| 41 | std::string str; |
| 42 | unicode.toUTF8String(str); |
| 43 | fEllipsis = SkString(str.c_str()); |
| 44 | } |
| 45 | } // namespace textlayout |
| 46 | } // namespace skia |