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>
38 const std::string XHTML_FAMILY_ATTRIBUTE("font-family");
39 const std::string XHTML_SIZE_ATTRIBUTE("font-size");
40 const std::string XHTML_WEIGHT_ATTRIBUTE("font-weight");
41 const std::string XHTML_WIDTH_ATTRIBUTE("font-width");
42 const std::string XHTML_SLANT_ATTRIBUTE("font-slant");
44 const std::string XHTML_COLOR_ATTRIBUTE("text-color");
47 void ProcessSpanTag(const Tag& tag, ColorRun& colorRun, FontDescriptionRun& fontRun, bool& isColorDefined, bool& isFontDefined)
49 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
50 endIt = tag.attributes.End();
54 const Attribute& attribute(*it);
56 if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
58 isColorDefined = true;
59 ProcessColor(attribute, colorRun);
61 else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
64 ProcessFontFamily(attribute, fontRun);
66 else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
69 ProcessFontSize(attribute, fontRun);
71 else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
74 ProcessFontWeight(attribute, fontRun);
76 else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
79 ProcessFontWidth(attribute, fontRun);
81 else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
84 ProcessFontSlant(attribute, fontRun);
91 } // namespace Toolkit