1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef LIB_TXT_SRC_TEXT_STYLE_H_ 18 #define LIB_TXT_SRC_TEXT_STYLE_H_ 19 20 #include <string> 21 #include <vector> 22 23 #include "font_features.h" 24 #include "font_style.h" 25 #include "font_weight.h" 26 #include "text_baseline.h" 27 #include "text_decoration.h" 28 #include "text_shadow.h" 29 #include "third_party/skia/include/core/SkColor.h" 30 #include "third_party/skia/include/core/SkPaint.h" 31 32 namespace txt { 33 34 class TextStyle { 35 public: 36 SkColor color = SK_ColorWHITE; 37 int decoration = TextDecoration::kNone; 38 // Does not make sense to draw a transparent object, so we use it as a default 39 // value to indicate no decoration color was set. 40 SkColor decoration_color = SK_ColorTRANSPARENT; 41 TextDecorationStyle decoration_style = TextDecorationStyle::kSolid; 42 // Thickness is applied as a multiplier to the default thickness of the font. 43 double decoration_thickness_multiplier = 1.0; 44 FontWeight font_weight = FontWeight::w400; 45 FontStyle font_style = FontStyle::normal; 46 TextBaseline text_baseline = TextBaseline::kAlphabetic; 47 // An ordered list of fonts in order of priority. The first font is more 48 // highly preferred than the last font. 49 std::vector<std::string> font_families; 50 double font_size = 14.0; 51 double letter_spacing = 0.0; 52 double word_spacing = 0.0; 53 double height = 1.0; 54 bool has_height_override = false; 55 std::string locale; 56 bool has_background = false; 57 SkPaint background; 58 bool has_foreground = false; 59 SkPaint foreground; 60 // An ordered list of shadows where the first shadow will be drawn first (at 61 // the bottom). 62 std::vector<TextShadow> text_shadows; 63 FontFeatures font_features; 64 65 TextStyle(); 66 67 bool equals(const TextStyle& other) const; 68 }; 69 70 } // namespace txt 71 72 #endif // LIB_TXT_SRC_TEXT_STYLE_H_ 73