2 * Copyright (c) 2022 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/markup-processor/markup-processor-paragraph.h>
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/internal/text/bounded-paragraph-run.h>
26 #include <dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.h>
27 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
35 void ProcessHorizontalAlignment(const Attribute& attribute, BoundedParagraphRun& boundedParagraphRun)
37 boundedParagraphRun.horizontalAlignmentDefined = HorizontalAlignmentTypeStringToTypeValue(attribute.valueBuffer,
38 attribute.valueLength,
39 boundedParagraphRun.horizontalAlignment);
42 void ProcessRelativeLineHeight(const Attribute& attribute, BoundedParagraphRun& boundedParagraphRun)
44 boundedParagraphRun.relativeLineSize = StringToFloat(attribute.valueBuffer);
45 boundedParagraphRun.relativeLineSizeDefined = true;
48 void ProcessAttributesOfParagraphTag(const Tag& tag, BoundedParagraphRun& boundedParagraphRun)
50 // By default the align attribute is not defined until it's parsed.
51 boundedParagraphRun.horizontalAlignmentDefined = false;
53 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
54 endIt = tag.attributes.End();
58 const Attribute& attribute(*it);
59 if(TokenComparison(MARKUP::PARAGRAPH_ATTRIBUTES::ALIGN, attribute.nameBuffer, attribute.nameLength))
61 ProcessHorizontalAlignment(attribute, boundedParagraphRun);
63 else if(TokenComparison(MARKUP::PARAGRAPH_ATTRIBUTES::RELATIVE_LINE_HEIGHT, attribute.nameBuffer, attribute.nameLength))
65 ProcessRelativeLineHeight(attribute, boundedParagraphRun);
71 } // namespace Toolkit