2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/line-helper-functions.h>
27 float GetPreOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
29 // Calculate vertical line alignment
34 case DevelText::VerticalLineAlignment::TOP:
38 case DevelText::VerticalLineAlignment::MIDDLE:
40 offset = line.lineSpacing * 0.5f;
43 case DevelText::VerticalLineAlignment::BOTTOM:
45 offset = line.lineSpacing;
50 // Apply TOP case when the lineSpacing is less than zero.
51 offset = line.lineSpacing < 0.0f ? 0.0f : offset;
56 float GetPostOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
58 // Calculate vertical line alignment
63 case DevelText::VerticalLineAlignment::TOP:
65 offset = line.lineSpacing;
68 case DevelText::VerticalLineAlignment::MIDDLE:
70 offset = line.lineSpacing * 0.5f;
73 case DevelText::VerticalLineAlignment::BOTTOM:
79 // Apply TOP case when the lineSpacing is less than zero.
80 offset = line.lineSpacing < 0.0f ? line.lineSpacing : offset;
86 } // namespace Toolkit