• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "texgine_font_metrics.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace TextEngine {
TexgineFontMetrics()21 TexgineFontMetrics::TexgineFontMetrics()
22 {
23     fFlags_ = &fontMetrics_->fFlags;
24     fTop_ = &fontMetrics_->fTop;
25     fAscent_ = &fontMetrics_->fAscent;
26     fDescent_ = &fontMetrics_->fDescent;
27     fBottom_ = &fontMetrics_->fBottom;
28     fLeading_ = &fontMetrics_->fLeading;
29     fAvgCharWidth_ = &fontMetrics_->fAvgCharWidth;
30     fMaxCharWidth_ = &fontMetrics_->fMaxCharWidth;
31     fXMin_ = &fontMetrics_->fXMin;
32     fXMax_ = &fontMetrics_->fXMax;
33     fXHeight_ = &fontMetrics_->fXHeight;
34     fCapHeight_ = &fontMetrics_->fCapHeight;
35     fUnderlineThickness_ = &fontMetrics_->fUnderlineThickness;
36     fUnderlinePosition_ = &fontMetrics_->fUnderlinePosition;
37     fStrikeoutThickness_ = &fontMetrics_->fStrikeoutThickness;
38     fStrikeoutPosition_ = &fontMetrics_->fStrikeoutPosition;
39 }
40 
GetFontMetrics() const41 std::shared_ptr<SkFontMetrics> TexgineFontMetrics::GetFontMetrics() const
42 {
43     return fontMetrics_;
44 }
45 
SetFontMetrics(const std::shared_ptr<SkFontMetrics> metrics)46 void TexgineFontMetrics::SetFontMetrics(const std::shared_ptr<SkFontMetrics> metrics)
47 {
48     if (metrics == nullptr) {
49         return;
50     }
51 
52     fontMetrics_ = metrics;
53     fFlags_ = &fontMetrics_->fFlags;
54     fTop_ = &fontMetrics_->fTop;
55     fAscent_ = &fontMetrics_->fAscent;
56     fDescent_ = &fontMetrics_->fDescent;
57     fBottom_ = &fontMetrics_->fBottom;
58     fLeading_ = &fontMetrics_->fLeading;
59     fAvgCharWidth_ = &fontMetrics_->fAvgCharWidth;
60     fMaxCharWidth_ = &fontMetrics_->fMaxCharWidth;
61     fXMin_ = &fontMetrics_->fXMin;
62     fXMax_ = &fontMetrics_->fXMax;
63     fXHeight_ = &fontMetrics_->fXHeight;
64     fCapHeight_ = &fontMetrics_->fCapHeight;
65     fUnderlineThickness_ = &fontMetrics_->fUnderlineThickness;
66     fUnderlinePosition_ = &fontMetrics_->fUnderlinePosition;
67     fStrikeoutThickness_ = &fontMetrics_->fStrikeoutThickness;
68     fStrikeoutPosition_ = &fontMetrics_->fStrikeoutPosition;
69 }
70 } // namespace TextEngine
71 } // namespace Rosen
72 } // namespace OHOS
73