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