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_text_blob_builder.h" 17 18 namespace OHOS { 19 namespace Rosen { 20 namespace TextEngine { GetTextBlobBuilder() const21std::shared_ptr<SkTextBlobBuilder> TexgineTextBlobBuilder::GetTextBlobBuilder() const 22 { 23 return textBlobBuilder_; 24 } 25 AllocRunPos(const TexgineFont & font,int count)26std::shared_ptr<TexgineTextBlobBuilder::RunBuffer> TexgineTextBlobBuilder::AllocRunPos( 27 const TexgineFont &font, int count) 28 { 29 if (textBlobBuilder_ == nullptr || font.GetFont() == nullptr) { 30 return nullptr; 31 } 32 33 const auto &runBuffer = textBlobBuilder_->allocRunPos(*font.GetFont(), count); 34 buffer_->glyphs = runBuffer.glyphs; 35 buffer_->pos = runBuffer.pos; 36 buffer_->utf8Text = runBuffer.utf8text; 37 buffer_->clusters = runBuffer.clusters; 38 return buffer_; 39 } 40 Make()41std::shared_ptr<TexgineTextBlob> TexgineTextBlobBuilder::Make() 42 { 43 if (textBlobBuilder_ == nullptr) { 44 return nullptr; 45 } 46 auto tb = std::make_shared<TexgineTextBlob>(); 47 auto blob = textBlobBuilder_->make(); 48 if (blob == nullptr) { 49 return nullptr; 50 } 51 tb->SetTextBlob(blob); 52 return tb; 53 } 54 } // namespace TextEngine 55 } // namespace Rosen 56 } // namespace OHOS 57