Handled nested tags in strikethrough
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / styles / strikethrough-helper-functions.cpp
index b28f90f..76b8ce3 100644 (file)
@@ -45,27 +45,34 @@ bool IsGlyphStrikethrough(GlyphIndex                                    index,
   return false;
 }
 
   return false;
 }
 
-float GetCurrentStrikethroughHeight(const Vector<StrikethroughGlyphRun>&         strikethroughRuns,
-                                    Vector<StrikethroughGlyphRun>::ConstIterator currentStrikethroughGlyphRunIt,
-                                    const float                                  strikethroughHeight)
+StrikethroughStyleProperties GetCurrentStrikethroughProperties(GlyphIndex                                    index,
+                                                               const bool&                                   isGlyphStrikethrough,
+                                                               const Vector<StrikethroughGlyphRun>&          strikethroughRuns,
+                                                               Vector<StrikethroughGlyphRun>::ConstIterator& currentStrikethroughGlyphRunIt,
+                                                               const StrikethroughStyleProperties&           commonStrikethroughProperties)
 {
 {
-  if(currentStrikethroughGlyphRunIt == strikethroughRuns.End())
+  StrikethroughStyleProperties currentStrikethroughStyleProperties = commonStrikethroughProperties;
+
+  if(isGlyphStrikethrough && (currentStrikethroughGlyphRunIt != strikethroughRuns.End()))
   {
   {
-    return strikethroughHeight;
-  }
+    // Retrieve the latest run to handle the nested case.
+    for(Vector<StrikethroughGlyphRun>::ConstIterator it    = currentStrikethroughGlyphRunIt + 1,
+                                                     endIt = strikethroughRuns.End();
+        it != endIt;
+        ++it)
+    {
+      const StrikethroughGlyphRun& run = *it;
 
 
-  const StrikethroughGlyphRun& strikethroughGlyphRun = *currentStrikethroughGlyphRunIt;
-  return (strikethroughGlyphRun.properties.heightDefined ? strikethroughGlyphRun.properties.height : strikethroughHeight);
-}
+      if((run.glyphRun.glyphIndex <= index) && (index < (run.glyphRun.glyphIndex + run.glyphRun.numberOfGlyphs)))
+      {
+        currentStrikethroughGlyphRunIt = it;
+      }
+    }
 
 
-StrikethroughStyleProperties GetCurrentStrikethroughProperties(const bool&                                  isGlyphStrikethrough,
-                                                               const Vector<StrikethroughGlyphRun>&         strikethroughRuns,
-                                                               Vector<StrikethroughGlyphRun>::ConstIterator currentStrikethroughGlyphRunIt,
-                                                               const StrikethroughStyleProperties&          commonStrikethroughProperties)
-{
-  return (isGlyphStrikethrough && (currentStrikethroughGlyphRunIt != strikethroughRuns.End()))
-           ? currentStrikethroughGlyphRunIt->properties
-           : commonStrikethroughProperties;
+    currentStrikethroughStyleProperties.OverrideByDefinedProperties(currentStrikethroughGlyphRunIt->properties);
+  }
+
+  return currentStrikethroughStyleProperties;
 }
 
 /// Helper method to fetch the strikethrough metrics for the specified font glyph
 }
 
 /// Helper method to fetch the strikethrough metrics for the specified font glyph