• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.. All rights reserved.
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 "rosen_text/ui/typography.h"
17 #include "rosen_text/properties/typography_create_base.h"
18 #include "rosen_text/properties/typography_txt.h"
19 
20 namespace rosen {
Typography()21 Typography::Typography()
22 {
23     typography_ = std::make_unique<TypographyTxt>();
24 }
25 
Init(std::shared_ptr<TypographyCreateBase> TypographyCreateBase_)26 void Typography::Init(std::shared_ptr<TypographyCreateBase> TypographyCreateBase_)
27 {
28     typography_->Init(TypographyCreateBase_);
29 }
30 
GetMaxWidth()31 double Typography::GetMaxWidth()
32 {
33     return typography_->GetMaxWidth();
34 }
35 
GetHeight()36 double Typography::GetHeight()
37 {
38     return typography_->GetHeight();
39 }
40 
GetLongestLine()41 double Typography::GetLongestLine()
42 {
43     return typography_->GetLongestLine();
44 }
45 
GetMinIntrinsicWidth()46 double Typography::GetMinIntrinsicWidth()
47 {
48     return typography_->GetMinIntrinsicWidth();
49 }
50 
GetMaxIntrinsicWidth()51 double Typography::GetMaxIntrinsicWidth()
52 {
53     return typography_->GetMaxIntrinsicWidth();
54 }
55 
GetAlphabeticBaseline()56 double Typography::GetAlphabeticBaseline()
57 {
58     return typography_->GetAlphabeticBaseline();
59 }
60 
GetIdeographicBaseline()61 double Typography::GetIdeographicBaseline()
62 {
63     return typography_->GetIdeographicBaseline();
64 }
65 
DidExceedMaxLines()66 bool Typography::DidExceedMaxLines()
67 {
68     return typography_->DidExceedMaxLines();
69 }
70 
Layout(double width)71 void Typography::Layout(double width)
72 {
73     typography_->Layout(width);
74 }
75 
Paint(Canvas * canvas,double x,double y)76 void Typography::Paint(Canvas* canvas, double x, double y)
77 {
78     typography_->Paint(canvas, x, y);
79 }
80 
GetRectsForRange(size_t start,size_t end,TypographyProperties::RectHeightStyle heightStyle,TypographyProperties::RectWidthStyle widthStyle)81 std::vector<TypographyProperties::TextBox> Typography::GetRectsForRange(
82     size_t start,
83     size_t end,
84     TypographyProperties::RectHeightStyle heightStyle,
85     TypographyProperties::RectWidthStyle widthStyle)
86 {
87     return typography_->GetRectsForRange(start, end, heightStyle, widthStyle);
88 }
89 
GetRectsForPlaceholders()90 std::vector<TypographyProperties::TextBox> Typography::GetRectsForPlaceholders()
91 {
92     return  typography_->GetRectsForPlaceholders();
93 }
94 
GetGlyphPositionAtCoordinate(double dx,double dy)95 TypographyProperties::PositionAndAffinity Typography::GetGlyphPositionAtCoordinate(double dx, double dy)
96 {
97     return typography_->GetGlyphPositionAtCoordinate(dx, dy);
98 }
99 
GetGlyphPositionAtCoordinateWithCluster(double dx,double dy)100 TypographyProperties::PositionAndAffinity Typography::GetGlyphPositionAtCoordinateWithCluster(double dx, double dy)
101 {
102     return typography_->GetGlyphPositionAtCoordinateWithCluster(dx, dy);
103 }
104 
GetWordBoundary(size_t offset)105 TypographyProperties::Range<size_t> Typography::GetWordBoundary(size_t offset)
106 {
107     return typography_->GetWordBoundary(offset);
108 }
109 } // namespace rosen
110