1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FONT_METRICS_H
17 #define FONT_METRICS_H
18 
19 #include "utils/scalar.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 namespace Drawing {
24 struct FontMetrics {
25     bool operator==(const FontMetrics& that)
26     {
27         return fFlags == that.fFlags &&
28                fTop == that.fTop &&
29                fAscent == that.fAscent &&
30                fDescent == that.fDescent &&
31                fBottom == that.fBottom &&
32                fLeading == that.fLeading &&
33                fAvgCharWidth == that.fAvgCharWidth &&
34                fMaxCharWidth == that.fMaxCharWidth &&
35                fXMin == that.fXMin &&
36                fXMax == that.fXMax &&
37                fXHeight == that.fXHeight &&
38                fCapHeight == that.fCapHeight &&
39                fUnderlineThickness == that.fUnderlineThickness &&
40                fUnderlinePosition == that.fUnderlinePosition &&
41                fStrikeoutThickness == that.fStrikeoutThickness &&
42                fStrikeoutPosition == that.fStrikeoutPosition;
43     }
44 
45     enum FontMetricsFlags {
46         UNDERLINE_THICKNESS_IS_VALID_FLAG = 1 << 0,
47         UNDERLINE_POSITION_IS_VALID_FLAG  = 1 << 1,
48         STRIKEOUT_THICKNESS_IS_VALID_FLAG = 1 << 2,
49         STRIKEOUT_POSITION_IS_VALID_FLAG  = 1 << 3,
50         BOUNDS_INVALID_FLAG               = 1 << 4,
51     };
52 
53     uint32_t fFlags;
54     scalar fTop;
55     scalar fAscent;
56     scalar fDescent;
57     scalar fBottom;
58     scalar fLeading;
59     scalar fAvgCharWidth;
60     scalar fMaxCharWidth;
61     scalar fXMin;
62     scalar fXMax;
63     scalar fXHeight;
64     scalar fCapHeight;
65     scalar fUnderlineThickness;
66     scalar fUnderlinePosition;
67     scalar fStrikeoutThickness;
68     scalar fStrikeoutPosition;
69 };
70 } // namespace Drawing
71 } // namespace Rosen
72 } // namespace OHOS
73 #endif