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()21TexgineFontMetrics::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 } GetFontMetrics() const40std::shared_ptr<RSFontMetrics> TexgineFontMetrics::GetFontMetrics() const 41 { 42 return fontMetrics_; 43 } 44 SetFontMetrics(const std::shared_ptr<RSFontMetrics> metrics)45void TexgineFontMetrics::SetFontMetrics(const std::shared_ptr<RSFontMetrics> metrics) 46 { 47 if (metrics == nullptr) { 48 return; 49 } 50 51 fontMetrics_ = metrics; 52 fFlags_ = &fontMetrics_->fFlags; 53 fTop_ = &fontMetrics_->fTop; 54 fAscent_ = &fontMetrics_->fAscent; 55 fDescent_ = &fontMetrics_->fDescent; 56 fBottom_ = &fontMetrics_->fBottom; 57 fLeading_ = &fontMetrics_->fLeading; 58 fAvgCharWidth_ = &fontMetrics_->fAvgCharWidth; 59 fMaxCharWidth_ = &fontMetrics_->fMaxCharWidth; 60 fXMin_ = &fontMetrics_->fXMin; 61 fXMax_ = &fontMetrics_->fXMax; 62 fXHeight_ = &fontMetrics_->fXHeight; 63 fCapHeight_ = &fontMetrics_->fCapHeight; 64 fUnderlineThickness_ = &fontMetrics_->fUnderlineThickness; 65 fUnderlinePosition_ = &fontMetrics_->fUnderlinePosition; 66 fStrikeoutThickness_ = &fontMetrics_->fStrikeoutThickness; 67 fStrikeoutPosition_ = &fontMetrics_->fStrikeoutPosition; 68 } 69 } // namespace TextEngine 70 } // namespace Rosen 71 } // namespace OHOS 72