• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
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 ANDROID_GRAPHICS_PAINT_H_
18 #define ANDROID_GRAPHICS_PAINT_H_
19 
20 #include <cutils/compiler.h>
21 
22 #include <SkPaint.h>
23 #include <string>
24 
25 #include <minikin/FontFamily.h>
26 
27 namespace android {
28 
29 class ANDROID_API Paint : public SkPaint {
30 public:
31     Paint();
32     Paint(const Paint& paint);
33     Paint(const SkPaint& paint);  // NOLINT(implicit)
34     ~Paint();
35 
36     Paint& operator=(const Paint& other);
37 
38     friend bool operator==(const Paint& a, const Paint& b);
39     friend bool operator!=(const Paint& a, const Paint& b) {
40         return !(a == b);
41     }
42 
setLetterSpacing(float letterSpacing)43     void setLetterSpacing(float letterSpacing) {
44         mLetterSpacing = letterSpacing;
45     }
46 
getLetterSpacing()47     float getLetterSpacing() const {
48         return mLetterSpacing;
49     }
50 
setWordSpacing(float wordSpacing)51     void setWordSpacing(float wordSpacing) {
52         mWordSpacing = wordSpacing;
53     }
54 
getWordSpacing()55     float getWordSpacing() const {
56         return mWordSpacing;
57     }
58 
setFontFeatureSettings(const std::string & fontFeatureSettings)59     void setFontFeatureSettings(const std::string& fontFeatureSettings) {
60         mFontFeatureSettings = fontFeatureSettings;
61     }
62 
getFontFeatureSettings()63     std::string getFontFeatureSettings() const {
64         return mFontFeatureSettings;
65     }
66 
setMinikinLangListId(uint32_t minikinLangListId)67     void setMinikinLangListId(uint32_t minikinLangListId) {
68         mMinikinLangListId = minikinLangListId;
69     }
70 
getMinikinLangListId()71     uint32_t getMinikinLangListId() const {
72         return mMinikinLangListId;
73     }
74 
setFontVariant(minikin::FontVariant variant)75     void setFontVariant(minikin::FontVariant variant) {
76         mFontVariant = variant;
77     }
78 
getFontVariant()79     minikin::FontVariant getFontVariant() const {
80         return mFontVariant;
81     }
82 
setHyphenEdit(uint32_t hyphen)83     void setHyphenEdit(uint32_t hyphen) {
84         mHyphenEdit = hyphen;
85     }
86 
getHyphenEdit()87     uint32_t getHyphenEdit() const {
88         return mHyphenEdit;
89     }
90 
91 private:
92     float mLetterSpacing = 0;
93     float mWordSpacing = 0;
94     std::string mFontFeatureSettings;
95     uint32_t mMinikinLangListId;
96     minikin::FontVariant mFontVariant;
97     uint32_t mHyphenEdit = 0;
98 };
99 
100 }  // namespace android
101 
102 #endif // ANDROID_GRAPHICS_PAINT_H_
103