2 * Copyright (c) 2015 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-color.h>
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/internal/text/color-run.h>
26 #include <dali-toolkit/internal/text/font-description-run.h>
27 #include <dali-toolkit/internal/text/markup-processor-font.h>
28 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
29 #include <dali-toolkit/internal/text/markup-processor-underline.h>
39 const std::string XHTML_FAMILY_ATTRIBUTE("font-family");
40 const std::string XHTML_SIZE_ATTRIBUTE("font-size");
41 const std::string XHTML_WEIGHT_ATTRIBUTE("font-weight");
42 const std::string XHTML_WIDTH_ATTRIBUTE("font-width");
43 const std::string XHTML_SLANT_ATTRIBUTE("font-slant");
45 const std::string XHTML_COLOR_ATTRIBUTE("text-color");
47 //the underlined character's attributes
48 const std::string XHTML_UNDERLINE_COLOR_ATTRIBUTE("u-color");
49 const std::string XHTML_UNDERLINE_HEIGHT_ATTRIBUTE("u-height");
50 const std::string XHTML_UNDERLINE_TYPE_ATTRIBUTE("u-type");
51 const std::string XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE("u-dash-gap");
52 const std::string XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE("u-dash-width");
55 void ProcessSpanTag(const Tag& tag,
57 FontDescriptionRun& fontRun,
58 UnderlinedCharacterRun& underlinedCharacterRun,
61 bool& isUnderlinedCharacterDefined)
63 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
64 endIt = tag.attributes.End();
68 const Attribute& attribute(*it);
70 if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
72 isColorDefined = true;
73 ProcessColor(attribute, colorRun);
75 else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
78 ProcessFontFamily(attribute, fontRun);
80 else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
83 ProcessFontSize(attribute, fontRun);
85 else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
88 ProcessFontWeight(attribute, fontRun);
90 else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
93 ProcessFontWidth(attribute, fontRun);
95 else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
98 ProcessFontSlant(attribute, fontRun);
100 else if(TokenComparison(XHTML_UNDERLINE_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
102 isUnderlinedCharacterDefined = true;
103 ProcessColorAttribute(attribute, underlinedCharacterRun);
105 else if(TokenComparison(XHTML_UNDERLINE_HEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
107 isUnderlinedCharacterDefined = true;
108 ProcessHeightAttribute(attribute, underlinedCharacterRun);
110 else if(TokenComparison(XHTML_UNDERLINE_TYPE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
112 isUnderlinedCharacterDefined = true;
113 ProcessTypeAttribute(attribute, underlinedCharacterRun);
115 else if(TokenComparison(XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
117 isUnderlinedCharacterDefined = true;
118 ProcessDashGapAttribute(attribute, underlinedCharacterRun);
120 else if(TokenComparison(XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
122 isUnderlinedCharacterDefined = true;
123 ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
130 } // namespace Toolkit