1 /*
2 * Copyright (c) 2024 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 "run_impl.h"
17
18 #include "convert.h"
19 #include "impl/run_impl.h"
20
21 namespace OHOS {
22 namespace Rosen {
23 namespace AdapterTxt {
RunImpl(std::unique_ptr<SPText::Run> run)24 RunImpl::RunImpl(std::unique_ptr<SPText::Run> run): run_(std::move(run))
25 {
26 }
27
GetFont() const28 Drawing::Font RunImpl::GetFont() const
29 {
30 if (!run_) {
31 return {};
32 }
33 return run_->GetFont();
34 }
35
GetGlyphCount() const36 size_t RunImpl::GetGlyphCount() const
37 {
38 if (!run_) {
39 return 0;
40 }
41 return run_->GetGlyphCount();
42 }
43
GetGlyphs() const44 std::vector<uint16_t> RunImpl::GetGlyphs() const
45 {
46 if (!run_) {
47 return {};
48 }
49 return run_->GetGlyphs();
50 }
51
GetPositions()52 std::vector<Drawing::Point> RunImpl::GetPositions()
53 {
54 if (!run_) {
55 return {};
56 }
57 return run_->GetPositions();
58 }
59
GetOffsets()60 std::vector<Drawing::Point> RunImpl::GetOffsets()
61 {
62 if (!run_) {
63 return {};
64 }
65 return run_->GetOffsets();
66 }
67
Paint(Drawing::Canvas * canvas,double x,double y)68 void RunImpl::Paint(Drawing::Canvas *canvas, double x, double y)
69 {
70 if (!run_) {
71 return;
72 }
73 return run_->Paint(canvas, x, y);
74 }
75 } // namespace AdapterTxt
76 } // namespace Rosen
77 } // namespace OHOS
78