1 // Copyright 2019 Google LLC. 2 3 #include "modules/skparagraph/include/DartTypes.h" 4 #include "modules/skparagraph/include/ParagraphStyle.h" 5 #include "src/utils/SkUTF.h" 6 #include "src/core/SkStringUtils.h" 7 8 namespace skia { 9 namespace textlayout { 10 StrutStyle()11StrutStyle::StrutStyle() { 12 #ifndef USE_SKIA_TXT 13 fFontStyle = SkFontStyle::Normal(); 14 #else 15 fFontStyle = RSFontStyle( 16 RSFontStyle::NORMAL_WEIGHT, 17 RSFontStyle::NORMAL_WIDTH, 18 RSFontStyle::UPRIGHT_SLANT); 19 #endif 20 fFontSize = 14; 21 fHeight = 1; 22 fLeading = -1; 23 fForceHeight = false; 24 fHeightOverride = false; 25 fHalfLeading = false; 26 fEnabled = false; 27 } 28 ParagraphStyle()29ParagraphStyle::ParagraphStyle() { 30 fTextAlign = TextAlign::kStart; 31 fTextDirection = TextDirection::kLtr; 32 fLinesLimit = std::numeric_limits<size_t>::max(); 33 fHeight = 1; 34 fTextHeightBehavior = TextHeightBehavior::kAll; 35 fHintingIsOn = true; 36 fReplaceTabCharacters = false; 37 } 38 effective_align() const39TextAlign ParagraphStyle::effective_align() const { 40 if (fTextAlign == TextAlign::kStart) { 41 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kLeft : TextAlign::kRight; 42 } else if (fTextAlign == TextAlign::kEnd) { 43 return (fTextDirection == TextDirection::kLtr) ? TextAlign::kRight : TextAlign::kLeft; 44 } else { 45 return fTextAlign; 46 } 47 } 48 } // namespace textlayout 49 } // namespace skia 50