2 * Copyright (c) 2020 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/devel-api/text-abstraction/text-renderer-layout-helper.h>
25 #include <dali/devel-api/text-abstraction/font-client.h>
29 namespace TextAbstraction
31 void TransformToArc(const CircularTextParameters& parameters, double& x, double& y)
35 // Does the italic synthesization for circular layout.
36 if(parameters.synthesizeItalic)
38 const double xP = -yP * sin(TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE);
39 yP *= cos(TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE);
45 double radius = parameters.radius;
47 // Transform to a circular layout.
48 if(parameters.isClockwise)
50 angle = parameters.beginAngle - parameters.invRadius * x;
53 x = radius * cos(angle);
54 y = -radius * sin(angle);
58 angle = parameters.beginAngle + parameters.invRadius * x;
61 x = radius * cos(angle);
62 y = radius * sin(-angle);
65 // Transforms to the text area coordinate system.
66 x += parameters.centerX;
67 y += parameters.centerY;
70 } // namespace TextAbstraction