Merge "Add the protected code and fix the crash issue" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
89 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
build/tizen/docs/dali.doxy.in
dali-toolkit/devel-api/controls/control-devel.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h [new file with mode: 0644]
dali-toolkit/devel-api/controls/text-controls/text-label-devel.h
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/image-loader/texture-manager.h
dali-toolkit/devel-api/text/text-enumerations-devel.h
dali-toolkit/devel-api/visual-factory/visual-base.cpp
dali-toolkit/devel-api/visual-factory/visual-base.h
dali-toolkit/devel-api/visuals/color-visual-properties-devel.h [new file with mode: 0644]
dali-toolkit/devel-api/visuals/image-visual-properties-devel.h
dali-toolkit/devel-api/visuals/text-visual-properties-devel.h [new file with mode: 0644]
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/decorator/text-decorator.h
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/line-run.h
dali-toolkit/internal/text/markup-processor-helper-functions.cpp
dali-toolkit/internal/text/markup-processor-helper-functions.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/rendering/text-typesetter.cpp
dali-toolkit/internal/text/rendering/view-model.cpp
dali-toolkit/internal/text/rendering/view-model.h
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-effects-style.cpp
dali-toolkit/internal/text/text-effects-style.h
dali-toolkit/internal/text/text-model-interface.h
dali-toolkit/internal/text/text-model.cpp
dali-toolkit/internal/text/text-model.h
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/text/text-scroller.h
dali-toolkit/internal/text/text-view-interface.h
dali-toolkit/internal/text/text-view.cpp
dali-toolkit/internal/text/text-view.h
dali-toolkit/internal/text/visual-model-impl.cpp
dali-toolkit/internal/text/visual-model-impl.h
dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/npatch-loader.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.h
dali-toolkit/internal/visuals/visual-base-impl.h
dali-toolkit/internal/visuals/visual-string-constants.cpp
dali-toolkit/internal/visuals/visual-string-constants.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control.cpp
dali-toolkit/public-api/controls/control.h
dali-toolkit/public-api/controls/image-view/image-view.h
dali-toolkit/public-api/controls/text-controls/text-editor.h
dali-toolkit/public-api/controls/text-controls/text-field.h
dali-toolkit/public-api/controls/text-controls/text-label.h
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/public-api/visuals/image-visual-properties.h
dali-toolkit/public-api/visuals/visual-properties.h
dali-toolkit/third-party/nanosvg/nanosvg.cc
dali-toolkit/third-party/nanosvg/nanosvg.h
dali-toolkit/third-party/nanosvg/nanosvgrast.cc
dali-toolkit/third-party/nanosvg/nanosvgrast.h
packaging/dali-toolkit.spec

index 8d73622..6c63ce1 100644 (file)
@@ -184,9 +184,16 @@ int UtcDaliTextControllerImfEvent(void)
   // Enables the text input.
   controller->EnableTextInput( decorator );
 
+  // Set the placeholder text.
+  controller->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, "Hello Dali" );
+
   // Creates an ImfManager.
   ImfManager imfManager = ImfManager::Get();
 
+  // For coverage.
+  imfEvent = ImfManager::ImfEventData( ImfManager::GETSURROUNDING, "", 0, 0 );
+  controller->OnImfEvent( imfManager, imfEvent );
+
   // Send VOID event.
   imfEvent = ImfManager::ImfEventData( ImfManager::VOID, "", 0, 0 );
   controller->OnImfEvent( imfManager, imfEvent );
@@ -528,3 +535,125 @@ int UtcDaliTextControllerSetGetTapLongPressAction(void)
 
   END_TEST;
 }
+
+int UtcDaliTextControllerSetGetLineSpacingProperty(void)
+{
+  tet_infoline(" UtcDaliTextControllerSetGetLineSpacingProperty");
+  ToolkitTestApplication application;
+
+  const Size size( Dali::Stage::GetCurrent().GetSize() );
+
+  // single line text
+  const std::string textSingle("A Quick Brown Fox Jumps Over The Lazy Dog");
+
+  // multi-line text
+  const std::string textMulti("A Quick Brown\nFox Jumps Over\nThe Lazy Dog");
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  ConfigureTextLabel(controller);
+
+  // single line, line spacing = 0px
+  {
+    const float EXPECTED_SPACING = 0.0f;
+    const Vector2 EXPECTED_LAYOUT_SIZE( 326.0f, 19.0f);
+    const Vector3 EXPECTED_NATURAL_SIZE( 326.0f, 20.0f, 0.0f );
+
+    controller->SetText(textSingle);
+    controller->Relayout(size);
+    controller->SetMultiLineEnabled( false );
+
+    Vector3 naturalSize  = controller->GetNaturalSize();
+    Vector2 layoutSize   = controller->GetTextModel()->GetLayoutSize();
+    float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+    DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+  }
+
+  // single line, line spacing = 20px
+  {
+    const float EXPECTED_SPACING = 20.0f;
+    const Vector2 EXPECTED_LAYOUT_SIZE( 326.0f, 19.0f );
+    const Vector3 EXPECTED_NATURAL_SIZE( 326.0f, 40.0f, 0.0f );
+
+    controller->SetText(textSingle);
+    controller->Relayout(size);
+    controller->SetDefaultLineSpacing( 20 );
+    controller->SetMultiLineEnabled( false );
+
+    Vector3 naturalSize  = controller->GetNaturalSize();
+    Vector2 layoutSize   = controller->GetTextModel()->GetLayoutSize();
+    float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+    DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+  }
+
+  // multi-line, line spacing = 0px
+  {
+    const float EXPECTED_SPACING = 0.0f;
+    const Vector2 EXPECTED_LAYOUT_SIZE( 318.0f, 39.0f );
+    const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 58.0f, 0.0f );
+
+    controller->SetText(textMulti);
+    controller->Relayout(size);
+    controller->SetMultiLineEnabled( true );
+    controller->SetDefaultLineSpacing( 0 );
+
+    Vector3 naturalSize  = controller->GetNaturalSize();
+    Vector2 layoutSize   = controller->GetTextModel()->GetLayoutSize();
+    float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+    DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+  }
+
+  // multi-line, line spacing = 20px
+  {
+    const float EXPECTED_SPACING = 20.0f;
+    const Vector2 EXPECTED_LAYOUT_SIZE( 115.0f, 57.0f );
+    const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 118.0f, 0.0f );
+
+    controller->SetText(textMulti);
+    controller->Relayout(size);
+    controller->SetMultiLineEnabled( true );
+    controller->SetDefaultLineSpacing( 20 );
+
+    Vector3 naturalSize  = controller->GetNaturalSize();
+    Vector2 layoutSize   = controller->GetTextModel()->GetLayoutSize();
+    float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+    DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+  }
+
+  // multi-line, line spacing = 30px
+  {
+    const float EXPECTED_SPACING = 30.0f;
+    const Vector2 EXPECTED_LAYOUT_SIZE( 115.0f, 117.0f );
+    const Vector3 EXPECTED_NATURAL_SIZE( 116.0f, 148.0f, 0.0f );
+
+    controller->SetText(textMulti);
+    controller->Relayout(size);
+    controller->SetMultiLineEnabled( true );
+    controller->SetDefaultLineSpacing( 30 );
+
+    Vector3 naturalSize  = controller->GetNaturalSize();
+    Vector2 layoutSize   = controller->GetTextModel()->GetLayoutSize();
+    float lineSpacing0 = controller->GetDefaultLineSpacing();
+
+    DALI_TEST_EQUALS( EXPECTED_SPACING, lineSpacing0, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_LAYOUT_SIZE, layoutSize, TEST_LOCATION );
+    DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, naturalSize, TEST_LOCATION );
+  }
+
+
+  END_TEST;
+
+}
\ No newline at end of file
index b521976..48c4476 100644 (file)
@@ -716,6 +716,7 @@ int UtcDaliTextLayoutSmallTextArea02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -806,6 +807,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -818,6 +820,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -830,6 +833,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     -4.f,
     5.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -842,6 +846,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     -4.f,
     5.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -854,6 +859,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     -4.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1001,6 +1007,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1013,6 +1020,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1025,6 +1033,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1037,6 +1046,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1049,6 +1059,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1061,6 +1072,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1142,6 +1154,7 @@ int UtcDaliTextLayoutMultilineText03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1154,6 +1167,7 @@ int UtcDaliTextLayoutMultilineText03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1166,6 +1180,7 @@ int UtcDaliTextLayoutMultilineText03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1253,6 +1268,7 @@ int UtcDaliTextLayoutMultilineText04(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1355,6 +1371,7 @@ int UtcDaliTextLayoutMultilineText05(void)
     -8.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1367,6 +1384,7 @@ int UtcDaliTextLayoutMultilineText05(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1685,6 +1703,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1697,6 +1716,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1709,6 +1729,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1721,6 +1742,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1733,6 +1755,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1745,6 +1768,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1757,6 +1781,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1769,6 +1794,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1781,6 +1807,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1793,6 +1820,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1805,6 +1833,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1817,6 +1846,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1829,6 +1859,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1841,6 +1872,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1853,6 +1885,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1865,6 +1898,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1877,6 +1911,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1889,6 +1924,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -1901,6 +1937,7 @@ int UtcDaliTextUpdateLayout01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2241,6 +2278,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2253,6 +2291,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2265,6 +2304,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2277,6 +2317,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2289,6 +2330,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2301,6 +2343,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2313,6 +2356,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2325,6 +2369,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2337,6 +2382,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2349,6 +2395,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2361,6 +2408,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2373,6 +2421,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2385,6 +2434,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2397,6 +2447,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2409,6 +2460,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2421,6 +2473,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2433,6 +2486,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2445,6 +2499,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2457,6 +2512,7 @@ int UtcDaliTextUpdateLayout02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2797,6 +2853,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2809,6 +2866,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2821,6 +2879,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2833,6 +2892,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2845,6 +2905,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2857,6 +2918,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2869,6 +2931,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2881,6 +2944,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2893,6 +2957,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2905,6 +2970,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2917,6 +2983,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2929,6 +2996,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2941,6 +3009,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2953,6 +3022,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2965,6 +3035,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2977,6 +3048,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -2989,6 +3061,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -3001,6 +3074,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -3013,6 +3087,7 @@ int UtcDaliTextUpdateLayout03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -3104,6 +3179,7 @@ int UtcDaliTextLayoutEllipsis01(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     true
   };
@@ -3180,6 +3256,7 @@ int UtcDaliTextLayoutEllipsis02(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -3192,6 +3269,7 @@ int UtcDaliTextLayoutEllipsis02(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     true
   };
@@ -3336,6 +3414,7 @@ int UtcDaliTextLayoutEllipsis03(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     true
   };
@@ -3478,6 +3557,7 @@ int UtcDaliTextLayoutEllipsis04(void)
     -5.f,
     3.f,
     0.f,
+    0.f,
     false,
     false
   };
@@ -3490,6 +3570,7 @@ int UtcDaliTextLayoutEllipsis04(void)
     -5.f,
     4.f,
     0.f,
+    0.f,
     false,
     true
   };
@@ -3566,6 +3647,7 @@ int UtcDaliTextLayoutEllipsis05(void)
     -5.f,
     0.f,
     0.f,
+    0.f,
     false,
     true
   };
index 50ca75d..14f352c 100644 (file)
@@ -141,3 +141,57 @@ int UtcDaliTextRenderingControllerRender(void)
   tet_result(TET_PASS);
   END_TEST;
 }
+
+int UtcDaliTextTypesetterVerticalLineAlignment(void)
+{
+  tet_infoline(" UtcDaliTextTypesetter");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Sets the text.
+  controller->SetMarkupProcessorEnabled( true );
+  controller->SetText( "<font family='TizenSansRegular'>Hello world</font>" );
+
+  // Creates the text's model and relais-out the text.
+  const Size relayoutSize( 120.f, 60.f );
+  controller->Relayout( relayoutSize );
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( renderingController );
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::TOP);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  {
+    controller->SetVerticalLineAlignment(Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM);
+    controller->Relayout(relayoutSize);
+
+    // Renders the text and creates the final bitmap.
+    auto bitmap = renderingController->Render(relayoutSize);
+    DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  }
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
\ No newline at end of file
index d695e92..df48a7d 100755 (executable)
@@ -75,6 +75,18 @@ static void TestKeyInputFocusCallback( Control control )
 const char* TEST_LARGE_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/tbcol.png";
 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/gallery-small-1.jpg";
 
+Vector4 GetControlBackgroundColor( Control& control )
+{
+  Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
+  Property::Map* resultMap = propValue.GetMap();
+  DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+
+  Vector4 color;
+  resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get( color );
+
+  return color;
+}
+
 } // namespace
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -458,6 +470,80 @@ int UtcDaliControlBackgroundColor(void)
   END_TEST;
 }
 
+int UtcDaliControlBackgroundColorRendererCount(void)
+{
+  tet_infoline( "Test ensures we only create renderers when non-transparent color is requested or if we our clipping-mode is set to CLIP_CHILDREN" );
+
+  ToolkitTestApplication application;
+  Control control = Control::New();
+  Stage::GetCurrent().Add( control );
+
+  tet_infoline( "Set transparent, no renderers should be created" );
+  control.SetBackgroundColor( Color::TRANSPARENT );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+
+  tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" );
+  const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f );
+  control.SetBackgroundColor( alphaZero );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION );
+
+  tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" );
+  const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f );
+  control.SetBackgroundColor( semiTransparent );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
+
+  tet_infoline( "Set transparent, ensure no renderers are created" );
+  control.SetBackgroundColor( Color::TRANSPARENT );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+
+  tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" );
+  control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+
+  tet_infoline( "Set a color, only 1 renderer should exist" );
+  control.SetBackgroundColor( Color::RED );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::RED, TEST_LOCATION );
+
+  tet_infoline( "Clear the background, no renderers" );
+  control.ClearBackground();
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+
+  tet_infoline( "Set control to clip its children again, a renderer should be created which will be transparent" );
+  control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+
+  tet_infoline( "Disable clipping, no renderers" );
+  control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliControlBackgroundImage(void)
 {
   ToolkitTestApplication application;
@@ -834,11 +920,12 @@ int UtcDaliControlResourcesReady(void)
 
   DummyControl actor = DummyControl::New();
   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, smallVisual );
 
   actor.SetSize( 200.f, 200.f );
 
-  Toolkit::Visual::ResourceStatus resourceStatus = DevelControl::GetVisualResourceStatus(dummyImpl, DummyControl::Property::TEST_VISUAL);
+  Toolkit::Visual::ResourceStatus resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
   DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
@@ -852,7 +939,7 @@ int UtcDaliControlResourcesReady(void)
   application.SendNotification();
   application.Render();
 
-  resourceStatus = DevelControl::GetVisualResourceStatus(dummyImpl, DummyControl::Property::TEST_VISUAL);
+  resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
   DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
@@ -865,12 +952,12 @@ int UtcDaliControlResourcesReady(void)
 
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, largeVisual, false );
 
-  resourceStatus = DevelControl::GetVisualResourceStatus(dummyImpl, DummyControl::Property::TEST_VISUAL2);
+  resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
 
   application.SendNotification();
 
-  resourceStatus = DevelControl::GetVisualResourceStatus(dummyImpl, DummyControl::Property::TEST_VISUAL2);
+  resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
   DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
@@ -881,7 +968,7 @@ int UtcDaliControlResourcesReady(void)
 
   application.SendNotification();
 
-  resourceStatus = DevelControl::GetVisualResourceStatus(dummyImpl, DummyControl::Property::TEST_VISUAL2);
+  resourceStatus = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL2);
   DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::READY), TEST_LOCATION );
 
   END_TEST;
index 97a4b1d..4ff9b13 100644 (file)
@@ -1526,7 +1526,7 @@ int UtcDaliImageViewResourceReadySignalWithImmediateLoad(void)
   Property::Map imageMap;
 
   imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
-  imageMap[ DevelImageVisual::Property::LOAD_POLICY ] =  DevelImageVisual::LoadPolicy::IMMEDIATE;
+  imageMap[ ImageVisual::Property::LOAD_POLICY ] =  ImageVisual::LoadPolicy::IMMEDIATE;
 
   tet_infoline("Creating ImageView without URL so image does not start loading");
   ImageView imageView = ImageView::New();
@@ -1557,7 +1557,7 @@ int UtcDaliImageViewResourceReadySignalWithReusedImage(void)
   Property::Map imageMap;
 
   imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
-  imageMap[ DevelImageVisual::Property::LOAD_POLICY ] =  DevelImageVisual::LoadPolicy::IMMEDIATE;
+  imageMap[ ImageVisual::Property::LOAD_POLICY ] =  ImageVisual::LoadPolicy::IMMEDIATE;
 
   ImageView imageView = ImageView::New();
   imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
@@ -1591,7 +1591,7 @@ int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
 
   Property::Map imageImmediateLoadingMap;
   imageImmediateLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
-  imageImmediateLoadingMap[ DevelImageVisual::Property::LOAD_POLICY ] =  DevelImageVisual::LoadPolicy::IMMEDIATE;
+  imageImmediateLoadingMap[ ImageVisual::Property::LOAD_POLICY ] =  ImageVisual::LoadPolicy::IMMEDIATE;
 
   tet_infoline("Immediate load an image");
   ImageView imageView = ImageView::New();
index 679721c..a2adf41 100644 (file)
@@ -247,7 +247,7 @@ int UtcDaliImageVisualTextureReuse1(void)
   Property::Map propertyMap;
   propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::IMAGE );
   propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
-  propertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY,  DevelImageVisual::ReleasePolicy::DETACHED );
+  propertyMap.Insert( ImageVisual::Property::RELEASE_POLICY,  ImageVisual::ReleasePolicy::DETACHED );
 
   TestGlAbstraction& gl = application.GetGlAbstraction();
   TraceCallStack& textureTrace = gl.GetTextureTrace();
@@ -1213,7 +1213,7 @@ int UtcDaliImageVisualReleasePolicy01(void)
   ToolkitTestApplication application;
   tet_infoline( "UtcDaliImageVisualReleasePolicy01 Detached Policy, disabling visual with this policy deletes texture" );
 
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DETACHED );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED );
   DALI_TEST_CHECK( imageVisual );
 
   // Set up debug trace
@@ -1263,7 +1263,7 @@ int UtcDaliImageVisualReleasePolicy02(void)
   ToolkitTestApplication application;
   tet_infoline( "UtcDaliImageVisualReleasePolicy02 Destroyed Policy, Texture should be deleted when visual destroyed" );
 
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DESTROYED );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
   DALI_TEST_CHECK( imageVisual );
 
   // Setup debug trace
@@ -1315,7 +1315,7 @@ int UtcDaliImageVisualReleasePolicy03(void)
   ToolkitTestApplication application;
   tet_infoline( "UtcDaliImageVisualReleasePolicy03 Never Policy, texture should not be deleted after visual destroyed" );
 
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::NEVER );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
   DALI_TEST_CHECK( imageVisual );
 
   TestGlAbstraction& gl = application.GetGlAbstraction();
@@ -1365,10 +1365,10 @@ int UtcDaliImageVisualReleasePolicy04(void)
   tet_infoline( "UtcDaliImageVisualReleasePolicy04 Two visuals with different policies sharing a texture" );
 
   tet_infoline( "Create first visual with Never release policy" );
-  Visual::Base imageVisualNever = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::NEVER );
+  Visual::Base imageVisualNever = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
 
   tet_infoline( "Create second visual with Destroyed release policy");
-    Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DESTROYED );
+    Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
 
   // Set up trace debug
   TestGlAbstraction& gl = application.GetGlAbstraction();
@@ -1444,7 +1444,7 @@ int UtcDaliImageVisualReleasePolicy05(void)
   imageVisualNever.CreatePropertyMap( resultMap );
   DALI_TEST_CHECK( ! resultMap.Empty() );
 
-  DALI_TEST_EQUALS( ( resultMap.Find( DevelImageVisual::Property::RELEASE_POLICY ) )->Get<int>(), (int)DevelImageVisual::ReleasePolicy::NEVER, TEST_LOCATION );
+  DALI_TEST_EQUALS( ( resultMap.Find( ImageVisual::Property::RELEASE_POLICY ) )->Get<int>(), (int)ImageVisual::ReleasePolicy::NEVER, TEST_LOCATION );
 
   END_TEST;
 }
@@ -1454,7 +1454,7 @@ int UtcDaliImageVisualReleasePolicy06(void)
   ToolkitTestApplication application;
   tet_infoline( "UtcDaliImageVisualReleasePolicy06 Never Policy, texture should not be affected by Disabling and Enabling visual" );
 
-  Visual::Base imageVisual= CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::NEVER );
+  Visual::Base imageVisual= CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
   DALI_TEST_CHECK( imageVisual );
 
   TestGlAbstraction& gl = application.GetGlAbstraction();
@@ -1514,11 +1514,11 @@ int UtcDaliImageVisualReleasePolicy07(void)
   tet_infoline( "UtcDaliImageVisualReleasePolicy07 Two visuals with different policies sharing a texture DETACHED and DESTROYED" );
 
   tet_infoline( "Create first visual with DESTROYED release policy" );
-  Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DESTROYED );
+  Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
 
 
   tet_infoline( "Create second visual with DETACHED release policy");
-  Visual::Base imageVisualDetached = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DETACHED );
+  Visual::Base imageVisualDetached = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED );
 
   // Set up trace debug
   TestGlAbstraction& gl = application.GetGlAbstraction();
@@ -1584,7 +1584,21 @@ int UtcDaliImageVisualLoadPolicy01(void)
   textureTrace.Enable(true);
 
   tet_infoline( "Create visual with IMMEDIATE load policy" );
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::IMMEDIATE );
+  VisualFactory factory = VisualFactory::Get();
+
+  Property::Map propertyMap;
+  propertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
+  propertyMap.Insert( ImageVisual::Property::URL,  TEST_IMAGE_FILE_NAME );
+  propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH,   20 );
+  propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT,   30 );
+  propertyMap.Insert( "loadPolicy" , ImageVisual::LoadPolicy::IMMEDIATE );
+
+  Visual::Base imageVisual = factory.CreateVisual( propertyMap );
+
+  Property::Map resultMap;
+  imageVisual.CreatePropertyMap( resultMap );
+  DALI_TEST_CHECK( ! resultMap.Empty() );
+  DALI_TEST_EQUALS( ( resultMap.Find( ImageVisual::Property::LOAD_POLICY ) )->Get<int>(), (int)ImageVisual::LoadPolicy::IMMEDIATE, TEST_LOCATION );
 
   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
@@ -1637,7 +1651,7 @@ int UtcDaliImageVisualLoadPolicy02(void)
   textureTrace.Enable(true);
 
   tet_infoline( "Create visual with IMMEDIATE load policy" );
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::ATTACHED );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
 
   const unsigned int TIME_OUT_3_SECONDS = 3;
   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, TIME_OUT_3_SECONDS ), false, TEST_LOCATION );
@@ -1699,7 +1713,7 @@ int UtcDaliImageVisualLoadPolicy03(void)
   actor.SetSize(200.f, 200.f);
 
   tet_infoline( "Create visual with IMMEDIATE load policy" );
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::IMMEDIATE );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
 
   tet_infoline( "Registering visual allows control to get a signal once loaded even if visual not enabled( not staged )" );
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED );
@@ -1737,7 +1751,7 @@ int UtcDaliImageVisualLoadPolicy04(void)
   actor.SetSize(200.f, 200.f);
 
   tet_infoline( "Create visual with IMMEDIATE load policy" );
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::IMMEDIATE );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
 
   tet_infoline( "Registering visual allows control to get a signal once loaded even if visual not enabled( staged )" );
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED );
@@ -1755,7 +1769,7 @@ int UtcDaliImageVisualLoadPolicy04(void)
   tet_infoline( "Original control correctly signalled, now testing for signal with new Control reusing the image" );
 
   gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
-  Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::IMMEDIATE );
+  Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
   DummyControl actor2 = DummyControl::New(true);
   Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   actor2.ResourceReadySignal().Connect( &ResourceReadySignal);
@@ -1788,7 +1802,7 @@ int UtcDaliImageVisualLoadPolicy05(void)
   Stage::GetCurrent().Add( actor );
 
   tet_infoline( "Create visual with ATTACHED load policy" );
-  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::ATTACHED );
+  Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
 
   tet_infoline( "Registering visual allows control to get a signal once loaded" );
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
@@ -1806,7 +1820,7 @@ int UtcDaliImageVisualLoadPolicy05(void)
   tet_infoline( "Original control correctly signalled, now testing for signal with new Control reusing the image" );
 
   gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
-  Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, DevelImageVisual::Property::LOAD_POLICY, DevelImageVisual::LoadPolicy::ATTACHED );
+  Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
   DummyControl actor2 = DummyControl::New(true);
   Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
   actor2.ResourceReadySignal().Connect( &ResourceReadySignal);
@@ -1832,7 +1846,7 @@ int UtcDaliImageVisualOrientationCorrection(void)
   Property::Map propertyMap;
   propertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
   propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
-  propertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, false );
+  propertyMap.Insert( "orientationCorrection", false );
   Visual::Base imageVisual = factory.CreateVisual( propertyMap );
 
   tet_infoline( "Create control for visual, need to loaded it" );
@@ -1857,7 +1871,7 @@ int UtcDaliImageVisualOrientationCorrection(void)
   propertyMap.Clear();
   propertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
   propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
-  propertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, true );
+  propertyMap.Insert( ImageVisual::Property::ORIENTATION_CORRECTION, true );
   imageVisual = factory.CreateVisual( propertyMap );
 
   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
@@ -1874,7 +1888,7 @@ int UtcDaliImageVisualOrientationCorrection(void)
   imageVisual.CreatePropertyMap( resultMap );
 
   // check the Property::ORIENTATION_CORRECTION value from the returned map
-  Property::Value* typeValue = resultMap.Find( DevelImageVisual::Property::ORIENTATION_CORRECTION,  Property::BOOLEAN );
+  Property::Value* typeValue = resultMap.Find( ImageVisual::Property::ORIENTATION_CORRECTION,  Property::BOOLEAN );
   DALI_TEST_EQUALS( typeValue->Get<bool>(), true, TEST_LOCATION );
 
   END_TEST;
index 487ae20..9fc074f 100644 (file)
@@ -99,6 +99,7 @@ const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placehol
 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
+const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
 
 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
 
@@ -314,9 +315,38 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma
 
       if( NULL != valueSet )
       {
-        if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+        if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
         {
-          tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
+        {
+          tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
+        {
+          Vector2 vector2Get = valueGet.second.Get<Vector2>();
+          Vector2 vector2Set = valueSet->Get<Vector2>();
+          tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
+        {
+          Vector4 vector4Get = valueGet.second.Get<Vector4>();
+          Vector4 vector4Set = valueSet->Get<Vector4>();
+          tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
           return false;
         }
       }
@@ -507,6 +537,7 @@ int UtcDaliTextEditorGetPropertyP(void)
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
+  DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
 
   END_TEST;
 }
@@ -785,8 +816,6 @@ int UtcDaliTextEditorSetPropertyP(void)
 
   editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
 
-  outlineMapSet["color"] = "red";
-  outlineMapSet["width"] = "2";
   outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
@@ -2148,6 +2177,52 @@ int utcDaliTextEditorEvent07(void)
 
   DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
 
+
+  // Disable Shift Selection
+  editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
+
+  // Test to select some text in the right of the current cursor position
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Cut the selected text
+  application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
+  DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+  // Test to select some text in the left of the current cursor position
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Copy the selected text
+  application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
+  DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -2483,3 +2558,31 @@ int UtcDaliTextEditorSetPaddingProperty(void)
 
   END_TEST;
 }
+
+int UtcDaliTextEditorEnableShiftSelectionProperty(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+  editor.SetSize( 300.f, 50.f );
+  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( editor );
+
+  application.SendNotification();
+  application.Render();
+
+  // The default value of ENABLE_SHIFT_SELECTION is 'true'.
+  DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
+
+  // Check the enable shift selection property
+  editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
+  DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
index 0074c78..07f1cac 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/integration-api/events/long-press-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include "toolkit-clipboard.h"
 
 using namespace Dali;
@@ -99,6 +100,7 @@ const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSiz
 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
 const char* const PROPERTY_NAME_ELLIPSIS                             = "ellipsis";
+const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
 
 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
 
@@ -329,39 +331,65 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma
     {
       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
 
-      if( valueGet.first.type == Property::Key::STRING )
+      Property::Value* valueSet = NULL;
+      if ( valueGet.first.type == Property::Key::INDEX )
       {
-        Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
-        if( NULL != valueSet )
+        valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+      }
+      else
+      {
+        // Get Key is a string so searching Set Map for a string key
+        valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+      }
+
+      if( NULL != valueSet )
+      {
+        if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
         {
-          if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
-          {
-            tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
-            return false;
-          }
+          tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          return false;
         }
-        else
+        else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
         {
-          tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
+        {
+          tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
+        {
+          Vector2 vector2Get = valueGet.second.Get<Vector2>();
+          Vector2 vector2Set = valueSet->Get<Vector2>();
+          tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
+        {
+          Vector4 vector4Get = valueGet.second.Get<Vector4>();
+          Vector4 vector4Set = valueSet->Get<Vector4>();
+          tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
           return false;
         }
       }
       else
       {
-        Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
-        if( NULL != valueSet )
+        if ( valueGet.first.type == Property::Key::INDEX )
         {
-          if( valueGet.second.Get<int>() != valueSet->Get<int>() )
-          {
-            tet_printf( "  Integer Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
-            return false;
-          }
+          tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
         }
         else
         {
-          tet_printf( "  The Int key %d doesn't exist.", valueGet.first.indexKey );
-          return false;
+          tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
         }
+        return false;
       }
     }
   }
@@ -513,6 +541,7 @@ int UtcDaliTextFieldGetPropertyP(void)
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
+  DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
 
   END_TEST;
 }
@@ -843,8 +872,6 @@ int UtcDaliTextFieldSetPropertyP(void)
 
   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
 
-  outlineMapSet["color"] = "red";
-  outlineMapSet["width"] = "2";
   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
@@ -2723,3 +2750,31 @@ int UtcDaliTextFieldSetPaddingProperty(void)
 
   END_TEST;
 }
+
+int UtcDaliTextFieldEnableShiftSelectionProperty(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
+
+  TextField field = TextField::New();
+  DALI_TEST_CHECK( field );
+  field.SetSize( 300.f, 50.f );
+  field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  Stage::GetCurrent().Add( field );
+
+  application.SendNotification();
+  application.Render();
+
+  // The default value of ENABLE_SHIFT_SELECTION is 'true'.
+  DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
+
+  // Check the enable shift selection property
+  field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
+  DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
index 45214f8..cf36a87 100644 (file)
@@ -82,18 +82,64 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma
     {
       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
 
-      Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+      Property::Value* valueSet = NULL;
+      if ( valueGet.first.type == Property::Key::INDEX )
+      {
+        valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+      }
+      else
+      {
+        // Get Key is a string so searching Set Map for a string key
+        valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+      }
+
       if( NULL != valueSet )
       {
-        if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+        if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
         {
-          tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
+        {
+          tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
+        {
+          Vector2 vector2Get = valueGet.second.Get<Vector2>();
+          Vector2 vector2Set = valueSet->Get<Vector2>();
+          tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
+        {
+          Vector4 vector4Get = valueGet.second.Get<Vector4>();
+          Vector4 vector4Set = valueSet->Get<Vector4>();
+          tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
           return false;
         }
       }
       else
       {
-        tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+        if ( valueGet.first.type == Property::Key::INDEX )
+        {
+          tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
+        }
+        else
+        {
+          tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+        }
         return false;
       }
     }
@@ -383,14 +429,35 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
 
+  // test natural size with multi-line and line spacing
+  {
+    TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
+    Vector3 expected0(414.f, 192.f, 0.0f);
+    Vector3 expected1(414.f, 252.f, 0.0f);
+    label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
+    label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
+    DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
+    label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
+    DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+  }
 
+  // single line, line spacing must not affect natural size
+  {
+    const Vector3 expected0(948.f, 64.f, 0.0f);
+    const Vector3 expected1(948.f, 84.f, 0.0f);
+    TextLabel label3 = TextLabel::New("Some text here end there end here");
+    label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
+    label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
+    DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
+    label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
+    DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+  }
   // Check the line spacing property
   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   // Check the underline property
-
   underlineMapSet.Clear();
   underlineMapSet.Insert( "enable", "true" );
   underlineMapSet.Insert( "color", "red" );
@@ -463,8 +530,6 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   outlineMapSet["width"] = 2.0f;
   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
 
-  outlineMapSet["color"] = "red";
-  outlineMapSet["width"] = "2";
   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
@@ -1163,19 +1228,39 @@ int UtcDaliToolkitTextlabelTextDirection(void)
   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
 
   TextLabel label = TextLabel::New();
+  DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
   Stage::GetCurrent().Add( label );
 
-  application.SendNotification();
-  application.Render();
-
   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
 
   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
-  application.SendNotification();
-  application.Render();
   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
 
   END_TEST;
 }
+
+int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
+
+  TextLabel label = TextLabel::New();
+
+  label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
+  label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
+  label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
+  label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
+  Stage::GetCurrent().Add( label );
+  DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
+
+  label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
+  DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
+
+  label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
+  DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
+
+  END_TEST;
+}
\ No newline at end of file
index b1f2e2e..bf54997 100644 (file)
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/animated-gradient-visual-properties-devel.h>
 #include <dali-toolkit/dali-toolkit.h>
 
@@ -68,18 +70,64 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma
     {
       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
 
-      Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+      Property::Value* valueSet = NULL;
+      if ( valueGet.first.type == Property::Key::INDEX )
+      {
+        valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
+      }
+      else
+      {
+        // Get Key is a string so searching Set Map for a string key
+        valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
+      }
+
       if( NULL != valueSet )
       {
-        if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
+        if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
+        {
+          tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
+        {
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
         {
-          tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
+          tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
+        {
+          tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
+        {
+          Vector2 vector2Get = valueGet.second.Get<Vector2>();
+          Vector2 vector2Set = valueSet->Get<Vector2>();
+          tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
+          return false;
+        }
+        else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
+        {
+          Vector4 vector4Get = valueGet.second.Get<Vector4>();
+          Vector4 vector4Set = valueSet->Get<Vector4>();
+          tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
           return false;
         }
       }
       else
       {
-        tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+        if ( valueGet.first.type == Property::Key::INDEX )
+        {
+          tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
+        }
+        else
+        {
+          tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
+        }
         return false;
       }
     }
@@ -1070,6 +1118,16 @@ int UtcDaliVisualGetPropertyMap10(void)
   propertyMap.Insert( "horizontalAlignment", "CENTER" );
   propertyMap.Insert( "verticalAlignment", "CENTER" );
   propertyMap.Insert( "textColor", Color::RED );
+
+  Property::Map shadowMapSet;
+  propertyMap.Insert( "shadow", shadowMapSet.Add("color", Color::RED).Add("offset", Vector2(2.0f, 2.0f)).Add("blurRadius", 3.0f) );
+
+  Property::Map underlineMapSet;
+  propertyMap.Insert( "underline", underlineMapSet.Add("enable", "true").Add("color", "green").Add("height", "1") );
+
+  Property::Map outlineMapSet;
+  propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) );
+
   Visual::Base textVisual = factory.CreateVisual( propertyMap );
 
   Property::Map resultMap;
@@ -1123,6 +1181,27 @@ int UtcDaliVisualGetPropertyMap10(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( !value->Get<bool>() );
 
+  value = resultMap.Find( TextVisual::Property::SHADOW, Property::MAP );
+  DALI_TEST_CHECK( value );
+
+  Property::Map shadowMapGet = value->Get<Property::Map>();
+  DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
+
+  value = resultMap.Find( TextVisual::Property::UNDERLINE, Property::MAP );
+  DALI_TEST_CHECK( value );
+
+  Property::Map underlineMapGet = value->Get<Property::Map>();
+  DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
+
+  value = resultMap.Find( DevelTextVisual::Property::OUTLINE, Property::MAP );
+  DALI_TEST_CHECK( value );
+
+  Property::Map outlineMapGet = value->Get<Property::Map>();
+  DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -3314,3 +3393,53 @@ int UtcDaliRegisterVisualWithDepthIndex(void)
 
   END_TEST;
 }
+
+int UtcDaliColorVisualRenderIfTransparentProperty(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "Test the renderIfTransparent property of ColorVisual" );
+
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert( Visual::Property::TYPE,  Visual::COLOR );
+  propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE );
+
+  tet_infoline( "Check default value" );
+  {
+    Visual::Base testVisual = factory.CreateVisual( propertyMap );
+    Property::Map returnedMap;
+    testVisual.CreatePropertyMap( returnedMap );
+
+    Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
+    DALI_TEST_CHECK( renderIfTransparentProperty );
+    DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
+  }
+
+  propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true );
+
+  tet_infoline( "Ensure set to value required" );
+  {
+    Visual::Base testVisual = factory.CreateVisual( propertyMap );
+    Property::Map returnedMap;
+    testVisual.CreatePropertyMap( returnedMap );
+
+    Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
+    DALI_TEST_CHECK( renderIfTransparentProperty );
+    DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION );
+  }
+
+  propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE;
+
+  tet_infoline( "Ensure it returns default value if set to wrong type" );
+  {
+    Visual::Base testVisual = factory.CreateVisual( propertyMap );
+    Property::Map returnedMap;
+    testVisual.CreatePropertyMap( returnedMap );
+
+    Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
+    DALI_TEST_CHECK( renderIfTransparentProperty );
+    DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
+  }
+
+  END_TEST;
+}
index ddcd598..354478a 100644 (file)
@@ -354,6 +354,10 @@ ALIASES += SINCE_1_2_10="@since 1.2.10"
 ALIASES += SINCE_1_2_14="@since 1.2.14"
 ALIASES += SINCE_1_2_32="@since 1.2.32"
 
+# Extra tags for Tizen 4.0
+ALIASES += SINCE_1_3_4="@since 1.3.4"
+ALIASES += SINCE_1_3_5="@since 1.3.5"
+
 ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
 ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
 ALIASES += DEPRECATED_1_2_8="@deprecated Deprecated since 1.2.8"
@@ -384,6 +388,10 @@ ALIASES += REMARK_RAWVIDEO=""
 #ALIASES += SINCE_1_2_14="\par Since:\n 3.0, DALi version 1.2.14"
 #ALIASES += SINCE_1_2_32="\par Since:\n 3.0, DALi version 1.2.32"
 
+## Extra tags for Tizen 4.0
+#ALIASES += SINCE_1_3_4="\par Since:\n 4.0, DALi version 1.3.4"
+#ALIASES += SINCE_1_3_5="\par Since:\n 4.0, DALi version 1.3.5"
+
 ## DALi has no deprecated API in Tizen 2.4 because it's DALi's first release.
 ## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0.
 #ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 3.0, DALi version 1.0"
index 1ea20d2..116f69a 100644 (file)
@@ -83,12 +83,6 @@ bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index in
   return controlDataImpl.IsVisualEnabled( index );
 }
 
-Toolkit::Visual::ResourceStatus GetVisualResourceStatus( const Internal::Control& control, Dali::Property::Index index )
-{
-  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
-  return controlDataImpl.GetVisualResourceStatus( index );
-}
-
 Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& handle )
 {
   Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
index 9a824d3..ae90f4d 100644 (file)
@@ -215,15 +215,6 @@ DALI_IMPORT_API void EnableVisual( Internal::Control& control, Dali::Property::I
 DALI_IMPORT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
 
 /**
- * @brief Get the loading state of the visual resource.
- *
- * @param[in] control The control
- * @param[in] index The Property index of the visual
- * @return Return the loading status (PREPARING, READY and FAILED) of visual resource
- */
-DALI_IMPORT_API Toolkit::Visual::ResourceStatus GetVisualResourceStatus( const Internal::Control& control, Dali::Property::Index index );
-
-/**
  * @brief Create a transition effect on the control.
  *
  * Only generates an animation if the properties described in the transition
index 153a538..3a8fa6f 100644 (file)
@@ -96,6 +96,12 @@ namespace Property
        * @details Name "placeholderTextColor", type Property::VECTOR4.
        */
       PLACEHOLDER_TEXT_COLOR,
+
+      /**
+       * @brief Enables Text selection using Shift key.
+       * @details Name "enableShiftSelection", type Property::BOOLEAN.
+       */
+      ENABLE_SHIFT_SELECTION
   };
 
 } // namespace Property
diff --git a/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
new file mode 100644 (file)
index 0000000..8e73c99
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
+#define DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelTextField
+{
+
+namespace Property
+{
+  enum
+  {
+      RENDERING_BACKEND = Dali::Toolkit::TextField::Property::RENDERING_BACKEND,
+      TEXT = Dali::Toolkit::TextField::Property::TEXT,
+      PLACEHOLDER_TEXT = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT,
+      PLACEHOLDER_TEXT_FOCUSED = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED,
+      FONT_FAMILY = Dali::Toolkit::TextField::Property::FONT_FAMILY,
+      FONT_STYLE = Dali::Toolkit::TextField::Property::FONT_STYLE,
+      POINT_SIZE = Dali::Toolkit::TextField::Property::POINT_SIZE,
+      MAX_LENGTH = Dali::Toolkit::TextField::Property::MAX_LENGTH,
+      EXCEED_POLICY = Dali::Toolkit::TextField::Property::EXCEED_POLICY,
+      HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT,
+      VERTICAL_ALIGNMENT = Dali::Toolkit::TextField::Property::VERTICAL_ALIGNMENT,
+      TEXT_COLOR = Dali::Toolkit::TextField::Property::TEXT_COLOR,
+      PLACEHOLDER_TEXT_COLOR = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR,
+      SHADOW_OFFSET = Dali::Toolkit::TextField::Property::SHADOW_OFFSET,
+      SHADOW_COLOR = Dali::Toolkit::TextField::Property::SHADOW_COLOR,
+      PRIMARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR,
+      SECONDARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR,
+      ENABLE_CURSOR_BLINK = Dali::Toolkit::TextField::Property::ENABLE_CURSOR_BLINK,
+      CURSOR_BLINK_INTERVAL = Dali::Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL,
+      CURSOR_BLINK_DURATION = Dali::Toolkit::TextField::Property::CURSOR_BLINK_DURATION,
+      CURSOR_WIDTH = Dali::Toolkit::TextField::Property::CURSOR_WIDTH,
+      GRAB_HANDLE_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_IMAGE,
+      GRAB_HANDLE_PRESSED_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE,
+      SCROLL_THRESHOLD = Dali::Toolkit::TextField::Property::SCROLL_THRESHOLD,
+      SCROLL_SPEED = Dali::Toolkit::TextField::Property::SCROLL_SPEED,
+      SELECTION_HANDLE_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT,
+      SELECTION_HANDLE_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT,
+      SELECTION_HANDLE_PRESSED_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
+      SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
+      SELECTION_HANDLE_MARKER_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT,
+      SELECTION_HANDLE_MARKER_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
+      SELECTION_HIGHLIGHT_COLOR = Dali::Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR,
+      DECORATION_BOUNDING_BOX = Dali::Toolkit::TextField::Property::DECORATION_BOUNDING_BOX,
+      INPUT_METHOD_SETTINGS = Dali::Toolkit::TextField::Property::INPUT_METHOD_SETTINGS,
+      INPUT_COLOR = Dali::Toolkit::TextField::Property::INPUT_COLOR,
+      ENABLE_MARKUP = Dali::Toolkit::TextField::Property::ENABLE_MARKUP,
+      INPUT_FONT_FAMILY = Dali::Toolkit::TextField::Property::INPUT_FONT_FAMILY,
+      INPUT_FONT_STYLE = Dali::Toolkit::TextField::Property::INPUT_FONT_STYLE,
+      INPUT_POINT_SIZE = Dali::Toolkit::TextField::Property::INPUT_POINT_SIZE,
+      UNDERLINE = Dali::Toolkit::TextField::Property::UNDERLINE,
+      INPUT_UNDERLINE = Dali::Toolkit::TextField::Property::INPUT_UNDERLINE,
+      SHADOW = Dali::Toolkit::TextField::Property::SHADOW,
+      INPUT_SHADOW = Dali::Toolkit::TextField::Property::INPUT_SHADOW,
+      EMBOSS = Dali::Toolkit::TextField::Property::EMBOSS,
+      INPUT_EMBOSS = Dali::Toolkit::TextField::Property::INPUT_EMBOSS,
+      OUTLINE = Dali::Toolkit::TextField::Property::OUTLINE,
+      INPUT_OUTLINE = Dali::Toolkit::TextField::Property::INPUT_OUTLINE,
+      HIDDEN_INPUT_SETTINGS = Dali::Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS,
+      PIXEL_SIZE = Dali::Toolkit::TextField::Property::PIXEL_SIZE,
+      ENABLE_SELECTION = Dali::Toolkit::TextField::Property::ENABLE_SELECTION,
+      PLACEHOLDER = Dali::Toolkit::TextField::Property::PLACEHOLDER,
+      ELLIPSIS = Dali::Toolkit::TextField::Property::ELLIPSIS,
+
+      /**
+       * @brief Enables Text selection using Shift key.
+       * @details Name "enableShiftSelection", type Property::BOOLEAN.
+       */
+      ENABLE_SHIFT_SELECTION = ELLIPSIS + 1
+  };
+} // namespace Property
+
+} // namespace DevelText
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
index 2838a00..3238c61 100644 (file)
@@ -67,10 +67,19 @@ namespace Property
 
     /**
      * @brief The direction of the layout.
-     * @details Name "textDirection", type Property::Integer, Read-Only.
+     * @details Name "textDirection", type [Type](@ref Dali::Toolkit::DevelText::TextDirection::Type) (Property::INTEGER), Read/Write
+     * @note The text direction can be changed only by replacing the text itself.
      * @see TextDirection::Type for supported values.
      */
     TEXT_DIRECTION,
+
+    /**
+     * @brief Alignment of text within area of single line
+     * @details Name "verticalLineAlignment", type [Type](@ref Dali::Toolkit::DevelText::VerticalLineAlignment::Type) (Property::INTEGER), Read/Write
+     * @note The default value is TOP
+     * @see VerticalLineAlignment::Type for supported values
+     */
+    VERTICAL_LINE_ALIGNMENT,
   };
 
 } // namespace Property
index 3f114bb..812668b 100644 (file)
@@ -91,9 +91,11 @@ devel_api_visual_factory_header_files = \
   $(devel_api_src_dir)/visual-factory/visual-base.h
 
 devel_api_visuals_header_files = \
+  $(devel_api_src_dir)/visuals/animated-gradient-visual-properties-devel.h \
+  $(devel_api_src_dir)/visuals/color-visual-properties-devel.h \
   $(devel_api_src_dir)/visuals/image-visual-properties-devel.h \
   $(devel_api_src_dir)/visuals/image-visual-actions-devel.h \
-  $(devel_api_src_dir)/visuals/animated-gradient-visual-properties-devel.h \
+  $(devel_api_src_dir)/visuals/text-visual-properties-devel.h \
   $(devel_api_src_dir)/visuals/visual-properties-devel.h
 
 devel_api_shadow_view_header_files = \
@@ -129,6 +131,7 @@ devel_api_super_blur_view_header_files = \
 
 devel_api_text_controls_header_files = \
   $(devel_api_src_dir)/controls/text-controls/text-editor-devel.h \
+  $(devel_api_src_dir)/controls/text-controls/text-field-devel.h \
   $(devel_api_src_dir)/controls/text-controls/text-label-devel.h \
   $(devel_api_src_dir)/controls/text-controls/text-selection-popup.h \
   $(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.h
index b88eab9..ce4bf3d 100644 (file)
@@ -61,7 +61,7 @@ DALI_IMPORT_API std::string AddTexture( TextureSet& textureSet );
  */
 DALI_IMPORT_API TextureSet RemoveTexture( const std::string& textureUrl );
 
-}
+} // TextureManager
 
 } // Toolkit
 
index 5062417..4e9b278 100644 (file)
@@ -38,6 +38,18 @@ enum Type
 
 } // namespace TextDirection
 
+namespace VerticalLineAlignment
+{
+
+enum Type
+{
+  TOP,
+  MIDDLE,
+  BOTTOM
+};
+
+} // namespace VerticalLineAlignment
+
 } // namespace DevelText
 
 } // namespace Toolkit
index b6a51fb..88cb626 100644 (file)
@@ -61,7 +61,7 @@ const std::string& Visual::Base::GetName()
   return GetImplementation( *this ).GetName();
 }
 
-void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize )
+void Visual::Base::SetTransformAndSize( const Dali::Property::Map& transform, Size controlSize )
 {
   GetImplementation( *this ).SetTransformAndSize( transform, controlSize );
 }
@@ -91,7 +91,7 @@ int Visual::Base::GetDepthIndex() const
   return GetImplementation( *this ).GetDepthIndex();
 }
 
-void Visual::Base::CreatePropertyMap( Property::Map& map ) const
+void Visual::Base::CreatePropertyMap( Dali::Property::Map& map ) const
 {
   GetImplementation( *this ).CreatePropertyMap( map );
 }
index da41237..54a0310 100644 (file)
@@ -38,13 +38,6 @@ class Base;
 namespace Visual
 {
 
-enum class ResourceStatus
-{
-  PREPARING,
-  READY,
-  FAILED
-};
-
 /**
  * @brief A Visual provides a renderer for drawing a control component. A control may have multiple visuals.
  *
diff --git a/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/color-visual-properties-devel.h
new file mode 100644 (file)
index 0000000..4eb8b3a
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_DEVEL_H
+#define DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+
+namespace DevelColorVisual
+{
+
+/**
+ * @brief Additional ColorVisual Properties.
+ */
+namespace Property
+{
+
+/**
+ * @brief Enumeration for the instance of additional properties belonging to the ColorVisual.
+ */
+enum
+{
+  MIX_COLOR = Toolkit::ColorVisual::Property::MIX_COLOR,
+
+  /**
+   * @brief Whether to render if the MIX_COLOR is transparent.
+   * @details Name "renderIfTransparent", type Property::BOOLEAN.
+   * @note Optional.
+   * @note By default it's false, i.e. ColorVisual will not render if the MIX_COLOR is transparent.
+   */
+  RENDER_IF_TRANSPARENT = MIX_COLOR + 1,
+};
+
+} // namespace Property
+
+} // namespace ColorVisual
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_DEVEL_H
index e87af5d..a340755 100644 (file)
@@ -30,42 +30,6 @@ namespace Toolkit
 namespace DevelImageVisual
 {
 
-/**
- * @brief The policy determining if the image is loaded when the visual is staged or created.
- */
-namespace LoadPolicy
-{
-
-/**
- * @brief The available named elements that define the LoadPolicy.
- */
-enum Type
-{
-  IMMEDIATE = 0,  ///< The image is loaded when the ImageVisual is created.
-  ATTACHED        ///< The image is loaded when the ImageVisual is attached to the stage.
-};
-
-} // namespace LoadPolicy
-
-/**
- * @brief The policy determining when a image is deleted from the cache in relation to the ImageVisual lifetime.
- * @note If the texture is being shared by another visual it persist if still required.
- */
-namespace ReleasePolicy
-{
-
-/**
- * @brief The available named elements that define the ReleasePolicy.
- */
-enum Type
-{
-  DETACHED = 0,  ///<  Image deleted from cache when ImageVisual detached from stage.
-  DESTROYED,     ///<  Image deleted from cache when ImageVisual destroyed.
-  NEVER          ///<  Image is never deleted, will survive the lifetime of the application.
-};
-
-} // namespace ReleasePolicy;
-
 namespace Property
 {
 
@@ -89,29 +53,9 @@ enum Type
   FRAME_DELAY         = Dali::Toolkit::ImageVisual::Property::FRAME_DELAY,
   MASK_CONTENT_SCALE  = Dali::Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE,
   CROP_TO_MASK        = Dali::Toolkit::ImageVisual::Property::CROP_TO_MASK,
-
-  /**
-   * @brief The policy to determine when an image should be loaded.
-   * @details Name "loadPolicy",  Type LoadPolicy::Type (Property::INTEGER)or Property::STRING.
-   * @note Default LoadPolicy::ATTACHED
-   * @see LoadPolicy::Type
-   */
-  LOAD_POLICY = CROP_TO_MASK + 1,
-
-  /**
-   * @brief The policy to determine when an image should no longer be cached.
-   * @details Name "releasePolicy", Type ReleasePolicy::Type (Property::INTEGER) or Property::STRING
-   * @note Default ReleasePolicy::DESTROYED
-   * @see ReleasePolicy::Type
-   */
-  RELEASE_POLICY = CROP_TO_MASK + 2,
-
-  /**
-   * @brief Determines if image orientation should be corrected so the image displays as it was intended.
-   * @details Name "orientationCorrection", Type Property::BOOLEAN, if true the image's orientation will be corrected.
-   * @note Default true
-   */
-  ORIENTATION_CORRECTION = CROP_TO_MASK + 3,
+  LOAD_POLICY         = Dali::Toolkit::ImageVisual::Property::LOAD_POLICY,
+  RELEASE_POLICY      = Dali::Toolkit::ImageVisual::Property::RELEASE_POLICY,
+  ORIENTATION_CORRECTION = Dali::Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION,
 
   /**
    * @brief Overlays the auxiliary iamge on top of an NPatch image.
@@ -123,14 +67,14 @@ enum Type
    * @details Name "auxiliaryImage", Type Property::STRING, URL of the image.
    * @note Default true
    */
-  AUXILIARY_IMAGE = CROP_TO_MASK + 4,
+  AUXILIARY_IMAGE = ORIENTATION_CORRECTION + 1,
 
   /**
    * @brief An alpha value for mixing between the masked main NPatch image and the auxiliary image
    * @details Name "auxiliaryImageAlpha", Type Property::FLOAT, between 0 and 1
    * @note Default 0
    */
-  AUXILIARY_IMAGE_ALPHA = CROP_TO_MASK + 5,
+  AUXILIARY_IMAGE_ALPHA = ORIENTATION_CORRECTION + 2,
 
 };
 
diff --git a/dali-toolkit/devel-api/visuals/text-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/text-visual-properties-devel.h
new file mode 100644 (file)
index 0000000..ec80f49
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_TEXT_VISUAL_PROPERTIES_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_TEXT_VISUAL_PROPERTIES_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/text-visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelTextVisual
+{
+
+namespace Property
+{
+
+/**
+ * @brief All the visual types.
+ */
+enum
+{
+  TEXT                  = Dali::Toolkit::TextVisual::Property::TEXT,
+  FONT_FAMILY           = Dali::Toolkit::TextVisual::Property::FONT_FAMILY,
+  FONT_STYLE            = Dali::Toolkit::TextVisual::Property::FONT_STYLE,
+  POINT_SIZE            = Dali::Toolkit::TextVisual::Property::POINT_SIZE,
+  MULTI_LINE            = Dali::Toolkit::TextVisual::Property::MULTI_LINE,
+  HORIZONTAL_ALIGNMENT  = Dali::Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT,
+  VERTICAL_ALIGNMENT    = Dali::Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT,
+  TEXT_COLOR            = Dali::Toolkit::TextVisual::Property::TEXT_COLOR,
+  ENABLE_MARKUP         = Dali::Toolkit::TextVisual::Property::ENABLE_MARKUP,
+  SHADOW                = Dali::Toolkit::TextVisual::Property::SHADOW,
+  UNDERLINE             = Dali::Toolkit::TextVisual::Property::UNDERLINE,
+
+  /**
+   * @brief The default outline parameters.
+   * @details name "outline", type Property::MAP.
+   */
+  OUTLINE               = UNDERLINE + 1
+};
+
+
+} // namespace Property
+
+} // namespace DevelTextVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_TEXT_VISUAL_PROPERTIES_DEVEL_H
index df661ef..ddd7506 100644 (file)
@@ -31,6 +31,7 @@
 #include <dali-toolkit/internal/controls/tooltip/tooltip.h>
 #include <dali-toolkit/internal/builder/style.h>
 #include <dali-toolkit/internal/builder/dictionary.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 namespace Dali
 {
index 8ac3938..77974d5 100644 (file)
@@ -135,6 +135,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder",
 DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineWrapMode",                         INTEGER,   LINE_WRAP_MODE                       )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText",                STRING,    PLACEHOLDER_TEXT                     )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor",           VECTOR4,   PLACEHOLDER_TEXT_COLOR               )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableShiftSelection",           BOOLEAN,   ENABLE_SHIFT_SELECTION               )
 
 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged",        SIGNAL_TEXT_CHANGED )
 DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged",  SIGNAL_INPUT_STYLE_CHANGED )
@@ -510,8 +511,14 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
+
+          // The line spacing isn't supported by the TextEditor. Since it's supported
+          // by the TextLabel for now it must be ignored. The property is being shadowed
+          // locally so its value isn't affected.
           const float lineSpacing = value.Get<float>();
-          impl.mController->SetDefaultLineSpacing( lineSpacing );
+          impl.mLineSpacing = lineSpacing;
+          // set it to 0.0 due to missing implementation
+          impl.mController->SetDefaultLineSpacing( 0.0f );
           impl.mRenderer.Reset();
         }
         break;
@@ -708,12 +715,23 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
           Text::LineWrap::Mode lineWrapMode( static_cast< Text::LineWrap::Mode >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
           if( GetLineWrapModeEnumeration( value, lineWrapMode ) )
           {
-            DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode );
+            DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode );
             impl.mController->SetLineWrapMode( lineWrapMode );
           }
         }
         break;
       }
+      case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
+      {
+        if( impl.mController )
+        {
+          const bool shiftSelection = value.Get<bool>();
+          DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
+
+          impl.mController->SetShiftSelectionEnabled( shiftSelection );
+        }
+        break;
+      }
     } // switch
   } // texteditor
 }
@@ -961,7 +979,9 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
       {
         if( impl.mController )
         {
-          value = impl.mController->GetDefaultLineSpacing();
+          // LINE_SPACING isn't implemented for the TextEditor. Returning
+          // only shadowed value, not the real one.
+          value = impl.mLineSpacing;
         }
         break;
       }
@@ -1094,6 +1114,15 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
         {
           value = impl.mController->GetLineWrapMode();
         }
+        break;
+      }
+      case Toolkit::DevelTextEditor::Property::ENABLE_SHIFT_SELECTION:
+      {
+        if( impl.mController )
+        {
+          value = impl.mController->IsShiftSelectionEnabled();
+        }
+        break;
       }
     } //switch
   }
@@ -1778,6 +1807,7 @@ TextEditor::TextEditor()
   mIdleCallback( NULL ),
   mAlignmentOffset( 0.f ),
   mScrollAnimationDuration( 0.f ),
+  mLineSpacing( 0.f ),
   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
   mHasBeenStaged( false ),
   mScrollAnimationEnabled( false ),
index f121799..a3a8854 100644 (file)
@@ -300,6 +300,7 @@ private: // Data
 
   float mAlignmentOffset;
   float mScrollAnimationDuration;
+  float mLineSpacing;
   int mRenderingBackend;
   bool mHasBeenStaged:1;
   bool mScrollAnimationEnabled:1;
index 1417743..737d507 100644 (file)
@@ -35,6 +35,7 @@
 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
@@ -127,6 +128,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pixelSize",
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableSelection",                      BOOLEAN,   ENABLE_SELECTION                     )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder",                          MAP,       PLACEHOLDER                          )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis",                             BOOLEAN,   ELLIPSIS                             )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection",           BOOLEAN,   ENABLE_SHIFT_SELECTION               )
 
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged",        SIGNAL_TEXT_CHANGED )
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached",   SIGNAL_MAX_LENGTH_REACHED )
@@ -758,6 +760,17 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
+      case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
+      {
+        if( impl.mController )
+        {
+          const bool shiftSelection = value.Get<bool>();
+          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
+
+          impl.mController->SetShiftSelectionEnabled( shiftSelection );
+        }
+        break;
+      }
     } // switch
   } // textfield
 }
@@ -1157,6 +1170,14 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
         }
         break;
       }
+      case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
+      {
+        if( impl.mController )
+        {
+          value = impl.mController->IsShiftSelectionEnabled();
+        }
+        break;
+      }
     } //switch
   }
 
index cd96e00..0cbb799 100644 (file)
@@ -116,6 +116,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit,           TextLabel, "autoScrollStopMode",
 DALI_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount",                 INTEGER, LINE_COUNT                 )
 DALI_PROPERTY_REGISTRATION( Toolkit,           TextLabel, "lineWrapMode",              INTEGER, LINE_WRAP_MODE             )
 DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "textDirection",       INTEGER, TEXT_DIRECTION             )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalLineAlignment",         INTEGER, VERTICAL_LINE_ALIGNMENT    )
 DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColor",      Color::BLACK,     TEXT_COLOR     )
 DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit,    TextLabel, "textColorRed",   TEXT_COLOR_RED,   TEXT_COLOR, 0  )
 DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit,    TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1  )
@@ -410,8 +411,12 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         if( impl.mController )
         {
           const float lineSpacing = value.Get<float>();
-          impl.mController->SetDefaultLineSpacing( lineSpacing );
-          impl.mTextUpdateNeeded = true;
+
+          // Don't trigger anything if the line spacing didn't change
+          if( impl.mController->SetDefaultLineSpacing( lineSpacing ) )
+          {
+            impl.mTextUpdateNeeded = true;
+          }
         }
         break;
       }
@@ -489,8 +494,37 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
+      case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT:
+      {
+        if( impl.mController && impl.mController->GetTextModel() )
+        {
+          DevelText::VerticalLineAlignment::Type alignment = static_cast<DevelText::VerticalLineAlignment::Type>( value.Get<int>() );
+
+          impl.mController->SetVerticalLineAlignment( alignment );
+
+          // Property doesn't affect the layout, only Visual must be updated
+          TextVisual::EnableRendererUpdate( impl.mVisual );
+
+          // No need to trigger full re-layout. Instead call UpdateRenderer() directly
+          TextVisual::UpdateRenderer( impl.mVisual );
+        }
+        break;
+      }
+    }
+
+    // Request relayout when text update is needed. It's necessary to call it
+    // as changing the property not via UI interaction brings no effect if only
+    // the mTextUpdateNeeded is changed.
+    if( impl.mTextUpdateNeeded )
+    {
+      // need to request relayout as size of text may have changed
+      impl.RequestTextRelayout();
     }
   }
+
+
+
+
 }
 
 Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
@@ -761,6 +795,14 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
         }
         break;
       }
+      case Toolkit::DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT:
+      {
+        if( impl.mController )
+        {
+          value = impl.mController->GetVerticalLineAlignment();
+        }
+        break;
+      }
     }
   }
 
@@ -979,7 +1021,7 @@ void TextLabel::SetUpAutoScrolling()
 
   // Set parameters for scrolling
   Renderer renderer = static_cast<Internal::Visual::Base&>( GetImplementation( mVisual ) ).GetRenderer();
-  mTextScroller->SetParameters( Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment() );
+  mTextScroller->SetParameters( Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment(), mController->IsTextElideEnabled() );
 }
 
 void TextLabel::ScrollingFinished()
index e9e0b1a..aa4d5c6 100644 (file)
@@ -236,6 +236,9 @@ struct Decorator::Impl : public ConnectionTracker
     mBoundingBox(),
     mHighlightColor( LIGHT_BLUE ),
     mHighlightPosition( Vector2::ZERO ),
+    mHighlightSize( Vector2::ZERO ),
+    mControlSize( Vector2::ZERO ),
+    mHighlightOutlineOffset( 0.f ),
     mActiveCursor( ACTIVE_CURSOR_NONE ),
     mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
     mCursorBlinkDuration( 0.0f ),
@@ -1163,8 +1166,8 @@ struct Decorator::Impl : public ConnectionTracker
     if ( mHighlightActor )
     {
       // Sets the position of the highlight actor inside the decorator.
-      mHighlightActor.SetPosition( mHighlightPosition.x,
-                                   mHighlightPosition.y );
+      mHighlightActor.SetPosition( mHighlightPosition.x + mHighlightOutlineOffset,
+                                   mHighlightPosition.y + mHighlightOutlineOffset );
 
       const unsigned int numberOfQuads = mHighlightQuadList.Count();
       if( 0u != numberOfQuads )
@@ -1912,6 +1915,7 @@ struct Decorator::Impl : public ConnectionTracker
   Vector2             mHighlightPosition;         ///< The position of the highlight actor.
   Size                mHighlightSize;             ///< The size of the highlighted text.
   Size                mControlSize;               ///< The control's size. Set by the Relayout.
+  float               mHighlightOutlineOffset;    ///< The outline's offset.
 
   unsigned int        mActiveCursor;
   unsigned int        mCursorBlinkInterval;
@@ -2199,16 +2203,18 @@ void Decorator::AddHighlight( unsigned int index, const Vector4& quad )
   *( mImpl->mHighlightQuadList.Begin() + index ) = quad;
 }
 
-void Decorator::SetHighLightBox( const Vector2& position, const Size& size )
+void Decorator::SetHighLightBox( const Vector2& position, const Size& size, float outlineOffset )
 {
   mImpl->mHighlightPosition = position;
   mImpl->mHighlightSize = size;
+  mImpl->mHighlightOutlineOffset = outlineOffset;
 }
 
 void Decorator::ClearHighlights()
 {
   mImpl->mHighlightQuadList.Clear();
   mImpl->mHighlightPosition = Vector2::ZERO;
+  mImpl->mHighlightOutlineOffset = 0.f;
 }
 
 void Decorator::ResizeHighlightQuads( unsigned int numberOfQuads )
index 8cff322..11f7062 100644 (file)
@@ -468,9 +468,11 @@ public:
    *
    * @param[in] position The position of the highlighted text in decorator's coords.
    * @param[in] size The size of the highlighted text.
+   * @param[in] outlineOffset The outline's offset.
    */
   void SetHighLightBox( const Vector2& position,
-                        const Size& size );
+                        const Size& size,
+                        float outlineOffset );
 
   /**
    * @brief Removes all of the previously added highlights.
index ccd42ae..dd429a1 100644 (file)
@@ -70,7 +70,8 @@ struct LineLayout
     extraWidth( 0.f ),
     wsLengthEndOfLine( 0.f ),
     ascender( 0.f ),
-    descender( MAX_FLOAT )
+    descender( MAX_FLOAT ),
+    lineSpacing( 0.f )
   {}
 
   ~LineLayout()
@@ -100,6 +101,7 @@ struct LineLayout
   float          wsLengthEndOfLine;  ///< The length of the white spaces at the end of the line.
   float          ascender;           ///< The maximum ascender of all fonts in the line.
   float          descender;          ///< The minimum descender of all fonts in the line.
+  float          lineSpacing;        ///< The line spacing
 };
 
 struct Engine::Impl
@@ -133,6 +135,9 @@ struct Engine::Impl
     {
       lineLayout.descender = fontMetrics.descender;
     }
+
+    // set the line spacing
+    lineLayout.lineSpacing = mDefaultLineSpacing;
   }
 
   /**
@@ -568,7 +573,7 @@ struct Engine::Impl
         // Get the last line and layout it again with the 'completelyFill' flag to true.
         lineRun = linesBuffer + ( numberOfLines - 1u );
 
-        penY -= layout.ascender - lineRun->descender;
+        penY -= layout.ascender - lineRun->descender + lineRun->lineSpacing;
 
         ellipsisLayout.glyphIndex = lineRun->glyphRun.glyphIndex;
       }
@@ -601,7 +606,7 @@ struct Engine::Impl
       layoutSize.width = layoutParameters.boundingBox.width;
       if( layoutSize.height < Math::MACHINE_EPSILON_1000 )
       {
-        layoutSize.height += ( lineRun->ascender + -lineRun->descender );
+        layoutSize.height += ( lineRun->ascender + -lineRun->descender ) + lineRun->lineSpacing;
       }
 
       SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex,
@@ -639,6 +644,8 @@ struct Engine::Impl
     lineRun.glyphRun.numberOfGlyphs = layout.numberOfGlyphs;
     lineRun.characterRun.characterIndex = layout.characterIndex;
     lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
+    lineRun.lineSpacing = mDefaultLineSpacing;
+
     if( isLastLine && !layoutParameters.isLastNewParagraph )
     {
       const float width = layout.extraBearing + layout.length + layout.extraWidth + layout.wsLengthEndOfLine;
@@ -669,7 +676,7 @@ struct Engine::Impl
       layoutSize.width = lineRun.width;
     }
 
-    layoutSize.height += ( lineRun.ascender + -lineRun.descender );
+    layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
   }
 
   /**
@@ -709,8 +716,9 @@ struct Engine::Impl
     lineRun.alignmentOffset = 0.f;
     lineRun.direction = !RTL;
     lineRun.ellipsis = false;
+    lineRun.lineSpacing = mDefaultLineSpacing;
 
-    layoutSize.height += ( lineRun.ascender + -lineRun.descender );
+    layoutSize.height += ( lineRun.ascender + -lineRun.descender ) + lineRun.lineSpacing;
   }
 
   /**
@@ -734,7 +742,7 @@ struct Engine::Impl
         layoutSize.width = line.width;
       }
 
-      layoutSize.height += ( line.ascender + -line.descender );
+      layoutSize.height += ( line.ascender + -line.descender ) + line.lineSpacing;
     }
   }
 
@@ -970,7 +978,7 @@ struct Engine::Impl
                            glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
 
         // Updates the vertical pen's position.
-        penY += -layout.descender;
+        penY += -layout.descender + layout.lineSpacing + mDefaultLineSpacing;
 
         // Increase the glyph index.
         index = nextIndex;
@@ -1203,6 +1211,7 @@ struct Engine::Impl
     line.alignmentOffset = 0.f;
     line.direction = !RTL;
     line.ellipsis = false;
+    line.lineSpacing = mDefaultLineSpacing;
   }
 
   Type mLayout;
index 52df79e..9023121 100644 (file)
@@ -43,6 +43,7 @@ struct LineRun
   float              descender;       ///< The line's descender.
   float              extraLength;     ///< The length of the white spaces at the end of the line.
   float              alignmentOffset; ///< The horizontal alignment offset.
+  float              lineSpacing;     ///< The line's spacing
   CharacterDirection direction : 1;   ///< Direction of the first character of the paragraph.
   bool               ellipsis  : 1;   ///< Wheter ellipsis is added to the line.
 };
index 8af6140..76d9a6a 100644 (file)
@@ -109,6 +109,13 @@ void FloatToString( float value, std::string& floatStr )
   floatStr = ss.str();
 }
 
+void UintToString( unsigned int value, std::string& uIntStr )
+{
+  std::stringstream ss;
+  ss << value;
+  uIntStr = ss.str();
+}
+
 void UintColorToVector4( unsigned int color, Vector4& retColor )
 {
   retColor.a = static_cast<float>( ( color & 0xFF000000 ) >> 24u ) / 255.f;
index 45f586c..d1ecbc8 100644 (file)
@@ -121,6 +121,14 @@ float StringToFloat( const char* const floatStr );
 void FloatToString( float value, std::string& floatStr );
 
 /**
+ * @brief Converts an unsigned int into a string.
+ *
+ * @param[in] value The unsigned int value.
+ * @param[out] uIntStr The string.
+ */
+void UintToString( unsigned int value, std::string& uIntStr );
+
+/**
  * @brief Converts an ARGB color packed in 4 byte unsigned int into a Vector4 color used in Dali.
  *
  * @param[in] color An ARGB color packed in an unsigned int.
index e88a286..990d0ce 100644 (file)
@@ -451,10 +451,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
   FontId previousFontId = 0u;
   bool isPreviousEmojiScript = false;
 
-  // Whether it's the first set of characters to be validated.
-  // Used in case the paragraph starts with characters common to all scripts.
-  bool isFirstSetToBeValidated = true;
-
   CharacterIndex lastCharacter = startIndex + numberOfCharacters;
   for( Length index = startIndex; index < lastCharacter; ++index )
   {
@@ -705,12 +701,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     }
 #endif
 
-    if( isFirstSetToBeValidated && !isCommonScript )
-    {
-      currentFontRun.fontId = fontId;
-      isFirstSetToBeValidated = false;
-    }
-
     // The font is now validated.
     if( ( fontId != currentFontRun.fontId ) ||
         isNewParagraphCharacter )
@@ -728,11 +718,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
       currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
       currentFontRun.characterRun.numberOfCharacters = 0u;
       currentFontRun.fontId = fontId;
-
-      if( isNewParagraphCharacter )
-      {
-        isFirstSetToBeValidated = true;
-      }
     }
 
     // Add one more character to the run.
index 0d72be9..957fd8e 100644 (file)
@@ -44,6 +44,7 @@ AtlasGlyphManager::AtlasGlyphManager()
 }
 
 void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
+                             const uint32_t outlineWidth,
                              const PixelData& bitmap,
                              Dali::Toolkit::AtlasManager::AtlasSlot& slot )
 {
@@ -62,6 +63,7 @@ void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
 
   GlyphRecordEntry record;
   record.mIndex = glyph.index;
+  record.mOutlineWidth = outlineWidth;
   record.mImageId = slot.mImageId;
   record.mCount = 1;
 
@@ -98,6 +100,7 @@ void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
 
 bool AtlasGlyphManager::IsCached( Text::FontId fontId,
                                 Text::GlyphIndex index,
+                                uint32_t outlineWidth,
                                 Dali::Toolkit::AtlasManager::AtlasSlot& slot )
 {
   for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
@@ -110,7 +113,7 @@ bool AtlasGlyphManager::IsCached( Text::FontId fontId,
             glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
             ++glyphRecordIt )
       {
-        if ( glyphRecordIt->mIndex == index )
+        if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth )
         {
           slot.mImageId = glyphRecordIt->mImageId;
           slot.mAtlasId = mAtlasManager.GetAtlas( slot.mImageId );
@@ -171,7 +174,7 @@ const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
   return mMetrics;
 }
 
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta )
 {
   if( 0 != delta )
   {
@@ -187,7 +190,7 @@ void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIn
               glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
               ++glyphRecordIt )
         {
-          if ( glyphRecordIt->mIndex == index )
+          if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth )
           {
             glyphRecordIt->mCount += delta;
             DALI_ASSERT_DEBUG( glyphRecordIt->mCount >= 0 && "Glyph ref-count should not be negative" );
index a2232f9..0d32834 100644 (file)
@@ -51,6 +51,7 @@ public:
   struct GlyphRecordEntry
   {
     Text::GlyphIndex mIndex;
+    uint32_t mOutlineWidth;
     uint32_t mImageId;
     int32_t mCount;
   };
@@ -70,6 +71,7 @@ public:
    * @copydoc Toolkit::AtlasGlyphManager::Add
    */
   void Add( const Text::GlyphInfo& glyph,
+            const uint32_t outlineWidth,
             const PixelData& bitmap,
             Dali::Toolkit::AtlasManager::AtlasSlot& slot );
 
@@ -85,6 +87,7 @@ public:
    */
   bool IsCached( Text::FontId fontId,
                  Text::GlyphIndex index,
+                 uint32_t outlineWidth,
                  Dali::Toolkit::AtlasManager::AtlasSlot& slot );
 
   /**
@@ -105,7 +108,7 @@ public:
   /**
    * @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
    */
-  void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
+  void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta );
 
   /**
    * @copydoc Toolkit::AtlasGlyphManager::GetTextures
index 743bc6c..bd6850d 100644 (file)
@@ -69,10 +69,11 @@ AtlasGlyphManager::AtlasGlyphManager(Internal::AtlasGlyphManager *impl)
 }
 
 void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
+                             const uint32_t outlineWidth,
                              const PixelData& bitmap,
                              AtlasManager::AtlasSlot& slot )
 {
-  GetImplementation(*this).Add( glyph, bitmap, slot );
+  GetImplementation(*this).Add( glyph, outlineWidth, bitmap, slot );
 }
 
 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
@@ -86,9 +87,10 @@ void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
 
 bool AtlasGlyphManager::IsCached( Text::FontId fontId,
                                   Text::GlyphIndex index,
+                                  uint32_t outlineWidth,
                                   AtlasManager::AtlasSlot& slot )
 {
-  return GetImplementation(*this).IsCached( fontId, index, slot );
+  return GetImplementation(*this).IsCached( fontId, index, outlineWidth, slot );
 }
 
 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
@@ -116,9 +118,9 @@ const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
   return GetImplementation(*this).GetMetrics();
 }
 
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta )
 {
-  GetImplementation(*this).AdjustReferenceCount( fontId, index, delta );
+  GetImplementation(*this).AdjustReferenceCount( fontId, index, outlineWidth, delta );
 }
 
 } // namespace Toolkit
index 1bc058b..c41415e 100644 (file)
@@ -80,10 +80,12 @@ public:
    * @brief Ask Atlas Manager to add a glyph
    *
    * @param[in] glyph glyph to add to an atlas
+   * @param[in] outlineWidth the outline width of the glyph
    * @param[in] bitmap bitmap to use for glyph addition
    * @param[out] slot information returned by atlas manager for addition
    */
   void Add( const Text::GlyphInfo& glyph,
+            const uint32_t outlineWidth,
             const PixelData& bitmap,
             AtlasManager::AtlasSlot& slot );
 
@@ -103,12 +105,14 @@ public:
    *
    * @param[in] fontId The font that this glyph comes from
    * @param[in] index The GlyphIndex of this glyph
+   * @param[in] outlineWidth The outline width of this glyph
    * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
    *
    * @return Whether glyph is cached or not ?
    */
   bool IsCached( Text::FontId fontId,
                  Text::GlyphIndex index,
+                 uint32_t outlineWidth,
                  AtlasManager::AtlasSlot& slot );
 
   /**
@@ -160,9 +164,10 @@ public:
    *
    * @param[in] fontId The font this image came from
    * @param[in] index The index of the glyph
+   * @param[in] outlineWidth The outline width of the glyph
    * @param[in] delta The adjustment to make to the reference count
    */
-  void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
+  void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta );
 
 private:
 
index 62865d6..03d02f5 100644 (file)
@@ -94,7 +94,7 @@ const float HALF( 0.5f );
 const float ONE( 1.0f );
 const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
 const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
-const int NO_OUTLINE( 0 );
+const uint32_t NO_OUTLINE = 0;
 }
 
 struct AtlasRenderer::Impl
@@ -172,12 +172,14 @@ struct AtlasRenderer::Impl
     TextCacheEntry()
     : mFontId( 0 ),
       mIndex( 0 ),
+      mOutlineWidth( 0 ),
       mImageId( 0 )
     {
     }
 
     FontId mFontId;
     Text::GlyphIndex mIndex;
+    uint32_t mOutlineWidth;
     uint32_t mImageId;
   };
 
@@ -211,6 +213,207 @@ struct AtlasRenderer::Impl
     return false;
   }
 
+  void CacheGlyph( const GlyphInfo& glyph, FontId lastFontId, uint32_t outline, AtlasManager::AtlasSlot& slot )
+  {
+    const bool glyphNotCached = !mGlyphManager.IsCached( glyph.fontId, glyph.index, outline, slot );  // Check FontGlyphRecord vector for entry with glyph index and fontId
+
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AddGlyphs fontID[%u] glyphIndex[%u] [%s]\n", glyph.fontId, glyph.index, (glyphNotCached)?"not cached":"cached" );
+
+    if( glyphNotCached )
+    {
+      MaxBlockSize& blockSize = mBlockSizes[0u];
+
+      if ( lastFontId != glyph.fontId )
+      {
+        uint32_t index = 0u;
+        // Looks through all stored block sizes until finds the one which mataches required glyph font it.  Ensures new atlas block size will match existing for same font id.
+        // CalculateBlocksSize() above ensures a block size entry exists.
+        for( std::vector<MaxBlockSize>::const_iterator it = mBlockSizes.begin(),
+               endIt = mBlockSizes.end();
+             it != endIt;
+             ++it, ++index )
+        {
+          const MaxBlockSize& blockSizeEntry = *it;
+          if( blockSizeEntry.mFontId == glyph.fontId )
+          {
+            blockSize = mBlockSizes[index];
+          }
+        }
+      }
+
+      // Create a new image for the glyph
+      PixelData bitmap;
+
+      // Whether the glyph is an outline.
+      const bool isOutline = 0u != outline;
+
+      // Whether the current glyph is a color one.
+      const bool isColorGlyph = mFontClient.IsColorGlyph( glyph.fontId, glyph.index );
+
+      if( !isOutline || ( isOutline && !isColorGlyph) )
+      {
+        // Retrieve the emoji's bitmap.
+        TextAbstraction::FontClient::GlyphBufferData glyphBufferData;
+        glyphBufferData.width = isColorGlyph ? glyph.width : 0;   // Desired width and height.
+        glyphBufferData.height = isColorGlyph ? glyph.height : 0;
+
+        mFontClient.CreateBitmap( glyph.fontId,
+                                  glyph.index,
+                                  glyphBufferData,
+                                  outline );
+
+        // Create the pixel data.
+        bitmap = PixelData::New( glyphBufferData.buffer,
+                                 glyphBufferData.width * glyphBufferData.height * GetBytesPerPixel( glyphBufferData.format ),
+                                 glyphBufferData.width,
+                                 glyphBufferData.height,
+                                 glyphBufferData.format,
+                                 PixelData::DELETE_ARRAY );
+
+        if( bitmap )
+        {
+          // Ensure that the next image will fit into the current block size
+          if( bitmap.GetWidth() > blockSize.mNeededBlockWidth )
+          {
+            blockSize.mNeededBlockWidth = bitmap.GetWidth();
+          }
+
+          if( bitmap.GetHeight() > blockSize.mNeededBlockHeight )
+          {
+            blockSize.mNeededBlockHeight = bitmap.GetHeight();
+          }
+
+          // If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
+
+          // Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
+          mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
+                                         DEFAULT_ATLAS_HEIGHT,
+                                         blockSize.mNeededBlockWidth,
+                                         blockSize.mNeededBlockHeight );
+
+          // Locate a new slot for our glyph
+          mGlyphManager.Add( glyph, outline, bitmap, slot ); // slot will be 0 is glyph not added
+        }
+      }
+    }
+    else
+    {
+      // We have 2+ copies of the same glyph
+      mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, outline, 1 ); //increment
+    }
+  }
+
+  void GenerateMesh( const GlyphInfo& glyph,
+                     const Vector2& position,
+                     const Vector4& color,
+                     uint32_t outline,
+                     AtlasManager::AtlasSlot& slot,
+                     bool underlineGlyph,
+                     float currentUnderlinePosition,
+                     float currentUnderlineThickness,
+                     std::vector<MeshRecord>& meshContainer,
+                     Vector<TextCacheEntry>& newTextCache,
+                     Vector<Extent>& extents )
+  {
+    // Generate mesh data for this quad, plugging in our supplied position
+    AtlasManager::Mesh2D newMesh;
+    mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
+
+    TextCacheEntry textCacheEntry;
+    textCacheEntry.mFontId = glyph.fontId;
+    textCacheEntry.mImageId = slot.mImageId;
+    textCacheEntry.mIndex = glyph.index;
+    textCacheEntry.mOutlineWidth = outline;
+
+    newTextCache.PushBack( textCacheEntry );
+
+    AtlasManager::Vertex2D* verticesBuffer = newMesh.mVertices.Begin();
+
+    for( unsigned int index = 0u, size = newMesh.mVertices.Count();
+         index < size;
+         ++index )
+    {
+      AtlasManager::Vertex2D& vertex = *( verticesBuffer + index );
+
+      // Set the color of the vertex.
+      vertex.mColor = color;
+    }
+
+    // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
+    StitchTextMesh( meshContainer,
+                    newMesh,
+                    extents,
+                    position.y + glyph.yBearing,
+                    underlineGlyph,
+                    currentUnderlinePosition,
+                    currentUnderlineThickness,
+                    slot );
+  }
+
+  void CreateActors( const std::vector<MeshRecord>& meshContainer,
+                     const Size& textSize,
+                     const Vector4& color,
+                     const Vector4& shadowColor,
+                     const Vector2& shadowOffset,
+                     Actor textControl,
+                     Property::Index animatablePropertyIndex,
+                     bool drawShadow )
+  {
+    if( !mActor )
+    {
+      // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues.
+      mActor = Actor::New();
+      mActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+      mActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+      mActor.SetSize( textSize );
+      mActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
+    }
+
+    for( std::vector< MeshRecord >::const_iterator it = meshContainer.begin(),
+           endIt = meshContainer.end();
+         it != endIt; ++it )
+    {
+      const MeshRecord& meshRecord = *it;
+
+      Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, color, meshRecord, textSize, STYLE_NORMAL );
+
+      // Whether the actor has renderers.
+      const bool hasRenderer = actor.GetRendererCount() > 0u;
+
+      // Create an effect if necessary
+      if( hasRenderer &&
+          drawShadow )
+      {
+        // Change the color of the vertices.
+        for( Vector<AtlasManager::Vertex2D>::Iterator vIt =  meshRecord.mMesh.mVertices.Begin(),
+               vEndIt = meshRecord.mMesh.mVertices.End();
+             vIt != vEndIt;
+             ++vIt )
+        {
+          AtlasManager::Vertex2D& vertex = *vIt;
+
+          vertex.mColor = shadowColor;
+        }
+
+        Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, color, meshRecord, textSize, STYLE_DROP_SHADOW );
+#if defined(DEBUG_ENABLED)
+        shadowActor.SetName( "Text Shadow renderable actor" );
+#endif
+        // Offset shadow in x and y
+        shadowActor.RegisterProperty("uOffset", shadowOffset );
+        Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
+        int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
+        renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
+        mActor.Add( shadowActor );
+      }
+
+      if( hasRenderer )
+      {
+        mActor.Add( actor );
+      }
+    }
+  }
+
   void AddGlyphs( Text::ViewInterface& view,
                   Actor textControl,
                   Property::Index animatablePropertyIndex,
@@ -223,18 +426,28 @@ struct AtlasRenderer::Impl
                   float minLineOffset )
   {
     AtlasManager::AtlasSlot slot;
+    slot.mImageId = 0u;
+    slot.mAtlasId = 0u;
+
+    AtlasManager::AtlasSlot slotOutline;
+    slotOutline.mImageId = 0u;
+    slotOutline.mAtlasId = 0u;
+
     std::vector< MeshRecord > meshContainer;
+    std::vector< MeshRecord > meshContainerOutline;
     Vector< Extent > extents;
-    TextCacheEntry textCacheEntry;
     mDepth = depth;
 
     const Vector2& textSize( view.GetLayoutSize() );
     const Vector2 halfTextSize( textSize * 0.5f );
     const Vector2& shadowOffset( view.GetShadowOffset() );
     const Vector4& shadowColor( view.GetShadowColor() );
-    const bool underlineEnabled( view.IsUnderlineEnabled() );
+    const bool underlineEnabled = view.IsUnderlineEnabled();
     const Vector4& underlineColor( view.GetUnderlineColor() );
-    const float underlineHeight( view.GetUnderlineHeight() );
+    const float underlineHeight = view.GetUnderlineHeight();
+    const unsigned int outlineWidth = view.GetOutlineWidth();
+    const Vector4& outlineColor( view.GetOutlineColor() );
+    const bool isOutline = 0u != outlineWidth;
 
     const bool useDefaultColor = ( NULL == colorsBuffer );
 
@@ -250,7 +463,6 @@ struct AtlasRenderer::Impl
 
     float currentUnderlinePosition = ZERO;
     float currentUnderlineThickness = underlineHeight;
-    uint32_t currentBlockSize = 0;
     FontId lastFontId = 0;
     FontId lastUnderlinedFontId = 0;
     Style style = STYLE_NORMAL;
@@ -271,14 +483,14 @@ struct AtlasRenderer::Impl
     for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
     {
       const GlyphInfo& glyph = *( glyphsBuffer + i );
-      const bool underlineGlyph = underlineEnabled || IsGlyphUnderlined( i, underlineRuns );
-      thereAreUnderlinedGlyphs = thereAreUnderlinedGlyphs || underlineGlyph;
+      const bool isGlyphUnderlined = underlineEnabled || IsGlyphUnderlined( i, underlineRuns );
+      thereAreUnderlinedGlyphs = thereAreUnderlinedGlyphs || isGlyphUnderlined;
 
       // No operation for white space
       if( glyph.width && glyph.height )
       {
         // Are we still using the same fontId as previous
-        if( underlineGlyph && ( glyph.fontId != lastUnderlinedFontId ) )
+        if( isGlyphUnderlined && ( glyph.fontId != lastUnderlinedFontId ) )
         {
           // We need to fetch fresh font underline metrics
           FontMetrics fontMetrics;
@@ -316,85 +528,13 @@ struct AtlasRenderer::Impl
           lastUnderlinedFontId = glyph.fontId;
         } // underline
 
-        bool glyphNotCached = !mGlyphManager.IsCached( glyph.fontId, glyph.index, slot );  // Check FontGlyphRecord vector for entry with glyph index and fontId
-
-        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AddGlyphs fontID[%u] glyphIndex[%u] [%s]\n", glyph.fontId, glyph.index, (glyphNotCached)?"not cached":"cached" );
+        // Retrieves and caches the glyph's bitmap.
+        CacheGlyph( glyph, lastFontId, NO_OUTLINE, slot );
 
-        if( glyphNotCached )
+        // Retrieves and caches the outline glyph's bitmap.
+        if( isOutline )
         {
-          MaxBlockSize& blockSize = mBlockSizes[currentBlockSize];
-
-          if ( lastFontId != glyph.fontId )
-          {
-            uint32_t index = 0u;
-            // Looks through all stored block sizes until finds the one which mataches required glyph font it.  Ensures new atlas block size will match existing for same font id.
-            // CalculateBlocksSize() above ensures a block size entry exists.
-            for( std::vector<MaxBlockSize>::const_iterator it = mBlockSizes.begin(),
-                   endIt = mBlockSizes.end();
-                 it != endIt;
-                 ++it, ++index )
-            {
-              const MaxBlockSize& blockSizeEntry = *it;
-              if( blockSizeEntry.mFontId == glyph.fontId )
-              {
-                blockSize = mBlockSizes[index];
-              }
-            }
-          }
-
-          // Create a new image for the glyph
-          PixelData bitmap;
-
-          // Whether the current glyph is a color one.
-          const bool isColorGlyph = mFontClient.IsColorGlyph( glyph.fontId, glyph.index );
-
-          // Retrieve the emoji's bitmap.
-          TextAbstraction::FontClient::GlyphBufferData glyphBufferData;
-          glyphBufferData.width = isColorGlyph ? glyph.width : 0;   // Desired width and height.
-          glyphBufferData.height = isColorGlyph ? glyph.height : 0;
-
-          mFontClient.CreateBitmap( glyph.fontId,
-                                    glyph.index,
-                                    glyphBufferData,
-                                    NO_OUTLINE );
-
-          // Create the pixel data.
-          bitmap = PixelData::New( glyphBufferData.buffer,
-                                   glyph.width * glyph.height * GetBytesPerPixel( glyphBufferData.format ),
-                                   glyph.width,
-                                   glyph.height,
-                                   glyphBufferData.format,
-                                   PixelData::DELETE_ARRAY );
-
-          if( bitmap )
-          {
-            // Ensure that the next image will fit into the current block size
-            if( bitmap.GetWidth() > blockSize.mNeededBlockWidth )
-            {
-              blockSize.mNeededBlockWidth = bitmap.GetWidth();
-            }
-
-            if( bitmap.GetHeight() > blockSize.mNeededBlockHeight )
-            {
-              blockSize.mNeededBlockHeight = bitmap.GetHeight();
-            }
-
-            // If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
-
-            // Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
-            mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
-                                           DEFAULT_ATLAS_HEIGHT,
-                                           blockSize.mNeededBlockWidth,
-                                           blockSize.mNeededBlockHeight );
-
-            // Locate a new slot for our glyph
-            mGlyphManager.Add( glyph, bitmap, slot ); // slot will be 0 is glyph not added
-          }
-        }
-        else
-        {
-          // We have 2+ copies of the same glyph
-          mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, 1/*increment*/ );
+          CacheGlyph( glyph, lastFontId, outlineWidth, slotOutline );
         }
 
         // Move the origin (0,0) of the mesh to the center of the actor
@@ -402,42 +542,47 @@ struct AtlasRenderer::Impl
 
         if ( 0u != slot.mImageId ) // invalid slot id, glyph has failed to be added to atlas
         {
-          // Generate mesh data for this quad, plugging in our supplied position
-          AtlasManager::Mesh2D newMesh;
-          mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
-          textCacheEntry.mFontId = glyph.fontId;
-          textCacheEntry.mImageId = slot.mImageId;
-          textCacheEntry.mIndex = glyph.index;
-          newTextCache.PushBack( textCacheEntry );
-
-          AtlasManager::Vertex2D* verticesBuffer = newMesh.mVertices.Begin();
+          Vector2 positionPlusOutlineOffset = position;
+          if( isOutline )
+          {
+            // Add an offset to the text.
+            const float outlineWidthOffset = static_cast<float>( outlineWidth );
+            positionPlusOutlineOffset += Vector2( outlineWidthOffset, outlineWidthOffset );
+          }
 
           // Get the color of the character.
           const ColorIndex colorIndex = useDefaultColor ? 0u : *( colorIndicesBuffer + i );
           const Vector4& color = ( useDefaultColor || ( 0u == colorIndex ) ) ? defaultColor : *( colorsBuffer + colorIndex - 1u );
 
-          for( unsigned int index = 0u, size = newMesh.mVertices.Count();
-               index < size;
-               ++index )
-          {
-            AtlasManager::Vertex2D& vertex = *( verticesBuffer + index );
-
-            // Set the color of the vertex.
-            vertex.mColor = color;
-          }
-
-          // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
-          StitchTextMesh( meshContainer,
-                          newMesh,
-                          extents,
-                          position.y + glyph.yBearing,
-                          underlineGlyph,
-                          currentUnderlinePosition,
-                          currentUnderlineThickness,
-                          slot );
+          GenerateMesh( glyph,
+                        positionPlusOutlineOffset,
+                        color,
+                        NO_OUTLINE,
+                        slot,
+                        isGlyphUnderlined,
+                        currentUnderlinePosition,
+                        currentUnderlineThickness,
+                        meshContainer,
+                        newTextCache,
+                        extents);
 
           lastFontId = glyph.fontId; // Prevents searching for existing blocksizes when string of the same fontId.
         }
+
+        if( isOutline && ( 0u != slotOutline.mImageId ) ) // invalid slot id, glyph has failed to be added to atlas
+        {
+          GenerateMesh( glyph,
+                        position,
+                        outlineColor,
+                        outlineWidth,
+                        slotOutline,
+                        false,
+                        currentUnderlinePosition,
+                        currentUnderlineThickness,
+                        meshContainerOutline,
+                        newTextCache,
+                        extents);
+        }
       }
     } // glyphs
 
@@ -452,62 +597,36 @@ struct AtlasRenderer::Impl
     }
 
     // For each MeshData object, create a mesh actor and add to the renderable actor
-    if( !meshContainer.empty() )
+    bool isShadowDrawn = false;
+    if( !meshContainerOutline.empty() )
     {
-      if( !mActor )
-      {
-        // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues.
-        mActor = Actor::New();
-        mActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-        mActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-        mActor.SetSize( textSize );
-        mActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
-      }
-
-      for( std::vector< MeshRecord >::iterator it = meshContainer.begin(),
-              endIt = meshContainer.end();
-            it != endIt; ++it )
-      {
-        MeshRecord& meshRecord = *it;
-
-        Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_NORMAL );
-
-        // Whether the actor has renderers.
-        const bool hasRenderer = actor.GetRendererCount() > 0u;
-
-        // Create an effect if necessary
-        if( hasRenderer &&
-            ( style == STYLE_DROP_SHADOW ) )
-        {
-          // Change the color of the vertices.
-          for( Vector<AtlasManager::Vertex2D>::Iterator vIt =  meshRecord.mMesh.mVertices.Begin(),
-                 vEndIt = meshRecord.mMesh.mVertices.End();
-               vIt != vEndIt;
-               ++vIt )
-          {
-            AtlasManager::Vertex2D& vertex = *vIt;
-
-            vertex.mColor = shadowColor;
-          }
-
-          Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_DROP_SHADOW );
-#if defined(DEBUG_ENABLED)
-          shadowActor.SetName( "Text Shadow renderable actor" );
-#endif
-          // Offset shadow in x and y
-          shadowActor.RegisterProperty("uOffset", shadowOffset );
-          Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
-          int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
-          renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
-          mActor.Add( shadowActor );
-        }
+      const bool drawShadow = STYLE_DROP_SHADOW == style;
+      CreateActors( meshContainerOutline,
+                    textSize,
+                    outlineColor,
+                    shadowColor,
+                    shadowOffset,
+                    textControl,
+                    animatablePropertyIndex,
+                    drawShadow );
+
+      isShadowDrawn = drawShadow;
+    }
 
-        if( hasRenderer )
-        {
-          mActor.Add( actor );
-        }
-      }
+    // For each MeshData object, create a mesh actor and add to the renderable actor
+    if( !meshContainer.empty() )
+    {
+      const bool drawShadow = !isShadowDrawn && ( STYLE_DROP_SHADOW == style );
+      CreateActors( meshContainer,
+                    textSize,
+                    defaultColor,
+                    shadowColor,
+                    shadowOffset,
+                    textControl,
+                    animatablePropertyIndex,
+                    drawShadow );
     }
+
 #if defined(DEBUG_ENABLED)
     Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
     DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
@@ -536,7 +655,7 @@ struct AtlasRenderer::Impl
   {
     for( Vector< TextCacheEntry >::Iterator oldTextIter = mTextCache.Begin(); oldTextIter != mTextCache.End(); ++oldTextIter )
     {
-      mGlyphManager.AdjustReferenceCount( oldTextIter->mFontId, oldTextIter->mIndex, -1/*decrement*/ );
+      mGlyphManager.AdjustReferenceCount( oldTextIter->mFontId, oldTextIter->mIndex, oldTextIter->mOutlineWidth, -1/*decrement*/ );
     }
     mTextCache.Resize( 0 );
   }
@@ -611,6 +730,7 @@ struct AtlasRenderer::Impl
     actor.SetSize( actorSize );
     actor.RegisterProperty("uOffset", Vector2::ZERO );
     actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
+
     return actor;
   }
 
index dcd803c..314bc63 100755 (executable)
 #include <dali-toolkit/internal/text/rendering/text-typesetter.h>
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/text-abstraction/font-client.h>
 #include <memory.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/public-api/common/constants.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
 
 namespace Dali
 {
@@ -298,6 +299,29 @@ PixelData Typesetter::Render( const Vector2& size, RenderBehaviour behaviour, bo
     }
   }
 
+  // Calculate vertical line alignment
+  switch( mModel->GetVerticalLineAlignment() )
+  {
+    case DevelText::VerticalLineAlignment::TOP:
+    {
+      break;
+    }
+    case DevelText::VerticalLineAlignment::MIDDLE:
+    {
+      const auto& line = *mModel->GetLines();
+      penY -= line.descender;
+      penY += static_cast<int>(line.lineSpacing*0.5f + line.descender);
+      break;
+    }
+    case DevelText::VerticalLineAlignment::BOTTOM:
+    {
+      const auto& line = *mModel->GetLines();
+      const auto lineHeight = line.ascender + (-line.descender) + line.lineSpacing;
+      penY += static_cast<int>(lineHeight - (line.ascender - line.descender));
+      break;
+    }
+  }
+
   // Generate the image buffers of the text for each different style first,
   // then combine all of them together as one final image buffer. We try to
   // do all of these in CPU only, so that once the final texture is generated,
@@ -431,6 +455,12 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth
     // Increases the vertical offset with the line's ascender.
     glyphData.verticalOffset += static_cast<int>( line.ascender );
 
+    // Include line spacing after first line
+    if( lineIndex > 0u )
+    {
+      glyphData.verticalOffset += static_cast<int>( line.lineSpacing );
+    }
+
     // Retrieves the glyph's outline width
     float outlineWidth = mModel->GetOutlineWidth();
 
index 1721a1c..4d87891 100755 (executable)
@@ -71,6 +71,11 @@ VerticalAlignment::Type ViewModel::GetVerticalAlignment() const
   return mModel->GetVerticalAlignment();
 }
 
+DevelText::VerticalLineAlignment::Type ViewModel::GetVerticalLineAlignment() const
+{
+  return mModel->GetVerticalLineAlignment();
+}
+
 bool ViewModel::IsTextElideEnabled() const
 {
   return mModel->IsTextElideEnabled();
index 0c0bb01..46c618f 100755 (executable)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/text/text-enumerations.h>
 #include <dali-toolkit/internal/text/text-model-interface.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
 
 namespace Dali
 {
@@ -83,6 +84,11 @@ public:
   virtual Text::VerticalAlignment::Type GetVerticalAlignment() const;
 
   /**
+ * @copydoc ModelInterface::GetVerticalLineAlignment()
+ */
+  virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
+
+  /**
    * @copydoc ModelInterface::IsTextElideEnabled()
    */
   virtual bool IsTextElideEnabled() const;
index 874503d..57e51d1 100644 (file)
@@ -108,7 +108,8 @@ EventData::EventData( DecoratorPtr decorator )
   mPasswordInput( false ),
   mIsPlaceholderPixelSize( false ),
   mIsPlaceholderElideEnabled( false ),
-  mPlaceholderEllipsisFlag( false )
+  mPlaceholderEllipsisFlag( false ),
+  mShiftSelectionFlag( true )
 {
   mImfManager = ImfManager::Get();
 }
@@ -888,7 +889,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
       TextAbstraction::FontDescription defaultFontDescription;
       TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
 
-      if( IsShowingPlaceholderText() && ( NULL != mEventData->mPlaceholderFont ) )
+      if( IsShowingPlaceholderText() && mEventData && ( NULL != mEventData->mPlaceholderFont ) )
       {
         // If the placeholder font is set specifically, only placeholder font is changed.
         defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription;
@@ -1144,7 +1145,7 @@ float Controller::Impl::GetDefaultFontLineHeight()
 
 void Controller::Impl::OnCursorKeyEvent( const Event& event )
 {
-  if( NULL == mEventData )
+  if( NULL == mEventData || !IsShowingRealText() )
   {
     // Nothing to do if there is no text input.
     return;
@@ -1251,7 +1252,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
     mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
   }
 
-  if ( isShiftModifier && IsShowingRealText() )
+  if ( isShiftModifier && IsShowingRealText() && mEventData->mShiftSelectionFlag )
   {
     // Handle text selection
     bool selecting = false;
@@ -2291,7 +2292,7 @@ void Controller::Impl::RepositionSelectionHandles()
   const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() );
   highLightPosition.y = firstSelectionBoxLineInfo.lineOffset;
 
-  mEventData->mDecorator->SetHighLightBox( highLightPosition, highLightSize );
+  mEventData->mDecorator->SetHighLightBox( highLightPosition, highLightSize, static_cast<float>( mModel->GetOutlineWidth() ) );
 
   if( !mEventData->mDecorator->IsSmoothHandlePanEnabled() )
   {
@@ -2711,6 +2712,13 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
   Text::GetCursorPosition( parameters,
                            cursorInfo );
 
+  // Adds Outline offset.
+  const float outlineWidth = static_cast<float>( mModel->GetOutlineWidth() );
+  cursorInfo.primaryPosition.x += outlineWidth;
+  cursorInfo.primaryPosition.y += outlineWidth;
+  cursorInfo.secondaryPosition.x += outlineWidth;
+  cursorInfo.secondaryPosition.y += outlineWidth;
+
   if( isMultiLine )
   {
     // If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control.
index a5de151..47c9bc0 100644 (file)
@@ -162,6 +162,7 @@ struct EventData
   bool mIsPlaceholderPixelSize          : 1;   ///< True if the placeholder font size is set as pixel size.
   bool mIsPlaceholderElideEnabled       : 1;   ///< True if the placeholder text's elide is enabled.
   bool mPlaceholderEllipsisFlag         : 1;   ///< True if the text controller sets the placeholder ellipsis.
+  bool mShiftSelectionFlag              : 1;   ///< True if the text selection using Shift key is enabled.
 };
 
 struct ModifyEvent
index 15e7b8b..d454031 100755 (executable)
@@ -466,6 +466,16 @@ bool Controller::IsSelectionEnabled() const
   return mImpl->mEventData->mSelectionEnabled;
 }
 
+void Controller::SetShiftSelectionEnabled( bool enabled )
+{
+  mImpl->mEventData->mShiftSelectionFlag = enabled;
+}
+
+bool Controller::IsShiftSelectionEnabled() const
+{
+  return mImpl->mEventData->mShiftSelectionFlag;
+}
+
 // public : Update
 
 void Controller::SetText( const std::string& text )
@@ -1182,14 +1192,14 @@ const Vector4& Controller::GetOutlineColor() const
   return mImpl->mModel->mVisualModel->GetOutlineColor();
 }
 
-void Controller::SetOutlineWidth( float width )
+void Controller::SetOutlineWidth( unsigned int width )
 {
   mImpl->mModel->mVisualModel->SetOutlineWidth( width );
 
   mImpl->RequestRelayout();
 }
 
-float Controller::GetOutlineWidth() const
+unsigned int Controller::GetOutlineWidth() const
 {
   return mImpl->mModel->mVisualModel->GetOutlineWidth();
 }
@@ -1234,10 +1244,15 @@ const std::string& Controller::GetDefaultOutlineProperties() const
   return EMPTY_STRING;
 }
 
-void Controller::SetDefaultLineSpacing( float lineSpacing )
+bool Controller::SetDefaultLineSpacing( float lineSpacing )
 {
-  //TODO finish implementation
-  mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing );
+  if( std::abs(lineSpacing - mImpl->mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000 )
+  {
+    mImpl->mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
+    mImpl->mRecalculateNaturalSize = true;
+    return true;
+  }
+  return false;
 }
 
 float Controller::GetDefaultLineSpacing() const
@@ -2105,8 +2120,15 @@ void Controller::GetPlaceholderProperty( Property::Map& map )
 
 Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
 {
-  const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
-  if ( firstline && firstline->direction )
+  if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
+  {
+    return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
+  }
+
+  const Character character = mImpl->mModel->mLogicalModel->mText[0];
+  Script script = TextAbstraction::GetCharacterScript( character );
+
+  if( TextAbstraction::IsRightToLeftScript( script ) )
   {
     return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT;
   }
@@ -2114,6 +2136,16 @@ Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
   return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
 }
 
+Toolkit::DevelText::VerticalLineAlignment::Type Controller::GetVerticalLineAlignment() const
+{
+  return mImpl->mModel->GetVerticalLineAlignment();
+}
+
+void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment )
+{
+  mImpl->mModel->mVerticalLineAlignment = alignment;
+}
+
 // public : Relayout.
 
 Controller::UpdateTextType Controller::Relayout( const Size& size )
@@ -2744,7 +2776,17 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons
 
   if( retrieveText )
   {
-    mImpl->GetText( numberOfWhiteSpaces, text );
+    if( !mImpl->IsShowingPlaceholderText() )
+    {
+      // Retrieves the normal text string.
+      mImpl->GetText( numberOfWhiteSpaces, text );
+    }
+    else
+    {
+      // When the current text is Placeholder Text, the surrounding text should be empty string.
+      // It means DALi should send empty string ("") to IME.
+      text = "";
+    }
   }
 
   ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
@@ -3377,7 +3419,7 @@ bool Controller::DoRelayout( const Size& size,
     const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
     const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
     const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
-    float outlineWidth = mImpl->mModel->GetOutlineWidth();
+    const float outlineWidth = static_cast<float>( mImpl->mModel->GetOutlineWidth() );
 
     // Set the layout parameters.
     Layout::Parameters layoutParameters( size,
@@ -3704,7 +3746,7 @@ bool Controller::DeleteEvent( int keyCode )
                           1,
                           UPDATE_INPUT_STYLE );
   }
-  else if( ( mImpl->mEventData->mPrimaryCursorPosition >= 0 ) && ( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) )
+  else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE )
   {
     // Remove the character after the current cursor position
     removed = RemoveText( 0,
@@ -3843,6 +3885,7 @@ void Controller::ClearFontData()
   mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
                                                            VALIDATE_FONTS            |
                                                            SHAPE_TEXT                |
+                                                           BIDI_INFO                 |
                                                            GET_GLYPH_METRICS         |
                                                            LAYOUT                    |
                                                            UPDATE_LAYOUT_SIZE        |
index 07d91be..defb8b5 100755 (executable)
@@ -394,6 +394,18 @@ public: // Configure the text controller.
   bool IsSelectionEnabled() const;
 
   /**
+   * @brief Enable or disable the text selection using Shift key.
+   * @param enabled Whether to enable the text selection using Shift key
+   */
+  void SetShiftSelectionEnabled( bool enabled );
+
+  /**
+   * @brief Whether the text selection using Shift key is enabled or not.
+   * @return True if the text selection using Shift key is enabled
+   */
+  bool IsShiftSelectionEnabled() const;
+
+  /**
    * @brief Sets input type to password
    *
    * @note The string is displayed hidden character
@@ -834,14 +846,14 @@ public: // Default style & Input style
    *
    * @param[in] width The width in pixels of the outline, 0 indicates no outline
    */
-  void SetOutlineWidth( float width );
+  void SetOutlineWidth( unsigned int width );
 
   /**
    * @brief Retrieves the width of an outline
    *
    * @return The width of the outline.
    */
-  float GetOutlineWidth() const;
+  unsigned int GetOutlineWidth() const;
 
   /**
    * @brief Sets the emboss's properties string.
@@ -879,8 +891,10 @@ public: // Default style & Input style
    * @brief Sets the default line spacing.
    *
    * @param[in] lineSpacing The line spacing.
+   *
+   * @return True if lineSpacing has been updated, false otherwise
    */
-  void SetDefaultLineSpacing( float lineSpacing );
+  bool SetDefaultLineSpacing( float lineSpacing );
 
   /**
    * @brief Retrieves the default line spacing.
@@ -1162,6 +1176,18 @@ public: // Queries & retrieves.
    */
   Toolkit::DevelText::TextDirection::Type GetTextDirection();
 
+  /**
+   * @brief Retrieves vertical line alignment
+   * @return The vertical line alignment
+   */
+  Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
+
+  /**
+   * @brief Sets vertical line alignment
+   * @param[in] alignment The vertical line alignment for the text
+   */
+  void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
+
 public: // Relayout.
 
   /**
index 7c08ebe..d8d35de 100755 (executable)
@@ -125,26 +125,45 @@ bool ParseUnderlineProperties( const Property::Map& underlinePropertiesMap,
     if( ENABLE_KEY == valueGet.first.stringKey )
     {
       /// Enable key.
-      const std::string enableStr = valueGet.second.Get<std::string>();
-      enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
+      if( valueGet.second.GetType() == Dali::Property::STRING )
+      {
+        const std::string enableStr = valueGet.second.Get<std::string>();
+        enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
+      }
+      else
+      {
+        enabled = valueGet.second.Get<bool>();
+      }
     }
     else if( COLOR_KEY == valueGet.first.stringKey )
     {
       /// Color key.
       colorDefined = true;
 
-      const std::string colorStr = valueGet.second.Get<std::string>();
-
-      Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+      if( valueGet.second.GetType() == Dali::Property::STRING )
+      {
+        const std::string colorStr = valueGet.second.Get<std::string>();
+        Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+      }
+      else
+      {
+        color = valueGet.second.Get<Vector4>();
+      }
     }
     else if( HEIGHT_KEY == valueGet.first.stringKey )
     {
       /// Height key.
       heightDefined = true;
 
-      const std::string heightStr = valueGet.second.Get<std::string>();
-
-      height = StringToFloat( heightStr.c_str() );
+      if( valueGet.second.GetType() == Dali::Property::STRING )
+      {
+        const std::string heightStr = valueGet.second.Get<std::string>();
+        height = StringToFloat( heightStr.c_str() );
+      }
+      else
+      {
+        height = valueGet.second.Get<float>();
+      }
     }
   }
 
@@ -155,7 +174,7 @@ bool ParseOutlineProperties( const Property::Map& underlinePropertiesMap,
                                bool& colorDefined,
                                Vector4& color,
                                bool& widthDefined,
-                               float& width )
+                               unsigned int& width )
 {
   const unsigned int numberOfItems = underlinePropertiesMap.Count();
 
@@ -174,7 +193,7 @@ bool ParseOutlineProperties( const Property::Map& underlinePropertiesMap,
     {
       /// Width key.
       widthDefined = true;
-      width = valueGet.second.Get<float>();
+      width = static_cast<unsigned int>( valueGet.second.Get<float>() );
     }
   }
 
@@ -218,7 +237,7 @@ bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& va
                                               heightDefined,
                                               height );
 
-            controller->UnderlineSetByString( !empty);
+            controller->UnderlineSetByString( !empty );
           }
         }
         else
@@ -546,7 +565,7 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu
         bool colorDefined = false;
         Vector4 color;
         bool widthDefined = false;
-        float width = 0.f;
+        unsigned int width = 0u;
 
         bool empty = true;
 
@@ -581,7 +600,7 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu
             update = true;
           }
 
-          if( widthDefined && ( fabsf( controller->GetOutlineWidth() - width ) > Math::MACHINE_EPSILON_1000 ) )
+          if( widthDefined && ( controller->GetOutlineWidth() != width ) )
           {
             controller->SetOutlineWidth( width );
             update = true;
@@ -590,9 +609,9 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu
         else
         {
           // Disable outline
-          if( fabsf( controller->GetOutlineWidth() ) > Math::MACHINE_EPSILON_1000 )
+          if( 0u != controller->GetOutlineWidth() )
           {
-            controller->SetOutlineWidth( 0.0f );
+            controller->SetOutlineWidth( 0u );
             update = true;
           }
         }
@@ -627,17 +646,11 @@ void GetOutlineProperties( ControllerPtr controller, Property::Value& value, Eff
         else
         {
           const Vector4& color = controller->GetOutlineColor();
-          const float width = controller->GetOutlineWidth();
+          const unsigned int width = controller->GetOutlineWidth();
 
           Property::Map map;
-
-          std::string colorStr;
-          Vector4ToColorString( color, colorStr );
-          map.Insert( COLOR_KEY, colorStr );
-
-          std::string widthStr;
-          FloatToString( width, widthStr );
-          map.Insert( WIDTH_KEY, widthStr );
+          map.Insert( COLOR_KEY, color );
+          map.Insert( WIDTH_KEY, static_cast<int>( width ) );
 
           value = map;
 
index 521f52c..e2b0f0c 100755 (executable)
@@ -84,7 +84,7 @@ bool ParseOutlineProperties( const Property::Map& outlineProperties,
                                bool& colorDefined,
                                Vector4& color,
                                bool& widthDefined,
-                               float& width );
+                               unsigned int& width );
 
 /**
  * @brief Sets the underline properties.
index ca575ce..ab21d62 100755 (executable)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/internal/text/line-run.h>
 #include <dali-toolkit/internal/text/script-run.h>
 #include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
 
 namespace Dali
 {
@@ -84,6 +85,13 @@ public:
   virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
 
   /**
+   * @brief Retrieves the text's vertical line alignment.
+   *
+   * @return The vertical line alignment.
+   */
+  virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
+
+  /**
    * @brief Whether the text elide property is enabled.
    *
    * @return @e true if the text elide property is enabled, @e false otherwise.
index 7b6536d..7f23aac 100755 (executable)
@@ -57,6 +57,11 @@ VerticalAlignment::Type Model::GetVerticalAlignment() const
   return mVerticalAlignment;
 }
 
+DevelText::VerticalLineAlignment::Type Model::GetVerticalLineAlignment() const
+{
+  return mVerticalLineAlignment;
+}
+
 bool Model::IsTextElideEnabled() const
 {
   return mElideEnabled;
@@ -169,6 +174,7 @@ Model::Model()
   mScrollPositionLast(),
   mHorizontalAlignment( Text::HorizontalAlignment::BEGIN ),
   mVerticalAlignment( Text::VerticalAlignment::TOP ),
+  mVerticalLineAlignment( DevelText::VerticalLineAlignment::TOP ),
   mLineWrapMode( Text::LineWrap::WORD ),
   mAlignmentOffset( 0.0f ),
   mElideEnabled( false )
index da7fd24..9422996 100755 (executable)
@@ -84,6 +84,11 @@ public:
   virtual VerticalAlignment::Type GetVerticalAlignment() const;
 
   /**
+   * @copydoc ModelInterface::GetVerticalLineAlignment()
+   */
+  virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
+
+  /**
    * @copydoc ModelInterface::IsTextElideEnabled()
    */
   virtual bool IsTextElideEnabled() const;
@@ -215,13 +220,14 @@ public:
    * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
    * Typically this will have a negative value with scrolling occurs.
    */
-  Vector2                            mScrollPosition;      ///< The text is offset by this position when scrolling.
-  Vector2                            mScrollPositionLast;  ///< The last offset value of mScrollPosition
-  HorizontalAlignment::Type          mHorizontalAlignment; ///< The layout's horizontal alignment.
-  VerticalAlignment::Type            mVerticalAlignment;   ///< The layout's vertical alignment.
-  Text::LineWrap::Mode               mLineWrapMode;        ///< The text wrap mode
-  float                              mAlignmentOffset;     ///< The alignment offset.
-  bool                               mElideEnabled:1;      ///< Whether the text's elide is enabled.
+  Vector2                                   mScrollPosition;        ///< The text is offset by this position when scrolling.
+  Vector2                                   mScrollPositionLast;    ///< The last offset value of mScrollPosition
+  HorizontalAlignment::Type                 mHorizontalAlignment;   ///< The layout's horizontal alignment.
+  VerticalAlignment::Type                   mVerticalAlignment;     ///< The layout's vertical alignment.
+  DevelText::VerticalLineAlignment::Type    mVerticalLineAlignment; ///< The layout's vertical line alignment.
+  Text::LineWrap::Mode                      mLineWrapMode;          ///< The text wrap mode
+  float                                     mAlignmentOffset;       ///< The alignment offset.
+  bool                                      mElideEnabled:1;        ///< Whether the text's elide is enabled.
 };
 
 } // namespace Text
index f8089a2..11ac3e4 100644 (file)
@@ -260,7 +260,7 @@ TextScroller::~TextScroller()
 {
 }
 
-void TextScroller::SetParameters( Actor scrollingTextActor, Renderer renderer, TextureSet textureSet, const Size& controlSize, const Size& textureSize, const float wrapGap, CharacterDirection direction, HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment )
+void TextScroller::SetParameters( Actor scrollingTextActor, Renderer renderer, TextureSet textureSet, const Size& controlSize, const Size& textureSize, const float wrapGap, CharacterDirection direction, HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment, bool isTextElided )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters controlSize[%f,%f] textureSize[%f,%f] direction[%d]\n",
                  controlSize.x, controlSize.y, textureSize.x, textureSize.y, direction );
@@ -298,7 +298,17 @@ void TextScroller::SetParameters( Actor scrollingTextActor, Renderer renderer, T
 
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters wrapGap[%f]\n", wrapGap );
 
-  const float horizontalAlign = HORIZONTAL_ALIGNMENT_TABLE[ horizontalAlignment ][ direction ];
+  float horizontalAlign;
+
+  if( isTextElided )
+  {
+    // if Text is elided, scroll should start at the begin of text.
+    horizontalAlign = HORIZONTAL_ALIGNMENT_TABLE[HorizontalAlignment::BEGIN][ direction ];
+  }
+  else
+  {
+    horizontalAlign = HORIZONTAL_ALIGNMENT_TABLE[ horizontalAlignment ][ direction ];
+  }
   const float verticalAlign = VERTICAL_ALIGNMENT_TABLE[ verticalAlignment ];
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters horizontalAlign[%f], verticalAlign[%f]\n", horizontalAlign, verticalAlign );
 
index a7a6410..4000023 100644 (file)
@@ -70,8 +70,9 @@ public:
    * @param[in] direction text direction true for right to left text
    * @param[in] horizontalAlignment horizontal alignment of the text
    * @param[in] verticalAlignment vertical alignment of the text
+   * @param[in] isTextElided whether text is elided or not
    */
-  void SetParameters( Actor scrollingTextActor, Dali::Renderer renderer, TextureSet textureSet, const Size& controlSize, const Size& textureSize, const float wrapGap, CharacterDirection direction, HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment );
+  void SetParameters( Actor scrollingTextActor, Dali::Renderer renderer, TextureSet textureSet, const Size& controlSize, const Size& textureSize, const float wrapGap, CharacterDirection direction, HorizontalAlignment::Type horizontalAlignment, VerticalAlignment::Type verticalAlignment, bool isTextElided );
 
   /**
    * @brief Set the gap distance to elapse before the text wraps around
index efa88ad..96f9005 100644 (file)
@@ -172,6 +172,21 @@ public:
   virtual void GetUnderlineRuns( GlyphRun* underlineRuns,
                                  UnderlineRunIndex index,
                                  Length numberOfRuns ) const = 0;
+
+  /**
+   * @brief Retrieve the outline color.
+   *
+   * @return The outline color.
+   */
+  virtual const Vector4& GetOutlineColor() const = 0;
+
+  /**
+   * @brief Retrieves the width of an outline
+   *
+   * @return The width of the outline.
+   */
+  virtual unsigned int GetOutlineWidth() const = 0;
+
 };
 
 } // namespace Text
index 9e8d0be..62c0008 100644 (file)
@@ -402,6 +402,24 @@ void View::GetUnderlineRuns( GlyphRun* underlineRuns,
   }
 }
 
+const Vector4& View::GetOutlineColor() const
+{
+  if( mImpl->mVisualModel )
+  {
+    return mImpl->mVisualModel->GetOutlineColor();
+  }
+  return Vector4::ZERO;
+}
+
+unsigned int View::GetOutlineWidth() const
+{
+  if( mImpl->mVisualModel )
+  {
+    return mImpl->mVisualModel->GetOutlineWidth();
+  }
+  return 0u;
+}
+
 } // namespace Text
 
 } // namespace Toolkit
index d494d2b..51426de 100644 (file)
@@ -131,6 +131,16 @@ public:
                                  UnderlineRunIndex index,
                                  Length numberOfRuns ) const;
 
+  /**
+   * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineColor()
+   */
+  virtual const Vector4& GetOutlineColor() const;
+
+  /**
+   * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineWidth()
+   */
+  virtual unsigned int GetOutlineWidth() const;
+
 private:
 
   // Undefined
index 9caa523..5373a6a 100755 (executable)
@@ -370,7 +370,7 @@ void VisualModel::SetUnderlineHeight( float height )
   mUnderlineHeight = height;
 }
 
-void VisualModel::SetOutlineWidth( float width )
+void VisualModel::SetOutlineWidth( unsigned int width )
 {
   mOutlineWidth = width;
 }
@@ -415,7 +415,7 @@ float VisualModel::GetUnderlineHeight() const
   return mUnderlineHeight;
 }
 
-float VisualModel::GetOutlineWidth() const
+unsigned int VisualModel::GetOutlineWidth() const
 {
   return mOutlineWidth;
 }
@@ -449,7 +449,7 @@ VisualModel::VisualModel()
   mControlSize(),
   mShadowOffset(),
   mUnderlineHeight( 0.0f ),
-  mOutlineWidth( 0.0f ),
+  mOutlineWidth( 0u ),
   mShadowBlurRadius( 0.0f ),
   mNaturalSize(),
   mLayoutSize(),
index 28d2269..24be0c7 100755 (executable)
@@ -320,14 +320,14 @@ public:
    *
    * @param[in] width The width in pixels of the outline, 0 indicates no outline
    */
-  void SetOutlineWidth( float width );
+  void SetOutlineWidth( unsigned int width );
 
   /**
    * @brief Retrieves the width of an outline
    *
    * @return The width of the outline.
    */
-  float GetOutlineWidth() const;
+  unsigned int GetOutlineWidth() const;
 
 protected:
 
@@ -369,7 +369,7 @@ public:
   Size                   mControlSize;          ///< The size of the UI control.
   Vector2                mShadowOffset;         ///< Offset for drop shadow, 0 indicates no shadow
   float                  mUnderlineHeight;      ///< Fixed height for underline to override font metrics.
-  float                  mOutlineWidth;         ///< Width of outline.
+  unsigned int           mOutlineWidth;         ///< Width of outline.
   float                  mShadowBlurRadius;     ///< Blur radius of shadow, 0 indicates no blur.
 
 private:
index f20286c..78ed950 100755 (executable)
@@ -19,6 +19,7 @@
 
 //INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/visuals/animated-gradient-visual-properties-devel.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
index 2d8008f..2058e1b 100644 (file)
@@ -25,6 +25,7 @@
 //INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
@@ -88,7 +89,8 @@ ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache, const Propert
 }
 
 ColorVisual::ColorVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache )
+: Visual::Base( factoryCache ),
+  mRenderIfTransparent( false )
 {
 }
 
@@ -122,13 +124,27 @@ void ColorVisual::DoSetProperties( const Property::Map& propertyMap )
       DALI_LOG_ERROR("ColorVisual: mixColor property has incorrect type\n");
     }
   }
+
+  Property::Value* renderIfTransparentValue = propertyMap.Find( Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT, RENDER_IF_TRANSPARENT_NAME );
+  if( renderIfTransparentValue )
+  {
+    if( ! renderIfTransparentValue->Get( mRenderIfTransparent ) )
+    {
+      DALI_LOG_ERROR( "ColorVisual: renderIfTransparent property has incorrect type: %d\n", renderIfTransparentValue->GetType() );
+    }
+  }
 }
 
 void ColorVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
 
-  actor.AddRenderer( mImpl->mRenderer );
+  // Only add the renderer if it's not fully transparent
+  // We cannot avoid creating a renderer as it's used in the base class
+  if( mRenderIfTransparent || mImpl->mMixColor.a > 0.0f )
+  {
+    actor.AddRenderer( mImpl->mRenderer );
+  }
 
   // Color Visual generated and ready to display
   ResourceReady( Toolkit::Visual::ResourceStatus::READY );
@@ -139,6 +155,7 @@ void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
   map.Clear();
   map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR );
   map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor );
+  map.Insert( Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT, mRenderIfTransparent );
 }
 
 void ColorVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
index 939d40e..4b6dca6 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -112,6 +112,10 @@ private:
 
   // Undefined
   ColorVisual& operator=( const ColorVisual& colorRenderer );
+
+private:
+
+  bool mRenderIfTransparent; ///< Whether we should render even if the mix-color is transparent.
 };
 
 } // namespace Internal
index 8845541..51924f0 100644 (file)
@@ -94,15 +94,15 @@ DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
 
 // load policies
 DALI_ENUM_TO_STRING_TABLE_BEGIN( LOAD_POLICY )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::LoadPolicy, IMMEDIATE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::LoadPolicy, ATTACHED )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::ImageVisual::LoadPolicy, IMMEDIATE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::ImageVisual::LoadPolicy, ATTACHED )
 DALI_ENUM_TO_STRING_TABLE_END( LOAD_POLICY )
 
 // release policies
 DALI_ENUM_TO_STRING_TABLE_BEGIN( RELEASE_POLICY )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, DETACHED )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, DESTROYED )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, NEVER )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::ImageVisual::ReleasePolicy, DETACHED )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::ImageVisual::ReleasePolicy, DESTROYED )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::ImageVisual::ReleasePolicy, NEVER )
 DALI_ENUM_TO_STRING_TABLE_END( RELEASE_POLICY )
 
 const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
@@ -282,8 +282,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
   mSamplingMode( samplingMode ),
   mWrapModeU( WrapMode::DEFAULT ),
   mWrapModeV( WrapMode::DEFAULT ),
-  mLoadPolicy( DevelImageVisual::LoadPolicy::ATTACHED ),
-  mReleasePolicy( DevelImageVisual::ReleasePolicy::DETACHED ),
+  mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
+  mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED ),
   mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
   mAttemptAtlasing( false ),
   mLoading( false ),
@@ -305,8 +305,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image )
   mSamplingMode( SamplingMode::DEFAULT ),
   mWrapModeU( WrapMode::DEFAULT ),
   mWrapModeV( WrapMode::DEFAULT ),
-  mLoadPolicy( DevelImageVisual::LoadPolicy::ATTACHED ),
-  mReleasePolicy( DevelImageVisual::ReleasePolicy::DESTROYED ),
+  mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
+  mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DESTROYED ),
   mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
   mAttemptAtlasing( false ),
   mLoading( false ),
@@ -331,7 +331,7 @@ ImageVisual::~ImageVisual()
     }
 
     // ImageVisual destroyed so remove texture unless ReleasePolicy is set to never release
-    if( ( mTextureId != TextureManager::INVALID_TEXTURE_ID  ) && ( mReleasePolicy != DevelImageVisual::ReleasePolicy::NEVER ) )
+    if( ( mTextureId != TextureManager::INVALID_TEXTURE_ID  ) && ( mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER ) )
     {
       RemoveTexture();
     }
@@ -400,20 +400,20 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
       }
       else if ( keyValue.first == LOAD_POLICY_NAME )
       {
-        DoSetProperty( Toolkit::DevelImageVisual::Property::LOAD_POLICY, keyValue.second );
+        DoSetProperty( Toolkit::ImageVisual::Property::LOAD_POLICY, keyValue.second );
       }
       else if( keyValue.first == RELEASE_POLICY_NAME )
       {
-        DoSetProperty( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, keyValue.second );
+        DoSetProperty( Toolkit::ImageVisual::Property::RELEASE_POLICY, keyValue.second );
       }
       else if( keyValue.first == ORIENTATION_CORRECTION_NAME )
       {
-        DoSetProperty( Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION, keyValue.second );
+        DoSetProperty( Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION, keyValue.second );
       }
     }
   }
   // Load image immediately if LOAD_POLICY requires it
-  if ( mLoadPolicy == DevelImageVisual::LoadPolicy::IMMEDIATE )
+  if ( mLoadPolicy == Toolkit::ImageVisual::LoadPolicy::IMMEDIATE )
   {
     auto attemptAtlasing = AttemptAtlasing();
     LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection,
@@ -554,22 +554,22 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v
       break;
     }
 
-    case Toolkit::DevelImageVisual::Property::RELEASE_POLICY:
+    case Toolkit::ImageVisual::Property::RELEASE_POLICY:
     {
       int releasePolicy;
       Scripting::GetEnumerationProperty( value, RELEASE_POLICY_TABLE, RELEASE_POLICY_TABLE_COUNT, releasePolicy );
-      mReleasePolicy = DevelImageVisual::ReleasePolicy::Type( releasePolicy );
+      mReleasePolicy = Toolkit::ImageVisual::ReleasePolicy::Type( releasePolicy );
       break;
     }
 
-    case Toolkit::DevelImageVisual::Property::LOAD_POLICY:
+    case Toolkit::ImageVisual::Property::LOAD_POLICY:
     {
       int loadPolicy;
       Scripting::GetEnumerationProperty( value, LOAD_POLICY_TABLE, LOAD_POLICY_TABLE_COUNT, loadPolicy );
-      mLoadPolicy = DevelImageVisual::LoadPolicy::Type( loadPolicy );
+      mLoadPolicy = Toolkit::ImageVisual::LoadPolicy::Type( loadPolicy );
       break;
     }
-    case Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION:
+    case Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION:
     {
       bool orientationCorrection( mOrientationCorrection );
       if( value.Get( orientationCorrection ) )
@@ -892,7 +892,7 @@ void ImageVisual::DoSetOffStage( Actor& actor )
 
   // Image release is dependent on the ReleasePolicy, renderer is destroyed.
   actor.RemoveRenderer( mImpl->mRenderer);
-  if( mReleasePolicy == DevelImageVisual::ReleasePolicy::DETACHED )
+  if( mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED )
   {
     RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
   }
@@ -948,9 +948,9 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
     map.Insert( Toolkit::ImageVisual::Property::CROP_TO_MASK, mMaskingData->mCropToMask );
   }
 
-  map.Insert( Toolkit::DevelImageVisual::Property::LOAD_POLICY, mLoadPolicy );
-  map.Insert( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, mReleasePolicy );
-  map.Insert( Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION, mOrientationCorrection );
+  map.Insert( Toolkit::ImageVisual::Property::LOAD_POLICY, mLoadPolicy );
+  map.Insert( Toolkit::ImageVisual::Property::RELEASE_POLICY, mReleasePolicy );
+  map.Insert( Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION, mOrientationCorrection );
 }
 
 void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
index 3108b55..d78ceca 100644 (file)
@@ -33,6 +33,7 @@
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
 namespace Dali
 {
@@ -369,8 +370,8 @@ private:
   Dali::SamplingMode::Type mSamplingMode:4;
   Dali::WrapMode::Type mWrapModeU:3;
   Dali::WrapMode::Type mWrapModeV:3;
-  DevelImageVisual::LoadPolicy::Type mLoadPolicy;
-  DevelImageVisual::ReleasePolicy::Type mReleasePolicy;
+  Dali::Toolkit::ImageVisual::LoadPolicy::Type mLoadPolicy;
+  Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
   Vector4 mAtlasRect;
   bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
   bool mLoading;  ///< True if the texture is still loading.
index f23f1ca..8bc050f 100644 (file)
@@ -79,10 +79,10 @@ std::size_t NPatchLoader::Load( const std::string& url, const Rect< int >& borde
     data->textureSet = mCache[ cachedIndex ]->textureSet;
 
     NinePatchImage::StretchRanges stretchRangesX;
-    stretchRangesX.PushBack( Uint16Pair( border.left, data->croppedWidth - border.right ) );
+    stretchRangesX.PushBack( Uint16Pair( border.left, ( (data->croppedWidth >= static_cast< unsigned int >( border.right )) ? data->croppedWidth - border.right : 0 ) ) );
 
     NinePatchImage::StretchRanges stretchRangesY;
-    stretchRangesY.PushBack( Uint16Pair( border.top, data->croppedHeight - border.bottom ) );
+    stretchRangesY.PushBack( Uint16Pair( border.top, ( (data->croppedHeight >= static_cast< unsigned int >( border.bottom )) ? data->croppedHeight - border.bottom : 0 ) ) );
 
     data->stretchPixelsX = stretchRangesX;
     data->stretchPixelsY = stretchRangesY;
@@ -137,10 +137,10 @@ std::size_t NPatchLoader::Load( const std::string& url, const Rect< int >& borde
       data->textureSet.SetTexture( 0u, texture );
 
       NinePatchImage::StretchRanges stretchRangesX;
-      stretchRangesX.PushBack( Uint16Pair( border.left, data->croppedWidth - border.right ) );
+      stretchRangesX.PushBack( Uint16Pair( border.left, ( (data->croppedWidth >= static_cast< unsigned int >( border.right )) ? data->croppedWidth - border.right : 0 ) ) );
 
       NinePatchImage::StretchRanges stretchRangesY;
-      stretchRangesY.PushBack( Uint16Pair( border.top, data->croppedHeight - border.bottom ) );
+      stretchRangesY.PushBack( Uint16Pair( border.top, ( (data->croppedHeight >= static_cast< unsigned int >( border.bottom )) ? data->croppedHeight - border.bottom : 0 ) ) );
 
       data->stretchPixelsX = stretchRangesX;
       data->stretchPixelsY = stretchRangesY;
index 33a4842..f61848c 100755 (executable)
@@ -56,6 +56,7 @@ const char * const AUXILIARY_IMAGE_ALPHA_NAME( "auxiliaryImageAlpha" );
 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   attribute mediump vec2 aPosition;\n
   varying mediump vec2 vTexCoord;\n
+  varying mediump vec2 vMaskTexCoord;\n
   uniform mediump mat4 uMvpMatrix;\n
   uniform mediump vec3 uSize;\n
   uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];\n
@@ -83,7 +84,7 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
     mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );\n
     mediump vec4 vertexPosition = gridPosition;\n
     vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );\n
-    vertexPostion.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;\n
+    vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;\n
     vertexPosition = uMvpMatrix * vertexPosition;\n
     \n
     vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );\n
@@ -569,8 +570,8 @@ void NPatchVisual::ApplyTextureAndUniforms()
       Uint16Pair stretchX = data->stretchPixelsX[ 0 ];
       Uint16Pair stretchY = data->stretchPixelsY[ 0 ];
 
-      uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
-      uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
+      uint16_t stretchWidth = ( stretchX.GetY() >= stretchX.GetX() ) ? stretchX.GetY() - stretchX.GetX() : 0;
+      uint16_t stretchHeight = ( stretchY.GetY() >= stretchY.GetX() ) ? stretchY.GetY() - stretchY.GetX() : 0;
 
       mImpl->mRenderer.RegisterProperty( "uFixed[0]", Vector2::ZERO );
       mImpl->mRenderer.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
index f5817ea..e44b005 100755 (executable)
@@ -24,6 +24,7 @@
 
 // INTERNAL HEADER
 #include <dali-toolkit/public-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties-devel.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
@@ -58,6 +59,7 @@ const char * const TEXT_COLOR_PROPERTY( "textColor" );
 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
 const char * const SHADOW_PROPERTY( "shadow" );
 const char * const UNDERLINE_PROPERTY( "underline" );
+const char * const OUTLINE_PROPERTY( "outline" );
 
 const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
 
@@ -328,6 +330,10 @@ Dali::Property::Index StringKeyToIndexKey( const std::string& stringKey )
   {
     result = Toolkit::TextVisual::Property::UNDERLINE;
   }
+  else if( stringKey == OUTLINE_PROPERTY )
+  {
+    result = Toolkit::DevelTextVisual::Property::OUTLINE;
+  }
 
   return result;
 }
@@ -405,6 +411,9 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const
 
   GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
   map.Insert( Toolkit::TextVisual::Property::UNDERLINE, value );
+
+  GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
+  map.Insert( Toolkit::DevelTextVisual::Property::OUTLINE, value );
 }
 
 void TextVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
@@ -593,6 +602,11 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
       SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
       break;
     }
+    case Toolkit::DevelTextVisual::Property::OUTLINE:
+    {
+      SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
+      break;
+    }
   }
 }
 
index ef5890e..765b9bf 100644 (file)
@@ -114,6 +114,15 @@ public:
     GetVisualObject( visual ).mRendererUpdateNeeded = true;
   };
 
+  /**
+   * @brief Instantly updates the renderer
+   * @param[in] visual The text visual.
+   */
+  static void UpdateRenderer( Toolkit::Visual::Base visual )
+  {
+    GetVisualObject( visual ).UpdateRenderer();
+  };
+
 public: // from Visual::Base
 
   /**
index b2e0d03..11d3b0f 100644 (file)
@@ -47,8 +47,10 @@ size_t GetNumberOfThreads(const char* environmentVariable, size_t defaultValue)
 {
   using Dali::EnvironmentVariable::GetEnvironmentVariable;
   auto numberString = GetEnvironmentVariable(environmentVariable);
-  auto numberOfThreads = numberString ? std::strtol(numberString, nullptr, 10) : 0;
-  return (numberOfThreads > 0) ? numberOfThreads : defaultValue;
+  auto numberOfThreads = numberString ? std::strtoul(numberString, nullptr, 10) : 0;
+  constexpr auto MAX_NUMBER_OF_THREADS = 100u;
+  DALI_ASSERT_DEBUG( numberOfThreads < MAX_NUMBER_OF_THREADS );
+  return ( numberOfThreads > 0 && numberOfThreads < MAX_NUMBER_OF_THREADS ) ? numberOfThreads : defaultValue;
 }
 
 size_t GetNumberOfLocalLoaderThreads()
index 79c099c..fd24205 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-resource-observer.h>
 #include <dali-toolkit/public-api/align-enumerations.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 namespace Dali
 {
index 6fc777d..b9cf7e9 100644 (file)
@@ -32,6 +32,7 @@
 #include <dali-toolkit/internal/visuals/transition-data-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/devel-api/direction-enums.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 namespace Dali
 {
index 9e889cb..079141d 100644 (file)
@@ -72,6 +72,9 @@ const char * const PREMULTIPLIED_ALPHA( "premultipliedAlpha" );
 const char * const MIX_COLOR( "mixColor" );
 const char * const OPACITY( "opacity" );
 
+// Color visual
+const char * const RENDER_IF_TRANSPARENT_NAME( "renderIfTransparent" );
+
 // Image visual
 const char * const IMAGE_URL_NAME( "url" );
 const char * const ATLAS_RECT_UNIFORM_NAME( "uAtlasRect" );
index eb0b617..1a73da9 100644 (file)
@@ -58,6 +58,9 @@ extern const char * const PREMULTIPLIED_ALPHA;
 extern const char * const MIX_COLOR;
 extern const char * const OPACITY;
 
+// Color visual
+extern const char * const RENDER_IF_TRANSPARENT_NAME;
+
 // Image visual
 extern const char * const IMAGE_URL_NAME;
 extern const char * const ATLAS_RECT_UNIFORM_NAME;
index 47a12b1..49064a8 100755 (executable)
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/public-api/align-enumerations.h>
 #include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/public-api/styling/style-manager.h>
 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/internal/styling/style-manager-impl.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
-#include <dali-toolkit/public-api/align-enumerations.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
 namespace Dali
@@ -61,6 +62,30 @@ Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CO
 #endif
 
 /**
+ * @brief Replace the background visual if it's a color visual with the renderIfTransparent property set as required.
+ * @param[in] controlImpl The control implementation
+ * @param[in] renderIfTransaparent Whether we should render if the color is transparent
+ */
+void ChangeBackgroundColorVisual( Control& controlImpl, bool renderIfTransparent )
+{
+  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+
+  Toolkit::Visual::Base backgroundVisual = controlDataImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
+  if( backgroundVisual )
+  {
+    Property::Map map;
+    backgroundVisual.CreatePropertyMap( map );
+    Property::Value* typeValue = map.Find( Toolkit::Visual::Property::TYPE );
+    if( typeValue && typeValue->Get< int >() == Toolkit::Visual::COLOR )
+    {
+      // Only change it if it's a color visual
+      map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = renderIfTransparent;
+      controlImpl.SetBackground( map );
+    }
+  }
+}
+
+/**
  * @brief Creates a clipping renderer if required.
  * (EG. If no renders exist and clipping is enabled).
  * @param[in] controlImpl The control implementation.
@@ -72,13 +97,34 @@ void CreateClippingRenderer( Control& controlImpl )
   int clippingMode = ClippingMode::DISABLED;
   if( self.GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) )
   {
-    Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
-
-    if( ( clippingMode == ClippingMode::CLIP_CHILDREN ) &&
-        controlDataImpl.mVisuals.Empty() &&
-        ( self.GetRendererCount() == 0u ) )
+    switch( clippingMode )
     {
-      controlImpl.SetBackgroundColor( Color::TRANSPARENT );
+      case ClippingMode::CLIP_CHILDREN:
+      {
+        if( self.GetRendererCount() == 0u )
+        {
+          Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
+          if( controlDataImpl.mVisuals.Empty() )
+          {
+            controlImpl.SetBackgroundColor( Color::TRANSPARENT );
+          }
+          else
+          {
+            // We have visuals, check if we've set the background and re-create it to
+            // render even if transparent (only if it's a color visual)
+            ChangeBackgroundColorVisual( controlImpl, true );
+          }
+        }
+        break;
+      }
+
+      case ClippingMode::DISABLED:
+      case ClippingMode::CLIP_TO_BOUNDING_BOX:
+      {
+        // If we have a background visual, check if it's a color visual and remove the render if transparent flag
+        ChangeBackgroundColorVisual( controlImpl, false );
+        break;
+      }
     }
   }
 }
@@ -168,6 +214,14 @@ void Control::SetBackgroundColor( const Vector4& color )
   map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
   map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
 
+  int clippingMode = ClippingMode::DISABLED;
+  if( ( Self().GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) ) &&
+      ( clippingMode == ClippingMode::CLIP_CHILDREN ) )
+  {
+    // If clipping-mode is set to CLIP_CHILDREN, then force visual to add the render even if transparent
+    map[ Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = true;
+  }
+
   SetBackground( map );
 }
 
index 5d28b91..14205f9 100644 (file)
@@ -140,6 +140,13 @@ bool Control::IsResourceReady() const
   return controlDataImpl.IsResourceReady();
 }
 
+Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus( Dali::Property::Index index )
+{
+  const Internal::Control& internalControl = Toolkit::Internal::GetImplementation( *this );
+  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
+  return controlDataImpl.GetVisualResourceStatus( index );
+}
+
 Control::KeyEventSignalType& Control::KeyEventSignal()
 {
   return Internal::GetImplementation(*this).KeyEventSignal();
index 58f3205..8e522a2 100644 (file)
@@ -28,6 +28,9 @@
 #include <dali/public-api/events/tap-gesture-detector.h>
 #include <dali/public-api/images/image.h>
 
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
 namespace Dali
 {
 
@@ -395,6 +398,15 @@ public:
    */
   bool IsResourceReady() const;
 
+  /**
+   * @brief Get the loading state of the visual resource.
+   *
+   * @SINCE_1_3_5
+   * @param[in] index The Property index of the visual
+   * @return Return the loading status (PREPARING, READY and FAILED) of visual resource
+   */
+  Visual::ResourceStatus GetVisualResourceStatus( const Dali::Property::Index index );
+
   // Signals
 
   /**
index ac2befa..7c99a5f 100644 (file)
@@ -48,7 +48,7 @@ class ImageView;
  * ResouceReadySignal is done after the resource is set then signal will be missed.
  *
  * To protect against this, IsResourceReady() can be checked before connecting to ResourceReadySignal,
- * or the signal connection can be done before setting the resource"
+ * or the signal connection can be done before setting the resource.
  *
  * @code
  *    auto myImageView = ImageView::New( resourceUrl );
index fdda010..f633f45 100644 (file)
@@ -301,9 +301,7 @@ public:
       INPUT_LINE_SPACING,
 
       /**
-       * @brief The default underline parameters.
-       * @details Name "underline", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::UNDERLINE
        */
       UNDERLINE,
 
@@ -315,9 +313,7 @@ public:
       INPUT_UNDERLINE,
 
       /**
-       * @brief The default shadow parameters.
-       * @details Name "shadow", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::SHADOW
        */
       SHADOW,
 
@@ -343,9 +339,7 @@ public:
       INPUT_EMBOSS,
 
       /**
-       * @brief The default outline parameters.
-       * @details Name "outline", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::OUTLINE
        */
       OUTLINE,
 
index 0875753..5af78b2 100644 (file)
@@ -353,9 +353,7 @@ public:
       INPUT_POINT_SIZE,
 
       /**
-       * @brief The default underline parameters.
-       * @details Name "underline", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::UNDERLINE
        */
       UNDERLINE,
 
@@ -367,9 +365,7 @@ public:
       INPUT_UNDERLINE,
 
       /**
-       * @brief The default shadow parameters.
-       * @details Name "shadow", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::SHADOW
        */
       SHADOW,
 
@@ -395,9 +391,7 @@ public:
       INPUT_EMBOSS,
 
       /**
-       * @brief The default outline parameters.
-       * @details Name "outline", type Property::MAP.
-       * @SINCE_1_2.13
+       * @copydoc Dali::Toolkit::TextLabel::Property::OUTLINE
        */
       OUTLINE,
 
index ec6613c..106f234 100644 (file)
@@ -254,6 +254,15 @@ public:
       /**
        * @brief The default underline parameters.
        * @details Name "underline", type Property::MAP.
+       *
+       * The underline map contains the following keys:
+       *
+       * | %Property Name       | Type     | Required | Description                                                                                                        |
+       * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
+       * | enable               | BOOLEAN  | No       | True to enable the underline or false to disable (the default value is false)                                      |
+       * | color                | VECTOR4  | No       | The color of the underline (the default value is Color::BLACK)                                                     |
+       * | height               | FLOAT    | No       | The height of the underline (the default value is 0)                                                               |
+       *
        * @SINCE_1_2.13
        */
       UNDERLINE,
@@ -261,6 +270,15 @@ public:
       /**
        * @brief The default shadow parameters.
        * @details Name "shadow", type Property::MAP.
+       *
+       * The shadow map contains the following keys:
+       *
+       * | %Property Name       | Type     | Required | Description                                                                                                        |
+       * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
+       * | color                | VECTOR4  | No       | The color of the shadow (the default value is Color::BLACK)                                                        |
+       * | offset               | VECTOR2  | No       | The offset from the text to draw the shadow in the X and Y axes (the default value is 0 which means no shadow)     |
+       * | blurRadius           | FLOAT    | No       | The radius of blur to be applied to the shadow (the default value is 0 which means no blur)                        |
+       *
        * @SINCE_1_2.13
        */
       SHADOW,
@@ -275,6 +293,14 @@ public:
       /**
        * @brief The default outline parameters.
        * @details Name "outline", type Property::MAP.
+       *
+       * The outline map contains the following keys:
+       *
+       * | %Property Name       | Type     | Required | Description                                                                                                        |
+       * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
+       * | color                | VECTOR4  | No       | The color of the outline (the default value is Color::WHITE)                                                       |
+       * | width                | INTEGER  | No       | The width of the outline (the default value is 0 which means no outline)                                           |
+       *
        * @SINCE_1_2.13
        */
       OUTLINE,
index e1226ce..d2c2e3f 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 2;
+const unsigned int TOOLKIT_MICRO_VERSION = 5;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 93902cf..0f5d58b 100644 (file)
@@ -232,10 +232,78 @@ enum
    * @note If this is false, then the mask is scaled to fit the image before being applied.
    */
   CROP_TO_MASK,
+
+  /**
+   * @brief The policy to determine when an image should be loaded.
+   * @details Name "loadPolicy",  Type LoadPolicy::Type (Property::INTEGER)or Property::STRING.
+   * @SINCE_1_3_5
+   * @note Default LoadPolicy::ATTACHED
+   * @see LoadPolicy::Type
+   */
+
+  LOAD_POLICY,
+
+  /**
+   * @brief The policy to determine when an image should no longer be cached.
+   * @details Name "releasePolicy", Type ReleasePolicy::Type (Property::INTEGER) or Property::STRING
+   * @SINCE_1_3_5
+   * @note Default ReleasePolicy::DESTROYED
+   * @see ReleasePolicy::Type
+   */
+  RELEASE_POLICY,
+
+  /**
+   * @brief Determines if image orientation should be corrected so the image displays as it was intended.
+   * @details Name "orientationCorrection", Type Property::BOOLEAN, if true the image's orientation will be corrected.
+   * @SINCE_1_3_5
+   * @note Default true
+   */
+  ORIENTATION_CORRECTION,
+
 };
 
 } // namespace Property
 
+/**
+ * @brief The policy determining if the image is loaded when the visual is staged or created.
+ * @SINCE_1_3_5
+ */
+namespace LoadPolicy
+{
+
+/**
+ * @brief The available named elements that define the LoadPolicy.
+ * @SINCE_1_3_5
+ */
+enum Type
+{
+  IMMEDIATE = 0,  ///< The image is loaded when the ImageVisual is created.
+  ATTACHED        ///< The image is loaded when the ImageVisual is attached to the stage.
+};
+
+} // namespace LoadPolicy
+
+/**
+ * @brief The policy determining when a image is deleted from the cache in relation to the ImageVisual lifetime.
+ * @SINCE_1_3_5
+ * @note If the texture is being shared by another visual it persist if still required.
+ */
+namespace ReleasePolicy
+{
+
+/**
+ * @brief The available named elements that define the ReleasePolicy.
+ * @SINCE_1_3_5
+ */
+enum Type
+{
+  DETACHED = 0,  ///<  Image deleted from cache when ImageVisual detached from stage.
+  DESTROYED,     ///<  Image deleted from cache when ImageVisual destroyed.
+  NEVER          ///<  Image is never deleted, will survive the lifetime of the application.
+};
+
+} // namespace ReleasePolicy;
+
 } // namespace ImageVisual
 
 /**
index 94b504b..bb0ecd2 100644 (file)
@@ -325,6 +325,18 @@ enum
 
 } // namespace Shader
 
+
+/**
+ * @brief Status of resource which is used for visual.
+ * @SINCE_1_3_5
+ */
+enum class ResourceStatus
+{
+  PREPARING, /// Resource is prepared.    @SINCE_1_3_5
+  READY,     /// Resource is ready.       @SINCE_1_3_5
+  FAILED     /// Resource is fail to load @SINCE_1_3_5
+};
+
 } // namespace Visual
 
 /**
index d3ffc40..1022a98 100644 (file)
 
 static int nsvg__isspace(char c)
 {
-    return strchr(" \t\n\v\f\r", c) != 0;
+       return strchr(" \t\n\v\f\r", c) != 0;
 }
 
 static int nsvg__isdigit(char c)
 {
-    return strchr("0123456789", c) != 0;
+       return c >= '0' && c <= '9';
 }
 
 static int nsvg__isnum(char c)
 {
-    return strchr("0123456789+-.eE", c) != 0;
+       return strchr("0123456789+-.eE", c) != 0;
 }
 
 static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
@@ -80,112 +80,121 @@ static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
 #define NSVG_XML_MAX_ATTRIBS 256
 
 static void nsvg__parseContent(char* s,
-                               void (*contentCb)(void* ud, const char* s),
-                               void* ud)
+                                                          void (*contentCb)(void* ud, const char* s),
+                                                          void* ud)
 {
-    // Trim start white spaces
-    while (*s && nsvg__isspace(*s)) s++;
-    if (!*s) return;
+       // Trim start white spaces
+       while (*s && nsvg__isspace(*s)) s++;
+       if (!*s) return;
 
-    if (contentCb)
-        (*contentCb)(ud, s);
+       if (contentCb)
+               (*contentCb)(ud, s);
 }
 
 static void nsvg__parseElement(char* s,
-                               void (*startelCb)(void* ud, const char* el, const char** attr),
-                               void (*endelCb)(void* ud, const char* el),
-                               void* ud)
-{
-    const char* attr[NSVG_XML_MAX_ATTRIBS];
-    int nattr = 0;
-    char* name;
-    int start = 0;
-    int end = 0;
-    char quote;
-
-    // Skip white space after the '<'
-    while (*s && nsvg__isspace(*s)) s++;
-
-    // Check if the tag is end tag
-    if (*s == '/') {
-        s++;
-        end = 1;
-    } else {
-        start = 1;
-    }
-
-    // Skip comments, data and preprocessor stuff.
-    if (!*s || *s == '?' || *s == '!')
-        return;
-
-    // Get tag name
-    name = s;
-    while (*s && !nsvg__isspace(*s)) s++;
-    if (*s) { *s++ = '\0'; }
-
-    // Get attribs
-    while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
-        // Skip white space before the attrib name
-        while (*s && nsvg__isspace(*s)) s++;
-        if (!*s) break;
-        if (*s == '/') {
-            end = 1;
-            break;
-        }
-        attr[nattr++] = s;
-        // Find end of the attrib name.
-        while (*s && !nsvg__isspace(*s) && *s != '=') s++;
-        if (*s) { *s++ = '\0'; }
-        // Skip until the beginning of the value.
-        while (*s && *s != '\"' && *s != '\'') s++;
-        if (!*s) break;
-        quote = *s;
-        s++;
-        // Store value and find the end of it.
-        attr[nattr++] = s;
-        while (*s && *s != quote) s++;
-        if (*s) { *s++ = '\0'; }
-    }
-
-    // List terminator
-    attr[nattr++] = 0;
-    attr[nattr++] = 0;
-
-    // Call callbacks.
-    if (start && startelCb)
-        (*startelCb)(ud, name, attr);
-    if (end && endelCb)
-        (*endelCb)(ud, name);
+                                                          void (*startelCb)(void* ud, const char* el, const char** attr),
+                                                          void (*endelCb)(void* ud, const char* el),
+                                                          void* ud)
+{
+       const char* attr[NSVG_XML_MAX_ATTRIBS];
+       int nattr = 0;
+       char* name;
+       int start = 0;
+       int end = 0;
+       char quote;
+
+       // Skip white space after the '<'
+       while (*s && nsvg__isspace(*s)) s++;
+
+       // Check if the tag is end tag
+       if (*s == '/') {
+               s++;
+               end = 1;
+       } else {
+               start = 1;
+       }
+
+       // Skip comments, data and preprocessor stuff.
+       if (!*s || *s == '?' || *s == '!')
+               return;
+
+       // Get tag name
+       name = s;
+       while (*s && !nsvg__isspace(*s)) s++;
+       if (*s) { *s++ = '\0'; }
+
+       // Get attribs
+       while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
+               char* name = NULL;
+               char* value = NULL;
+
+               // Skip white space before the attrib name
+               while (*s && nsvg__isspace(*s)) s++;
+               if (!*s) break;
+               if (*s == '/') {
+                       end = 1;
+                       break;
+               }
+               name = s;
+               // Find end of the attrib name.
+               while (*s && !nsvg__isspace(*s) && *s != '=') s++;
+               if (*s) { *s++ = '\0'; }
+               // Skip until the beginning of the value.
+               while (*s && *s != '\"' && *s != '\'') s++;
+               if (!*s) break;
+               quote = *s;
+               s++;
+               // Store value and find the end of it.
+               value = s;
+               while (*s && *s != quote) s++;
+               if (*s) { *s++ = '\0'; }
+
+               // Store only well formed attributes
+               if (name && value) {
+                       attr[nattr++] = name;
+                       attr[nattr++] = value;
+               }
+       }
+
+       // List terminator
+       attr[nattr++] = 0;
+       attr[nattr++] = 0;
+
+       // Call callbacks.
+       if (start && startelCb)
+               (*startelCb)(ud, name, attr);
+       if (end && endelCb)
+               (*endelCb)(ud, name);
 }
 
 int nsvg__parseXML(char* input,
-                   void (*startelCb)(void* ud, const char* el, const char** attr),
-                   void (*endelCb)(void* ud, const char* el),
-                   void (*contentCb)(void* ud, const char* s),
-                   void* ud)
-{
-    char* s = input;
-    char* mark = s;
-    int state = NSVG_XML_CONTENT;
-    while (*s) {
-        if (*s == '<' && state == NSVG_XML_CONTENT) {
-            // Start of a tag
-            *s++ = '\0';
-            nsvg__parseContent(mark, contentCb, ud);
-            mark = s;
-            state = NSVG_XML_TAG;
-        } else if (*s == '>' && state == NSVG_XML_TAG) {
-            // Start of a content or new tag.
-            *s++ = '\0';
-            nsvg__parseElement(mark, startelCb, endelCb, ud);
-            mark = s;
-            state = NSVG_XML_CONTENT;
-        } else {
-            s++;
-        }
-    }
-
-    return 1;
+                                  void (*startelCb)(void* ud, const char* el, const char** attr),
+                                  void (*endelCb)(void* ud, const char* el),
+                                  void (*contentCb)(void* ud, const char* s),
+                                  void* ud)
+{
+       char* s = input;
+       char* mark = s;
+       int state = NSVG_XML_CONTENT;
+       while (*s) {
+               if (*s == '<' && state == NSVG_XML_CONTENT) {
+                       // Start of a tag
+                       *s++ = '\0';
+                       nsvg__parseContent(mark, contentCb, ud);
+                       mark = s;
+                       state = NSVG_XML_TAG;
+               } else if (*s == '>' && state == NSVG_XML_TAG) {
+                       // Start of a content or new tag.
+                       *s++ = '\0';
+                       nsvg__parseElement(mark, startelCb, endelCb, ud);
+                       mark = s;
+                       state = NSVG_XML_CONTENT;
+               } else {
+                       s++;
+               }
+       }
+
+       return 1;
 }
 
 
@@ -194,465 +203,466 @@ int nsvg__parseXML(char* input,
 #define NSVG_MAX_ATTR 128
 
 enum NSVGgradientUnits {
-    NSVG_USER_SPACE = 0,
-    NSVG_OBJECT_SPACE = 1,
+       NSVG_USER_SPACE = 0,
+       NSVG_OBJECT_SPACE = 1
 };
 
 #define NSVG_MAX_DASHES 8
 
 enum NSVGunits {
-    NSVG_UNITS_USER,
-    NSVG_UNITS_PX,
-    NSVG_UNITS_PT,
-    NSVG_UNITS_PC,
-    NSVG_UNITS_MM,
-    NSVG_UNITS_CM,
-    NSVG_UNITS_IN,
-    NSVG_UNITS_PERCENT,
-    NSVG_UNITS_EM,
-    NSVG_UNITS_EX,
+       NSVG_UNITS_USER,
+       NSVG_UNITS_PX,
+       NSVG_UNITS_PT,
+       NSVG_UNITS_PC,
+       NSVG_UNITS_MM,
+       NSVG_UNITS_CM,
+       NSVG_UNITS_IN,
+       NSVG_UNITS_PERCENT,
+       NSVG_UNITS_EM,
+       NSVG_UNITS_EX
 };
 
 typedef struct NSVGcoordinate {
-    float value;
-    int units;
+       float value;
+       int units;
 } NSVGcoordinate;
 
 typedef struct NSVGlinearData {
-    NSVGcoordinate x1, y1, x2, y2;
+       NSVGcoordinate x1, y1, x2, y2;
 } NSVGlinearData;
 
 typedef struct NSVGradialData {
-    NSVGcoordinate cx, cy, r, fx, fy;
+       NSVGcoordinate cx, cy, r, fx, fy;
 } NSVGradialData;
 
 typedef struct NSVGgradientData
 {
-    char id[64];
-    char ref[64];
-
-    /**
-     * In the original file, using char type (without signed or unsigned) can be interpreted
-     * as 'unsigned char' in some build environments, like ARM architecture.
-     * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
-     */
+       char id[64];
+       char ref[64];
+  /**
+   * In the original file, using char type (without signed or unsigned) can be interpreted
+   * as 'unsigned char' in some build environments, like ARM architecture.
+   * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
+   */
     signed char type;
-    union {
-        NSVGlinearData linear;
-        NSVGradialData radial;
-    };
-    char spread;
-
-    /**
-     * In the original file, using char type (without signed or unsigned) can be interpreted
-     * as 'unsigned char' in some build environments, like ARM architecture.
-     * To prevent the unexpected behavior, we replace 'char units' with 'signed char units' here.
-     */
+       union {
+               NSVGlinearData linear;
+               NSVGradialData radial;
+       };
+       char spread;
+       /**
+        * In the original file, using char type (without signed or unsigned) can be interpreted
+        * as 'unsigned char' in some build environments, like ARM architecture.
+        * To prevent the unexpected behavior, we replace 'char units' with 'signed char units' here.
+        */
     signed char units;
-    float xform[6];
-    int nstops;
-    NSVGgradientStop* stops;
-    struct NSVGgradientData* next;
+       float xform[6];
+       int nstops;
+       NSVGgradientStop* stops;
+       struct NSVGgradientData* next;
 } NSVGgradientData;
 
 typedef struct NSVGattrib
 {
-    char id[64];
-    float xform[6];
-    unsigned int fillColor;
-    unsigned int strokeColor;
-    float opacity;
-    float fillOpacity;
-    float strokeOpacity;
-    char fillGradient[64];
-    char strokeGradient[64];
-    float strokeWidth;
-    float strokeDashOffset;
-    float strokeDashArray[NSVG_MAX_DASHES];
-    int strokeDashCount;
-    char strokeLineJoin;
-    char strokeLineCap;
-    char fillRule;
-    float fontSize;
-    unsigned int stopColor;
-    float stopOpacity;
-    float stopOffset;
-    char hasFill;
-    char hasStroke;
-    char visible;
+       char id[64];
+       float xform[6];
+       unsigned int fillColor;
+       unsigned int strokeColor;
+       float opacity;
+       float fillOpacity;
+       float strokeOpacity;
+       char fillGradient[64];
+       char strokeGradient[64];
+       float strokeWidth;
+       float strokeDashOffset;
+       float strokeDashArray[NSVG_MAX_DASHES];
+       int strokeDashCount;
+       char strokeLineJoin;
+       char strokeLineCap;
+       float miterLimit;
+       char fillRule;
+       float fontSize;
+       unsigned int stopColor;
+       float stopOpacity;
+       float stopOffset;
+       char hasFill;
+       char hasStroke;
+       char visible;
 } NSVGattrib;
 
 typedef struct NSVGparser
 {
-    NSVGattrib attr[NSVG_MAX_ATTR];
-    int attrHead;
-    float* pts;
-    int npts;
-    int cpts;
-    NSVGpath* plist;
-    NSVGimage* image;
-    NSVGgradientData* gradients;
-    float viewMinx, viewMiny, viewWidth, viewHeight;
-    int alignX, alignY, alignType;
-    float dpi;
-    char pathFlag;
-    char defsFlag;
+       NSVGattrib attr[NSVG_MAX_ATTR];
+       int attrHead;
+       float* pts;
+       int npts;
+       int cpts;
+       NSVGpath* plist;
+       NSVGimage* image;
+       NSVGgradientData* gradients;
+       NSVGshape* shapesTail;
+       float viewMinx, viewMiny, viewWidth, viewHeight;
+       int alignX, alignY, alignType;
+       float dpi;
+       char pathFlag;
+       char defsFlag;
 } NSVGparser;
 
 static void nsvg__xformIdentity(float* t)
 {
-    t[0] = 1.0f; t[1] = 0.0f;
-    t[2] = 0.0f; t[3] = 1.0f;
-    t[4] = 0.0f; t[5] = 0.0f;
+       t[0] = 1.0f; t[1] = 0.0f;
+       t[2] = 0.0f; t[3] = 1.0f;
+       t[4] = 0.0f; t[5] = 0.0f;
 }
 
 static void nsvg__xformSetTranslation(float* t, float tx, float ty)
 {
-    t[0] = 1.0f; t[1] = 0.0f;
-    t[2] = 0.0f; t[3] = 1.0f;
-    t[4] = tx; t[5] = ty;
+       t[0] = 1.0f; t[1] = 0.0f;
+       t[2] = 0.0f; t[3] = 1.0f;
+       t[4] = tx; t[5] = ty;
 }
 
 static void nsvg__xformSetScale(float* t, float sx, float sy)
 {
-    t[0] = sx; t[1] = 0.0f;
-    t[2] = 0.0f; t[3] = sy;
-    t[4] = 0.0f; t[5] = 0.0f;
+       t[0] = sx; t[1] = 0.0f;
+       t[2] = 0.0f; t[3] = sy;
+       t[4] = 0.0f; t[5] = 0.0f;
 }
 
 static void nsvg__xformSetSkewX(float* t, float a)
 {
-    t[0] = 1.0f; t[1] = 0.0f;
-    t[2] = tanf(a); t[3] = 1.0f;
-    t[4] = 0.0f; t[5] = 0.0f;
+       t[0] = 1.0f; t[1] = 0.0f;
+       t[2] = tanf(a); t[3] = 1.0f;
+       t[4] = 0.0f; t[5] = 0.0f;
 }
 
 static void nsvg__xformSetSkewY(float* t, float a)
 {
-    t[0] = 1.0f; t[1] = tanf(a);
-    t[2] = 0.0f; t[3] = 1.0f;
-    t[4] = 0.0f; t[5] = 0.0f;
+       t[0] = 1.0f; t[1] = tanf(a);
+       t[2] = 0.0f; t[3] = 1.0f;
+       t[4] = 0.0f; t[5] = 0.0f;
 }
 
 static void nsvg__xformSetRotation(float* t, float a)
 {
-    float cs = cosf(a), sn = sinf(a);
-    t[0] = cs; t[1] = sn;
-    t[2] = -sn; t[3] = cs;
-    t[4] = 0.0f; t[5] = 0.0f;
+       float cs = cosf(a), sn = sinf(a);
+       t[0] = cs; t[1] = sn;
+       t[2] = -sn; t[3] = cs;
+       t[4] = 0.0f; t[5] = 0.0f;
 }
 
 static void nsvg__xformMultiply(float* t, float* s)
 {
-    float t0 = t[0] * s[0] + t[1] * s[2];
-    float t2 = t[2] * s[0] + t[3] * s[2];
-    float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
-    t[1] = t[0] * s[1] + t[1] * s[3];
-    t[3] = t[2] * s[1] + t[3] * s[3];
-    t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
-    t[0] = t0;
-    t[2] = t2;
-    t[4] = t4;
+       float t0 = t[0] * s[0] + t[1] * s[2];
+       float t2 = t[2] * s[0] + t[3] * s[2];
+       float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
+       t[1] = t[0] * s[1] + t[1] * s[3];
+       t[3] = t[2] * s[1] + t[3] * s[3];
+       t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
+       t[0] = t0;
+       t[2] = t2;
+       t[4] = t4;
 }
 
 static void nsvg__xformInverse(float* inv, float* t)
 {
-    double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
-    if (det > -1e-6 && det < 1e-6) {
-        nsvg__xformIdentity(t);
-        return;
-    }
-    invdet = 1.0 / det;
-    inv[0] = (float)(t[3] * invdet);
-    inv[2] = (float)(-t[2] * invdet);
-    inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
-    inv[1] = (float)(-t[1] * invdet);
-    inv[3] = (float)(t[0] * invdet);
-    inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
+       double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
+       if (det > -1e-6 && det < 1e-6) {
+               nsvg__xformIdentity(t);
+               return;
+       }
+       invdet = 1.0 / det;
+       inv[0] = (float)(t[3] * invdet);
+       inv[2] = (float)(-t[2] * invdet);
+       inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
+       inv[1] = (float)(-t[1] * invdet);
+       inv[3] = (float)(t[0] * invdet);
+       inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
 }
 
 static void nsvg__xformPremultiply(float* t, float* s)
 {
-    float s2[6];
-    memcpy(s2, s, sizeof(float)*6);
-    nsvg__xformMultiply(s2, t);
-    memcpy(t, s2, sizeof(float)*6);
+       float s2[6];
+       memcpy(s2, s, sizeof(float)*6);
+       nsvg__xformMultiply(s2, t);
+       memcpy(t, s2, sizeof(float)*6);
 }
 
 static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t)
 {
-    *dx = x*t[0] + y*t[2] + t[4];
-    *dy = x*t[1] + y*t[3] + t[5];
+       *dx = x*t[0] + y*t[2] + t[4];
+       *dy = x*t[1] + y*t[3] + t[5];
 }
 
 static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t)
 {
-    *dx = x*t[0] + y*t[2];
-    *dy = x*t[1] + y*t[3];
+       *dx = x*t[0] + y*t[2];
+       *dy = x*t[1] + y*t[3];
 }
 
 #define NSVG_EPSILON (1e-12)
 
 static int nsvg__ptInBounds(float* pt, float* bounds)
 {
-    return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
+       return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
 }
 
 
 static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3)
 {
-    double it = 1.0-t;
-    return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
+       double it = 1.0-t;
+       return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
 }
 
 static void nsvg__curveBounds(float* bounds, float* curve)
 {
-    int i, j, count;
-    double roots[2], a, b, c, b2ac, t, v;
-    float* v0 = &curve[0];
-    float* v1 = &curve[2];
-    float* v2 = &curve[4];
-    float* v3 = &curve[6];
-
-    // Start the bounding box by end points
-    bounds[0] = nsvg__minf(v0[0], v3[0]);
-    bounds[1] = nsvg__minf(v0[1], v3[1]);
-    bounds[2] = nsvg__maxf(v0[0], v3[0]);
-    bounds[3] = nsvg__maxf(v0[1], v3[1]);
-
-    // Bezier curve fits inside the convex hull of it's control points.
-    // If control points are inside the bounds, we're done.
-    if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
-        return;
-
-    // Add bezier curve inflection points in X and Y.
-    for (i = 0; i < 2; i++) {
-        a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
-        b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
-        c = 3.0 * v1[i] - 3.0 * v0[i];
-        count = 0;
-        if (fabs(a) < NSVG_EPSILON) {
-            if (fabs(b) > NSVG_EPSILON) {
-                t = -c / b;
-                if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
-                    roots[count++] = t;
-            }
-        } else {
-            b2ac = b*b - 4.0*c*a;
-            if (b2ac > NSVG_EPSILON) {
-                t = (-b + sqrt(b2ac)) / (2.0 * a);
-                if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
-                    roots[count++] = t;
-                t = (-b - sqrt(b2ac)) / (2.0 * a);
-                if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
-                    roots[count++] = t;
-            }
-        }
-        for (j = 0; j < count; j++) {
-            v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
-            bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
-            bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
-        }
-    }
+       int i, j, count;
+       double roots[2], a, b, c, b2ac, t, v;
+       float* v0 = &curve[0];
+       float* v1 = &curve[2];
+       float* v2 = &curve[4];
+       float* v3 = &curve[6];
+
+       // Start the bounding box by end points
+       bounds[0] = nsvg__minf(v0[0], v3[0]);
+       bounds[1] = nsvg__minf(v0[1], v3[1]);
+       bounds[2] = nsvg__maxf(v0[0], v3[0]);
+       bounds[3] = nsvg__maxf(v0[1], v3[1]);
+
+       // Bezier curve fits inside the convex hull of it's control points.
+       // If control points are inside the bounds, we're done.
+       if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
+               return;
+
+       // Add bezier curve inflection points in X and Y.
+       for (i = 0; i < 2; i++) {
+               a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
+               b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
+               c = 3.0 * v1[i] - 3.0 * v0[i];
+               count = 0;
+               if (fabs(a) < NSVG_EPSILON) {
+                       if (fabs(b) > NSVG_EPSILON) {
+                               t = -c / b;
+                               if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+                                       roots[count++] = t;
+                       }
+               } else {
+                       b2ac = b*b - 4.0*c*a;
+                       if (b2ac > NSVG_EPSILON) {
+                               t = (-b + sqrt(b2ac)) / (2.0 * a);
+                               if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+                                       roots[count++] = t;
+                               t = (-b - sqrt(b2ac)) / (2.0 * a);
+                               if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+                                       roots[count++] = t;
+                       }
+               }
+               for (j = 0; j < count; j++) {
+                       v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
+                       bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
+                       bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
+               }
+       }
 }
 
 static NSVGparser* nsvg__createParser()
 {
-    NSVGparser* p;
-    p = (NSVGparser*)malloc(sizeof(NSVGparser));
-    if (p == NULL) goto error;
-    memset(p, 0, sizeof(NSVGparser));
-
-    p->image = (NSVGimage*)malloc(sizeof(NSVGimage));
-    if (p->image == NULL) goto error;
-    memset(p->image, 0, sizeof(NSVGimage));
-
-    // Init style
-    nsvg__xformIdentity(p->attr[0].xform);
-    memset(p->attr[0].id, 0, sizeof p->attr[0].id);
-    p->attr[0].fillColor = NSVG_RGB(0,0,0);
-    p->attr[0].strokeColor = NSVG_RGB(0,0,0);
-    p->attr[0].opacity = 1;
-    p->attr[0].fillOpacity = 1;
-    p->attr[0].strokeOpacity = 1;
-    p->attr[0].stopOpacity = 1;
-    p->attr[0].strokeWidth = 1;
-    p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
-    p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
-    p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
-    p->attr[0].hasFill = 1;
-    p->attr[0].visible = 1;
-
-    return p;
+       NSVGparser* p;
+       p = (NSVGparser*)malloc(sizeof(NSVGparser));
+       if (p == NULL) goto error;
+       memset(p, 0, sizeof(NSVGparser));
+
+       p->image = (NSVGimage*)malloc(sizeof(NSVGimage));
+       if (p->image == NULL) goto error;
+       memset(p->image, 0, sizeof(NSVGimage));
+
+       // Init style
+       nsvg__xformIdentity(p->attr[0].xform);
+       memset(p->attr[0].id, 0, sizeof p->attr[0].id);
+       p->attr[0].fillColor = NSVG_RGB(0,0,0);
+       p->attr[0].strokeColor = NSVG_RGB(0,0,0);
+       p->attr[0].opacity = 1;
+       p->attr[0].fillOpacity = 1;
+       p->attr[0].strokeOpacity = 1;
+       p->attr[0].stopOpacity = 1;
+       p->attr[0].strokeWidth = 1;
+       p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
+       p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
+       p->attr[0].miterLimit = 4;
+       p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
+       p->attr[0].hasFill = 1;
+       p->attr[0].visible = 1;
+
+       return p;
 
 error:
-    if (p) {
-        if (p->image) free(p->image);
-        free(p);
-    }
-    return NULL;
+       if (p) {
+               if (p->image) free(p->image);
+               free(p);
+       }
+       return NULL;
 }
 
 static void nsvg__deletePaths(NSVGpath* path)
 {
-    while (path) {
-        NSVGpath *next = path->next;
-        if (path->pts != NULL)
-            free(path->pts);
-        free(path);
-        path = next;
-    }
+       while (path) {
+               NSVGpath *next = path->next;
+               if (path->pts != NULL)
+                       free(path->pts);
+               free(path);
+               path = next;
+       }
 }
 
 static void nsvg__deletePaint(NSVGpaint* paint)
 {
-    if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
-        free(paint->gradient);
+       if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
+               free(paint->gradient);
 }
 
 static void nsvg__deleteGradientData(NSVGgradientData* grad)
 {
-    NSVGgradientData* next;
-    while (grad != NULL) {
-        next = grad->next;
-        free(grad->stops);
-        free(grad);
-        grad = next;
-    }
+       NSVGgradientData* next;
+       while (grad != NULL) {
+               next = grad->next;
+               free(grad->stops);
+               free(grad);
+               grad = next;
+       }
 }
 
 static void nsvg__deleteParser(NSVGparser* p)
 {
-    if (p != NULL) {
-        nsvg__deletePaths(p->plist);
-        nsvg__deleteGradientData(p->gradients);
-        nsvgDelete(p->image);
-        free(p->pts);
-        free(p);
-    }
+       if (p != NULL) {
+               nsvg__deletePaths(p->plist);
+               nsvg__deleteGradientData(p->gradients);
+               nsvgDelete(p->image);
+               free(p->pts);
+               free(p);
+       }
 }
 
 static void nsvg__resetPath(NSVGparser* p)
 {
-    p->npts = 0;
+       p->npts = 0;
 }
 
 static void nsvg__addPoint(NSVGparser* p, float x, float y)
 {
-    if (p->npts+1 > p->cpts) {
-        p->cpts = p->cpts ? p->cpts*2 : 8;
-        p->pts = (float*)realloc(p->pts, p->cpts*2*sizeof(float));
-        if (!p->pts) return;
-    }
-    p->pts[p->npts*2+0] = x;
-    p->pts[p->npts*2+1] = y;
-    p->npts++;
+       if (p->npts+1 > p->cpts) {
+               p->cpts = p->cpts ? p->cpts*2 : 8;
+               p->pts = (float*)realloc(p->pts, p->cpts*2*sizeof(float));
+               if (!p->pts) return;
+       }
+       p->pts[p->npts*2+0] = x;
+       p->pts[p->npts*2+1] = y;
+       p->npts++;
 }
 
 static void nsvg__moveTo(NSVGparser* p, float x, float y)
 {
-    if (p->npts > 0) {
-        p->pts[(p->npts-1)*2+0] = x;
-        p->pts[(p->npts-1)*2+1] = y;
-    } else {
-        nsvg__addPoint(p, x, y);
-    }
+       if (p->npts > 0) {
+               p->pts[(p->npts-1)*2+0] = x;
+               p->pts[(p->npts-1)*2+1] = y;
+       } else {
+               nsvg__addPoint(p, x, y);
+       }
 }
 
 static void nsvg__lineTo(NSVGparser* p, float x, float y)
 {
-    float px,py, dx,dy;
-    if (p->npts > 0) {
-        px = p->pts[(p->npts-1)*2+0];
-        py = p->pts[(p->npts-1)*2+1];
-        dx = x - px;
-        dy = y - py;
-        nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
-        nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
-        nsvg__addPoint(p, x, y);
-    }
+       float px,py, dx,dy;
+       if (p->npts > 0) {
+               px = p->pts[(p->npts-1)*2+0];
+               py = p->pts[(p->npts-1)*2+1];
+               dx = x - px;
+               dy = y - py;
+               nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
+               nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
+               nsvg__addPoint(p, x, y);
+       }
 }
 
 static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
 {
-    nsvg__addPoint(p, cpx1, cpy1);
-    nsvg__addPoint(p, cpx2, cpy2);
-    nsvg__addPoint(p, x, y);
+       nsvg__addPoint(p, cpx1, cpy1);
+       nsvg__addPoint(p, cpx2, cpy2);
+       nsvg__addPoint(p, x, y);
 }
 
 static NSVGattrib* nsvg__getAttr(NSVGparser* p)
 {
-    return &p->attr[p->attrHead];
+       return &p->attr[p->attrHead];
 }
 
 static void nsvg__pushAttr(NSVGparser* p)
 {
-    if (p->attrHead < NSVG_MAX_ATTR-1) {
-        p->attrHead++;
-        memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib));
-    }
+       if (p->attrHead < NSVG_MAX_ATTR-1) {
+               p->attrHead++;
+               memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib));
+       }
 }
 
 static void nsvg__popAttr(NSVGparser* p)
 {
-    if (p->attrHead > 0)
-        p->attrHead--;
+       if (p->attrHead > 0)
+               p->attrHead--;
 }
 
 static float nsvg__actualOrigX(NSVGparser* p)
 {
-    return p->viewMinx;
+       return p->viewMinx;
 }
 
 static float nsvg__actualOrigY(NSVGparser* p)
 {
-    return p->viewMiny;
+       return p->viewMiny;
 }
 
 static float nsvg__actualWidth(NSVGparser* p)
 {
-    return p->viewWidth;
+       return p->viewWidth;
 }
 
 static float nsvg__actualHeight(NSVGparser* p)
 {
-    return p->viewHeight;
+       return p->viewHeight;
 }
 
 static float nsvg__actualLength(NSVGparser* p)
 {
-    float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p);
-    return sqrtf(w*w + h*h) / sqrtf(2.0f);
+       float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p);
+       return sqrtf(w*w + h*h) / sqrtf(2.0f);
 }
 
 static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, float length)
 {
-    NSVGattrib* attr = nsvg__getAttr(p);
-    switch (c.units) {
-        case NSVG_UNITS_USER:       return c.value;
-        case NSVG_UNITS_PX:         return c.value;
-        case NSVG_UNITS_PT:         return c.value / 72.0f * p->dpi;
-        case NSVG_UNITS_PC:         return c.value / 6.0f * p->dpi;
-        case NSVG_UNITS_MM:         return c.value / 25.4f * p->dpi;
-        case NSVG_UNITS_CM:         return c.value / 2.54f * p->dpi;
-        case NSVG_UNITS_IN:         return c.value * p->dpi;
-        case NSVG_UNITS_EM:         return c.value * attr->fontSize;
-        case NSVG_UNITS_EX:         return c.value * attr->fontSize * 0.52f; // x-height of Helvetica.
-        case NSVG_UNITS_PERCENT:    return orig + c.value / 100.0f * length;
-        default:                    return c.value;
-    }
-    return c.value;
+       NSVGattrib* attr = nsvg__getAttr(p);
+       switch (c.units) {
+               case NSVG_UNITS_USER:           return c.value;
+               case NSVG_UNITS_PX:                     return c.value;
+               case NSVG_UNITS_PT:                     return c.value / 72.0f * p->dpi;
+               case NSVG_UNITS_PC:                     return c.value / 6.0f * p->dpi;
+               case NSVG_UNITS_MM:                     return c.value / 25.4f * p->dpi;
+               case NSVG_UNITS_CM:                     return c.value / 2.54f * p->dpi;
+               case NSVG_UNITS_IN:                     return c.value * p->dpi;
+               case NSVG_UNITS_EM:                     return c.value * attr->fontSize;
+               case NSVG_UNITS_EX:                     return c.value * attr->fontSize * 0.52f; // x-height of Helvetica.
+               case NSVG_UNITS_PERCENT:        return orig + c.value / 100.0f * length;
+               default:                                        return c.value;
+       }
+       return c.value;
 }
 
 static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
 {
-    NSVGgradientData* grad = p->gradients;
-    while (grad) {
-        if (strcmp(grad->id, id) == 0)
-            return grad;
-        grad = grad->next;
-    }
-    return NULL;
+       NSVGgradientData* grad = p->gradients;
+       while (grad) {
+               if (strcmp(grad->id, id) == 0)
+                       return grad;
+               grad = grad->next;
+       }
+       return NULL;
 }
 
 /**
@@ -662,1197 +672,1243 @@ static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
  */
 static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, signed char* paintType)
 {
-    NSVGattrib* attr = nsvg__getAttr(p);
-    NSVGgradientData* data = NULL;
-    NSVGgradientData* ref = NULL;
-    NSVGgradientStop* stops = NULL;
-    NSVGgradient* grad;
-    float ox, oy, sw, sh, sl;
-    int nstops = 0;
-
-    data = nsvg__findGradientData(p, id);
-    if (data == NULL) return NULL;
-
-    // TODO: use ref to fill in all unset values too.
-    ref = data;
-    while (ref != NULL) {
-        if (stops == NULL && ref->stops != NULL) {
-            stops = ref->stops;
-            nstops = ref->nstops;
-            break;
-        }
-        ref = nsvg__findGradientData(p, ref->ref);
-    }
-    if (stops == NULL) return NULL;
-
-    grad = (NSVGgradient*)malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
-    if (grad == NULL) return NULL;
-
-    // The shape width and height.
-    if (data->units == NSVG_OBJECT_SPACE) {
-        ox = localBounds[0];
-        oy = localBounds[1];
-        sw = localBounds[2] - localBounds[0];
-        sh = localBounds[3] - localBounds[1];
-    } else {
-        ox = nsvg__actualOrigX(p);
-        oy = nsvg__actualOrigY(p);
-        sw = nsvg__actualWidth(p);
-        sh = nsvg__actualHeight(p);
-    }
-    sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f);
-
-    if (data->type == NSVG_PAINT_LINEAR_GRADIENT) {
-        float x1, y1, x2, y2, dx, dy;
-        x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
-        y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
-        x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
-        y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
-        // Calculate transform aligned to the line
-        dx = x2 - x1;
-        dy = y2 - y1;
-        grad->xform[0] = dy; grad->xform[1] = -dx;
-        grad->xform[2] = dx; grad->xform[3] = dy;
-        grad->xform[4] = x1; grad->xform[5] = y1;
-    } else {
-        float cx, cy, fx, fy, r;
-        cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
-        cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
-        fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
-        fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
-        r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
-        // Calculate transform aligned to the circle
-        grad->xform[0] = r; grad->xform[1] = 0;
-        grad->xform[2] = 0; grad->xform[3] = r;
-        grad->xform[4] = cx; grad->xform[5] = cy;
-        grad->fx = fx / r;
-        grad->fy = fy / r;
-    }
-
-    if( data->units ==  NSVG_OBJECT_SPACE)
-    {
-      float scaling[6],t[6];
-      scaling[0] = 1.0 / ( localBounds[2] - localBounds[0] );
-      scaling[1] = 0.0;
-      scaling[2] = 0.0;
-      scaling[3] = 1.0 / ( localBounds[3] - localBounds[1]);
-      scaling[4] = -localBounds[0] * scaling[0];
-      scaling[5] = -localBounds[1] * scaling[3];
-      memcpy(t, scaling, sizeof(float)*6);
-      nsvg__xformInverse(scaling, t);
-      nsvg__xformMultiply(grad->xform, data->xform);
-      nsvg__xformMultiply(grad->xform, scaling);
-      nsvg__xformMultiply(grad->xform, attr->xform);
-    }
-    else
-    {
-      nsvg__xformMultiply(grad->xform, data->xform);
-      nsvg__xformMultiply(grad->xform, attr->xform);
-    }
-
-    grad->spread = data->spread;
-    memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
-    grad->nstops = nstops;
-
-    *paintType = data->type;
-
-    return grad;
+       NSVGattrib* attr = nsvg__getAttr(p);
+       NSVGgradientData* data = NULL;
+       NSVGgradientData* ref = NULL;
+       NSVGgradientStop* stops = NULL;
+       NSVGgradient* grad;
+       float ox, oy, sw, sh, sl;
+       int nstops = 0;
+
+       data = nsvg__findGradientData(p, id);
+       if (data == NULL) return NULL;
+
+       // TODO: use ref to fill in all unset values too.
+       ref = data;
+       while (ref != NULL) {
+               if (stops == NULL && ref->stops != NULL) {
+                       stops = ref->stops;
+                       nstops = ref->nstops;
+                       break;
+               }
+               ref = nsvg__findGradientData(p, ref->ref);
+       }
+       if (stops == NULL) return NULL;
+
+       grad = (NSVGgradient*)malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
+       if (grad == NULL) return NULL;
+
+       // The shape width and height.
+       if (data->units == NSVG_OBJECT_SPACE) {
+               ox = localBounds[0];
+               oy = localBounds[1];
+               sw = localBounds[2] - localBounds[0];
+               sh = localBounds[3] - localBounds[1];
+       } else {
+               ox = nsvg__actualOrigX(p);
+               oy = nsvg__actualOrigY(p);
+               sw = nsvg__actualWidth(p);
+               sh = nsvg__actualHeight(p);
+       }
+       sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f);
+
+       if (data->type == NSVG_PAINT_LINEAR_GRADIENT) {
+               float x1, y1, x2, y2, dx, dy;
+               x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
+               y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
+               x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
+               y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
+               // Calculate transform aligned to the line
+               dx = x2 - x1;
+               dy = y2 - y1;
+               grad->xform[0] = dy; grad->xform[1] = -dx;
+               grad->xform[2] = dx; grad->xform[3] = dy;
+               grad->xform[4] = x1; grad->xform[5] = y1;
+       } else {
+               float cx, cy, fx, fy, r;
+               cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
+               cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
+               fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
+               fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
+               r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
+               // Calculate transform aligned to the circle
+               grad->xform[0] = r; grad->xform[1] = 0;
+               grad->xform[2] = 0; grad->xform[3] = r;
+               grad->xform[4] = cx; grad->xform[5] = cy;
+               grad->fx = fx / r;
+               grad->fy = fy / r;
+       }
+
+       nsvg__xformMultiply(grad->xform, data->xform);
+       nsvg__xformMultiply(grad->xform, attr->xform);
+
+       grad->spread = data->spread;
+       memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
+       grad->nstops = nstops;
+
+       *paintType = data->type;
+
+       return grad;
 }
 
 static float nsvg__getAverageScale(float* t)
 {
-    float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
-    float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
-    return (sx + sy) * 0.5f;
+       float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
+       float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
+       return (sx + sy) * 0.5f;
 }
 
 static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform)
 {
-    NSVGpath* path;
-    float curve[4*2], curveBounds[4];
-    int i, first = 1;
-    for (path = shape->paths; path != NULL; path = path->next) {
-        nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
-        for (i = 0; i < path->npts-1; i += 3) {
-            nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
-            nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
-            nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
-            nsvg__curveBounds(curveBounds, curve);
-            if (first) {
-                bounds[0] = curveBounds[0];
-                bounds[1] = curveBounds[1];
-                bounds[2] = curveBounds[2];
-                bounds[3] = curveBounds[3];
-                first = 0;
-            } else {
-                bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
-                bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
-                bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
-                bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
-            }
-            curve[0] = curve[6];
-            curve[1] = curve[7];
-        }
-    }
+       NSVGpath* path;
+       float curve[4*2], curveBounds[4];
+       int i, first = 1;
+       for (path = shape->paths; path != NULL; path = path->next) {
+               nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
+               for (i = 0; i < path->npts-1; i += 3) {
+                       nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
+                       nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
+                       nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
+                       nsvg__curveBounds(curveBounds, curve);
+                       if (first) {
+                               bounds[0] = curveBounds[0];
+                               bounds[1] = curveBounds[1];
+                               bounds[2] = curveBounds[2];
+                               bounds[3] = curveBounds[3];
+                               first = 0;
+                       } else {
+                               bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
+                               bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
+                               bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
+                               bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
+                       }
+                       curve[0] = curve[6];
+                       curve[1] = curve[7];
+               }
+       }
 }
 
 static void nsvg__addShape(NSVGparser* p)
 {
-    NSVGattrib* attr = nsvg__getAttr(p);
-    float scale = 1.0f;
-    NSVGshape *shape, *cur, *prev;
-    NSVGpath* path;
-    int i;
-
-    if (p->plist == NULL)
-        return;
-
-    shape = (NSVGshape*)malloc(sizeof(NSVGshape));
-    if (shape == NULL) goto error;
-    memset(shape, 0, sizeof(NSVGshape));
-
-    memcpy(shape->id, attr->id, sizeof shape->id);
-    scale = nsvg__getAverageScale(attr->xform);
-    shape->strokeWidth = attr->strokeWidth * scale;
-    shape->strokeDashOffset = attr->strokeDashOffset * scale;
-    shape->strokeDashCount = attr->strokeDashCount;
-    for (i = 0; i < attr->strokeDashCount; i++)
-        shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
-    shape->strokeLineJoin = attr->strokeLineJoin;
-    shape->strokeLineCap = attr->strokeLineCap;
-    shape->fillRule = attr->fillRule;
-    shape->opacity = attr->opacity;
-
-    shape->paths = p->plist;
-    p->plist = NULL;
-
-    // Calculate shape bounds
-    shape->bounds[0] = shape->paths->bounds[0];
-    shape->bounds[1] = shape->paths->bounds[1];
-    shape->bounds[2] = shape->paths->bounds[2];
-    shape->bounds[3] = shape->paths->bounds[3];
-    for (path = shape->paths->next; path != NULL; path = path->next) {
-        shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
-        shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
-        shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
-        shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
-    }
-
-    // Set fill
-    if (attr->hasFill == 0) {
-        shape->fill.type = NSVG_PAINT_NONE;
-    } else if (attr->hasFill == 1) {
-        shape->fill.type = NSVG_PAINT_COLOR;
-        shape->fill.color = attr->fillColor;
-        shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
-    } else if (attr->hasFill == 2) {
-        shape->opacity *= attr->fillOpacity;
-        float inv[6], localBounds[4];
-        nsvg__xformInverse(inv, attr->xform);
-        nsvg__getLocalBounds(localBounds, shape, inv);
-        shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
-        if (shape->fill.gradient == NULL) {
-            shape->fill.type = NSVG_PAINT_NONE;
-        }
-    }
-
-    // Set stroke
-    if (attr->hasStroke == 0) {
-        shape->stroke.type = NSVG_PAINT_NONE;
-    } else if (attr->hasStroke == 1) {
-        shape->stroke.type = NSVG_PAINT_COLOR;
-        shape->stroke.color = attr->strokeColor;
-        shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
-    } else if (attr->hasStroke == 2) {
-        float inv[6], localBounds[4];
-        nsvg__xformInverse(inv, attr->xform);
-        nsvg__getLocalBounds(localBounds, shape, inv);
-        shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
-        if (shape->stroke.gradient == NULL)
-            shape->stroke.type = NSVG_PAINT_NONE;
-    }
-
-    // Set flags
-    shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
-
-    // Add to tail
-    prev = NULL;
-    cur = p->image->shapes;
-    while (cur != NULL) {
-        prev = cur;
-        cur = cur->next;
-    }
-    if (prev == NULL)
-        p->image->shapes = shape;
-    else
-        prev->next = shape;
-
-    return;
+       NSVGattrib* attr = nsvg__getAttr(p);
+       float scale = 1.0f;
+       NSVGshape* shape;
+       NSVGpath* path;
+       int i;
+
+       if (p->plist == NULL)
+               return;
+
+       shape = (NSVGshape*)malloc(sizeof(NSVGshape));
+       if (shape == NULL) goto error;
+       memset(shape, 0, sizeof(NSVGshape));
+
+       memcpy(shape->id, attr->id, sizeof shape->id);
+       scale = nsvg__getAverageScale(attr->xform);
+       shape->strokeWidth = attr->strokeWidth * scale;
+       shape->strokeDashOffset = attr->strokeDashOffset * scale;
+       shape->strokeDashCount = (char)attr->strokeDashCount;
+       for (i = 0; i < attr->strokeDashCount; i++)
+               shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
+       shape->strokeLineJoin = attr->strokeLineJoin;
+       shape->strokeLineCap = attr->strokeLineCap;
+       shape->miterLimit = attr->miterLimit;
+       shape->fillRule = attr->fillRule;
+       shape->opacity = attr->opacity;
+
+       shape->paths = p->plist;
+       p->plist = NULL;
+
+       // Calculate shape bounds
+       shape->bounds[0] = shape->paths->bounds[0];
+       shape->bounds[1] = shape->paths->bounds[1];
+       shape->bounds[2] = shape->paths->bounds[2];
+       shape->bounds[3] = shape->paths->bounds[3];
+       for (path = shape->paths->next; path != NULL; path = path->next) {
+               shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
+               shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
+               shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
+               shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
+       }
+
+       // Set fill
+       if (attr->hasFill == 0) {
+               shape->fill.type = NSVG_PAINT_NONE;
+       } else if (attr->hasFill == 1) {
+               shape->fill.type = NSVG_PAINT_COLOR;
+               shape->fill.color = attr->fillColor;
+               shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
+       } else if (attr->hasFill == 2) {
+               shape->opacity *= attr->fillOpacity;
+               float inv[6], localBounds[4];
+               nsvg__xformInverse(inv, attr->xform);
+               nsvg__getLocalBounds(localBounds, shape, inv);
+               shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
+               if (shape->fill.gradient == NULL) {
+                       shape->fill.type = NSVG_PAINT_NONE;
+               }
+       }
+
+       // Set stroke
+       if (attr->hasStroke == 0) {
+               shape->stroke.type = NSVG_PAINT_NONE;
+       } else if (attr->hasStroke == 1) {
+               shape->stroke.type = NSVG_PAINT_COLOR;
+               shape->stroke.color = attr->strokeColor;
+               shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
+       } else if (attr->hasStroke == 2) {
+               float inv[6], localBounds[4];
+               nsvg__xformInverse(inv, attr->xform);
+               nsvg__getLocalBounds(localBounds, shape, inv);
+               shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
+               if (shape->stroke.gradient == NULL)
+                       shape->stroke.type = NSVG_PAINT_NONE;
+       }
+
+       // Set flags
+       shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
+
+       // Add to tail
+       if (p->image->shapes == NULL)
+               p->image->shapes = shape;
+       else
+               p->shapesTail->next = shape;
+       p->shapesTail = shape;
+
+       return;
 
 error:
-    if (shape) free(shape);
+       if (shape) free(shape);
 }
 
 static void nsvg__addPath(NSVGparser* p, char closed)
 {
-    NSVGattrib* attr = nsvg__getAttr(p);
-    NSVGpath* path = NULL;
-    float bounds[4];
-    float* curve;
-    int i;
-
-    if (p->npts < 4)
-        return;
-
-    if (closed)
-        nsvg__lineTo(p, p->pts[0], p->pts[1]);
-
-    path = (NSVGpath*)malloc(sizeof(NSVGpath));
-    if (path == NULL) goto error;
-    memset(path, 0, sizeof(NSVGpath));
-
-    path->pts = (float*)malloc(p->npts*2*sizeof(float));
-    if (path->pts == NULL) goto error;
-    path->closed = closed;
-    path->npts = p->npts;
-
-    // Transform path.
-    for (i = 0; i < p->npts; ++i)
-        nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
-
-    // Find bounds
-    for (i = 0; i < path->npts-1; i += 3) {
-        curve = &path->pts[i*2];
-        nsvg__curveBounds(bounds, curve);
-        if (i == 0) {
-            path->bounds[0] = bounds[0];
-            path->bounds[1] = bounds[1];
-            path->bounds[2] = bounds[2];
-            path->bounds[3] = bounds[3];
-        } else {
-            path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
-            path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
-            path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
-            path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
-        }
-    }
-
-    path->next = p->plist;
-    p->plist = path;
-
-    return;
+       NSVGattrib* attr = nsvg__getAttr(p);
+       NSVGpath* path = NULL;
+       float bounds[4];
+       float* curve;
+       int i;
+
+       if (p->npts < 4)
+               return;
+
+       if (closed)
+               nsvg__lineTo(p, p->pts[0], p->pts[1]);
+
+       path = (NSVGpath*)malloc(sizeof(NSVGpath));
+       if (path == NULL) goto error;
+       memset(path, 0, sizeof(NSVGpath));
+
+       path->pts = (float*)malloc(p->npts*2*sizeof(float));
+       if (path->pts == NULL) goto error;
+       path->closed = closed;
+       path->npts = p->npts;
+
+       // Transform path.
+       for (i = 0; i < p->npts; ++i)
+               nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
+
+       // Find bounds
+       for (i = 0; i < path->npts-1; i += 3) {
+               curve = &path->pts[i*2];
+               nsvg__curveBounds(bounds, curve);
+               if (i == 0) {
+                       path->bounds[0] = bounds[0];
+                       path->bounds[1] = bounds[1];
+                       path->bounds[2] = bounds[2];
+                       path->bounds[3] = bounds[3];
+               } else {
+                       path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
+                       path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
+                       path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
+                       path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
+               }
+       }
+
+       path->next = p->plist;
+       p->plist = path;
+
+       return;
 
 error:
-    if (path != NULL) {
-        if (path->pts != NULL) free(path->pts);
-        free(path);
-    }
+       if (path != NULL) {
+               if (path->pts != NULL) free(path->pts);
+               free(path);
+       }
+}
+
+// We roll our own string to float because the std library one uses locale and messes things up.
+static double nsvg__atof(const char* s)
+{
+       char* cur = (char*)s;
+       char* end = NULL;
+       double res = 0.0, sign = 1.0;
+       long long intPart = 0, fracPart = 0;
+       char hasIntPart = 0, hasFracPart = 0;
+
+       // Parse optional sign
+       if (*cur == '+') {
+               cur++;
+       } else if (*cur == '-') {
+               sign = -1;
+               cur++;
+       }
+
+       // Parse integer part
+       if (nsvg__isdigit(*cur)) {
+               // Parse digit sequence
+               intPart = (double)strtoll(cur, &end, 10);
+               if (cur != end) {
+                       res = (double)intPart;
+                       hasIntPart = 1;
+                       cur = end;
+               }
+       }
+
+       // Parse fractional part.
+       if (*cur == '.') {
+               cur++; // Skip '.'
+               if (nsvg__isdigit(*cur)) {
+                       // Parse digit sequence
+                       fracPart = strtoll(cur, &end, 10);
+                       if (cur != end) {
+                               res += (double)fracPart / pow(10.0, (double)(end - cur));
+                               hasFracPart = 1;
+                               cur = end;
+                       }
+               }
+       }
+
+       // A valid number should have integer or fractional part.
+       if (!hasIntPart && !hasFracPart)
+               return 0.0;
+
+       // Parse optional exponent
+       if (*cur == 'e' || *cur == 'E') {
+               int expPart = 0;
+               cur++; // skip 'E'
+               expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
+               if (cur != end) {
+                       res *= pow(10.0, (double)expPart);
+               }
+       }
+
+       return res * sign;
 }
 
+
 static const char* nsvg__parseNumber(const char* s, char* it, const int size)
 {
-    const int last = size-1;
-    int i = 0;
-
-    // sign
-    if (*s == '-' || *s == '+') {
-        if (i < last) it[i++] = *s;
-        s++;
-    }
-    // integer part
-    while (*s && nsvg__isdigit(*s)) {
-        if (i < last) it[i++] = *s;
-        s++;
-    }
-    if (*s == '.') {
-        // decimal point
-        if (i < last) it[i++] = *s;
-        s++;
-        // fraction part
-        while (*s && nsvg__isdigit(*s)) {
-            if (i < last) it[i++] = *s;
-            s++;
-        }
-    }
-    // exponent
-    if (*s == 'e' || *s == 'E') {
-        if (i < last) it[i++] = *s;
-        s++;
-        if (*s == '-' || *s == '+') {
-            if (i < last) it[i++] = *s;
-            s++;
-        }
-        while (*s && nsvg__isdigit(*s)) {
-            if (i < last) it[i++] = *s;
-            s++;
-        }
-    }
-    it[i] = '\0';
-
-    return s;
+       const int last = size-1;
+       int i = 0;
+
+       // sign
+       if (*s == '-' || *s == '+') {
+               if (i < last) it[i++] = *s;
+               s++;
+       }
+       // integer part
+       while (*s && nsvg__isdigit(*s)) {
+               if (i < last) it[i++] = *s;
+               s++;
+       }
+       if (*s == '.') {
+               // decimal point
+               if (i < last) it[i++] = *s;
+               s++;
+               // fraction part
+               while (*s && nsvg__isdigit(*s)) {
+                       if (i < last) it[i++] = *s;
+                       s++;
+               }
+       }
+       // exponent
+       if (*s == 'e' || *s == 'E') {
+               if (i < last) it[i++] = *s;
+               s++;
+               if (*s == '-' || *s == '+') {
+                       if (i < last) it[i++] = *s;
+                       s++;
+               }
+               while (*s && nsvg__isdigit(*s)) {
+                       if (i < last) it[i++] = *s;
+                       s++;
+               }
+       }
+       it[i] = '\0';
+
+       return s;
 }
 
 static const char* nsvg__getNextPathItem(const char* s, char* it)
 {
-    it[0] = '\0';
-    // Skip white spaces and commas
-    while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
-    if (!*s) return s;
-    if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
-        s = nsvg__parseNumber(s, it, 64);
-    } else {
-        // Parse command
-        it[0] = *s++;
-        it[1] = '\0';
-        return s;
-    }
+       it[0] = '\0';
+       // Skip white spaces and commas
+       while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+       if (!*s) return s;
+       if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
+               s = nsvg__parseNumber(s, it, 64);
+       } else {
+               // Parse command
+               it[0] = *s++;
+               it[1] = '\0';
+               return s;
+       }
 
-    return s;
+       return s;
 }
 
 static unsigned int nsvg__parseColorHex(const char* str)
 {
-    unsigned int c = 0, r = 0, g = 0, b = 0;
-    int n = 0;
-    str++; // skip #
-    // Calculate number of characters.
-    while(str[n] && !nsvg__isspace(str[n]))
-        n++;
-    if (n == 6) {
-        sscanf(str, "%x", &c);
-    } else if (n == 3) {
-        sscanf(str, "%x", &c);
-        c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
-        c |= c<<4;
-    }
-    r = (c >> 16) & 0xff;
-    g = (c >> 8) & 0xff;
-    b = c & 0xff;
-    return NSVG_RGB(r,g,b);
+       unsigned int c = 0, r = 0, g = 0, b = 0;
+       int n = 0;
+       str++; // skip #
+       // Calculate number of characters.
+       while(str[n] && !nsvg__isspace(str[n]))
+               n++;
+       if (n == 6) {
+               sscanf(str, "%x", &c);
+       } else if (n == 3) {
+               sscanf(str, "%x", &c);
+               c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
+               c |= c<<4;
+       }
+       r = (c >> 16) & 0xff;
+       g = (c >> 8) & 0xff;
+       b = c & 0xff;
+       return NSVG_RGB(r,g,b);
 }
 
 static unsigned int nsvg__parseColorRGB(const char* str)
 {
-    int r = -1, g = -1, b = -1;
-    char s1[32]="", s2[32]="";
-
-    /**
-     * In the original file, the formatted data reading did not specify the string with width limitation.
-     * To prevent the possible overflow, we replace '%s' with '%32s' here.
-     */
-    sscanf(str + 4, "%d%32[%%, \t]%d%32[%%, \t]%d", &r, s1, &g, s2, &b);
-    if (strchr(s1, '%')) {
-        return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
-    } else {
-        return NSVG_RGB(r,g,b);
-    }
+       int r = -1, g = -1, b = -1;
+       char s1[32]="", s2[32]="";
+       /**
+        * In the original file, the formatted data reading did not specify the string with width limitation.
+        * To prevent the possible overflow, we replace '%s' with '%32s' here.
+        */
+       sscanf(str + 4, "%d%32[%%, \t]%d%32[%%, \t]%d", &r, s1, &g, s2, &b);
+       if (strchr(s1, '%')) {
+               return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
+       } else {
+               return NSVG_RGB(r,g,b);
+       }
 }
 
 typedef struct NSVGNamedColor {
-    const char* name;
-    unsigned int color;
+       const char* name;
+       unsigned int color;
 } NSVGNamedColor;
 
 NSVGNamedColor nsvg__colors[] = {
 
-    { "red", NSVG_RGB(255, 0, 0) },
-    { "green", NSVG_RGB( 0, 128, 0) },
-    { "blue", NSVG_RGB( 0, 0, 255) },
-    { "yellow", NSVG_RGB(255, 255, 0) },
-    { "cyan", NSVG_RGB( 0, 255, 255) },
-    { "magenta", NSVG_RGB(255, 0, 255) },
-    { "black", NSVG_RGB( 0, 0, 0) },
-    { "grey", NSVG_RGB(128, 128, 128) },
-    { "gray", NSVG_RGB(128, 128, 128) },
-    { "white", NSVG_RGB(255, 255, 255) },
-
-    { "aliceblue", NSVG_RGB(240, 248, 255) },
-    { "antiquewhite", NSVG_RGB(250, 235, 215) },
-    { "aqua", NSVG_RGB( 0, 255, 255) },
-    { "aquamarine", NSVG_RGB(127, 255, 212) },
-    { "azure", NSVG_RGB(240, 255, 255) },
-    { "beige", NSVG_RGB(245, 245, 220) },
-    { "bisque", NSVG_RGB(255, 228, 196) },
-    { "blanchedalmond", NSVG_RGB(255, 235, 205) },
-    { "blueviolet", NSVG_RGB(138, 43, 226) },
-    { "brown", NSVG_RGB(165, 42, 42) },
-    { "burlywood", NSVG_RGB(222, 184, 135) },
-    { "cadetblue", NSVG_RGB( 95, 158, 160) },
-    { "chartreuse", NSVG_RGB(127, 255, 0) },
-    { "chocolate", NSVG_RGB(210, 105, 30) },
-    { "coral", NSVG_RGB(255, 127, 80) },
-    { "cornflowerblue", NSVG_RGB(100, 149, 237) },
-    { "cornsilk", NSVG_RGB(255, 248, 220) },
-    { "crimson", NSVG_RGB(220, 20, 60) },
-    { "darkblue", NSVG_RGB( 0, 0, 139) },
-    { "darkcyan", NSVG_RGB( 0, 139, 139) },
-    { "darkgoldenrod", NSVG_RGB(184, 134, 11) },
-    { "darkgray", NSVG_RGB(169, 169, 169) },
-    { "darkgreen", NSVG_RGB( 0, 100, 0) },
-    { "darkgrey", NSVG_RGB(169, 169, 169) },
-    { "darkkhaki", NSVG_RGB(189, 183, 107) },
-    { "darkmagenta", NSVG_RGB(139, 0, 139) },
-    { "darkolivegreen", NSVG_RGB( 85, 107, 47) },
-    { "darkorange", NSVG_RGB(255, 140, 0) },
-    { "darkorchid", NSVG_RGB(153, 50, 204) },
-    { "darkred", NSVG_RGB(139, 0, 0) },
-    { "darksalmon", NSVG_RGB(233, 150, 122) },
-    { "darkseagreen", NSVG_RGB(143, 188, 143) },
-    { "darkslateblue", NSVG_RGB( 72, 61, 139) },
-    { "darkslategray", NSVG_RGB( 47, 79, 79) },
-    { "darkslategrey", NSVG_RGB( 47, 79, 79) },
-    { "darkturquoise", NSVG_RGB( 0, 206, 209) },
-    { "darkviolet", NSVG_RGB(148, 0, 211) },
-    { "deeppink", NSVG_RGB(255, 20, 147) },
-    { "deepskyblue", NSVG_RGB( 0, 191, 255) },
-    { "dimgray", NSVG_RGB(105, 105, 105) },
-    { "dimgrey", NSVG_RGB(105, 105, 105) },
-    { "dodgerblue", NSVG_RGB( 30, 144, 255) },
-    { "firebrick", NSVG_RGB(178, 34, 34) },
-    { "floralwhite", NSVG_RGB(255, 250, 240) },
-    { "forestgreen", NSVG_RGB( 34, 139, 34) },
-    { "fuchsia", NSVG_RGB(255, 0, 255) },
-    { "gainsboro", NSVG_RGB(220, 220, 220) },
-    { "ghostwhite", NSVG_RGB(248, 248, 255) },
-    { "gold", NSVG_RGB(255, 215, 0) },
-    { "goldenrod", NSVG_RGB(218, 165, 32) },
-    { "greenyellow", NSVG_RGB(173, 255, 47) },
-    { "honeydew", NSVG_RGB(240, 255, 240) },
-    { "hotpink", NSVG_RGB(255, 105, 180) },
-    { "indianred", NSVG_RGB(205, 92, 92) },
-    { "indigo", NSVG_RGB( 75, 0, 130) },
-    { "ivory", NSVG_RGB(255, 255, 240) },
-    { "khaki", NSVG_RGB(240, 230, 140) },
-    { "lavender", NSVG_RGB(230, 230, 250) },
-    { "lavenderblush", NSVG_RGB(255, 240, 245) },
-    { "lawngreen", NSVG_RGB(124, 252, 0) },
-    { "lemonchiffon", NSVG_RGB(255, 250, 205) },
-    { "lightblue", NSVG_RGB(173, 216, 230) },
-    { "lightcoral", NSVG_RGB(240, 128, 128) },
-    { "lightcyan", NSVG_RGB(224, 255, 255) },
-    { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
-    { "lightgray", NSVG_RGB(211, 211, 211) },
-    { "lightgreen", NSVG_RGB(144, 238, 144) },
-    { "lightgrey", NSVG_RGB(211, 211, 211) },
-    { "lightpink", NSVG_RGB(255, 182, 193) },
-    { "lightsalmon", NSVG_RGB(255, 160, 122) },
-    { "lightseagreen", NSVG_RGB( 32, 178, 170) },
-    { "lightskyblue", NSVG_RGB(135, 206, 250) },
-    { "lightslategray", NSVG_RGB(119, 136, 153) },
-    { "lightslategrey", NSVG_RGB(119, 136, 153) },
-    { "lightsteelblue", NSVG_RGB(176, 196, 222) },
-    { "lightyellow", NSVG_RGB(255, 255, 224) },
-    { "lime", NSVG_RGB( 0, 255, 0) },
-    { "limegreen", NSVG_RGB( 50, 205, 50) },
-    { "linen", NSVG_RGB(250, 240, 230) },
-    { "maroon", NSVG_RGB(128, 0, 0) },
-    { "mediumaquamarine", NSVG_RGB(102, 205, 170) },
-    { "mediumblue", NSVG_RGB( 0, 0, 205) },
-    { "mediumorchid", NSVG_RGB(186, 85, 211) },
-    { "mediumpurple", NSVG_RGB(147, 112, 219) },
-    { "mediumseagreen", NSVG_RGB( 60, 179, 113) },
-    { "mediumslateblue", NSVG_RGB(123, 104, 238) },
-    { "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
-    { "mediumturquoise", NSVG_RGB( 72, 209, 204) },
-    { "mediumvioletred", NSVG_RGB(199, 21, 133) },
-    { "midnightblue", NSVG_RGB( 25, 25, 112) },
-    { "mintcream", NSVG_RGB(245, 255, 250) },
-    { "mistyrose", NSVG_RGB(255, 228, 225) },
-    { "moccasin", NSVG_RGB(255, 228, 181) },
-    { "navajowhite", NSVG_RGB(255, 222, 173) },
-    { "navy", NSVG_RGB( 0, 0, 128) },
-    { "oldlace", NSVG_RGB(253, 245, 230) },
-    { "olive", NSVG_RGB(128, 128, 0) },
-    { "olivedrab", NSVG_RGB(107, 142, 35) },
-    { "orange", NSVG_RGB(255, 165, 0) },
-    { "orangered", NSVG_RGB(255, 69, 0) },
-    { "orchid", NSVG_RGB(218, 112, 214) },
-    { "palegoldenrod", NSVG_RGB(238, 232, 170) },
-    { "palegreen", NSVG_RGB(152, 251, 152) },
-    { "paleturquoise", NSVG_RGB(175, 238, 238) },
-    { "palevioletred", NSVG_RGB(219, 112, 147) },
-    { "papayawhip", NSVG_RGB(255, 239, 213) },
-    { "peachpuff", NSVG_RGB(255, 218, 185) },
-    { "peru", NSVG_RGB(205, 133, 63) },
-    { "pink", NSVG_RGB(255, 192, 203) },
-    { "plum", NSVG_RGB(221, 160, 221) },
-    { "powderblue", NSVG_RGB(176, 224, 230) },
-    { "purple", NSVG_RGB(128, 0, 128) },
-    { "rosybrown", NSVG_RGB(188, 143, 143) },
-    { "royalblue", NSVG_RGB( 65, 105, 225) },
-    { "saddlebrown", NSVG_RGB(139, 69, 19) },
-    { "salmon", NSVG_RGB(250, 128, 114) },
-    { "sandybrown", NSVG_RGB(244, 164, 96) },
-    { "seagreen", NSVG_RGB( 46, 139, 87) },
-    { "seashell", NSVG_RGB(255, 245, 238) },
-    { "sienna", NSVG_RGB(160, 82, 45) },
-    { "silver", NSVG_RGB(192, 192, 192) },
-    { "skyblue", NSVG_RGB(135, 206, 235) },
-    { "slateblue", NSVG_RGB(106, 90, 205) },
-    { "slategray", NSVG_RGB(112, 128, 144) },
-    { "slategrey", NSVG_RGB(112, 128, 144) },
-    { "snow", NSVG_RGB(255, 250, 250) },
-    { "springgreen", NSVG_RGB( 0, 255, 127) },
-    { "steelblue", NSVG_RGB( 70, 130, 180) },
-    { "tan", NSVG_RGB(210, 180, 140) },
-    { "teal", NSVG_RGB( 0, 128, 128) },
-    { "thistle", NSVG_RGB(216, 191, 216) },
-    { "tomato", NSVG_RGB(255, 99, 71) },
-    { "turquoise", NSVG_RGB( 64, 224, 208) },
-    { "violet", NSVG_RGB(238, 130, 238) },
-    { "wheat", NSVG_RGB(245, 222, 179) },
-    { "whitesmoke", NSVG_RGB(245, 245, 245) },
-    { "yellowgreen", NSVG_RGB(154, 205, 50) },
+       { "red", NSVG_RGB(255, 0, 0) },
+       { "green", NSVG_RGB( 0, 128, 0) },
+       { "blue", NSVG_RGB( 0, 0, 255) },
+       { "yellow", NSVG_RGB(255, 255, 0) },
+       { "cyan", NSVG_RGB( 0, 255, 255) },
+       { "magenta", NSVG_RGB(255, 0, 255) },
+       { "black", NSVG_RGB( 0, 0, 0) },
+       { "grey", NSVG_RGB(128, 128, 128) },
+       { "gray", NSVG_RGB(128, 128, 128) },
+       { "white", NSVG_RGB(255, 255, 255) },
+
+       { "aliceblue", NSVG_RGB(240, 248, 255) },
+       { "antiquewhite", NSVG_RGB(250, 235, 215) },
+       { "aqua", NSVG_RGB( 0, 255, 255) },
+       { "aquamarine", NSVG_RGB(127, 255, 212) },
+       { "azure", NSVG_RGB(240, 255, 255) },
+       { "beige", NSVG_RGB(245, 245, 220) },
+       { "bisque", NSVG_RGB(255, 228, 196) },
+       { "blanchedalmond", NSVG_RGB(255, 235, 205) },
+       { "blueviolet", NSVG_RGB(138, 43, 226) },
+       { "brown", NSVG_RGB(165, 42, 42) },
+       { "burlywood", NSVG_RGB(222, 184, 135) },
+       { "cadetblue", NSVG_RGB( 95, 158, 160) },
+       { "chartreuse", NSVG_RGB(127, 255, 0) },
+       { "chocolate", NSVG_RGB(210, 105, 30) },
+       { "coral", NSVG_RGB(255, 127, 80) },
+       { "cornflowerblue", NSVG_RGB(100, 149, 237) },
+       { "cornsilk", NSVG_RGB(255, 248, 220) },
+       { "crimson", NSVG_RGB(220, 20, 60) },
+       { "darkblue", NSVG_RGB( 0, 0, 139) },
+       { "darkcyan", NSVG_RGB( 0, 139, 139) },
+       { "darkgoldenrod", NSVG_RGB(184, 134, 11) },
+       { "darkgray", NSVG_RGB(169, 169, 169) },
+       { "darkgreen", NSVG_RGB( 0, 100, 0) },
+       { "darkgrey", NSVG_RGB(169, 169, 169) },
+       { "darkkhaki", NSVG_RGB(189, 183, 107) },
+       { "darkmagenta", NSVG_RGB(139, 0, 139) },
+       { "darkolivegreen", NSVG_RGB( 85, 107, 47) },
+       { "darkorange", NSVG_RGB(255, 140, 0) },
+       { "darkorchid", NSVG_RGB(153, 50, 204) },
+       { "darkred", NSVG_RGB(139, 0, 0) },
+       { "darksalmon", NSVG_RGB(233, 150, 122) },
+       { "darkseagreen", NSVG_RGB(143, 188, 143) },
+       { "darkslateblue", NSVG_RGB( 72, 61, 139) },
+       { "darkslategray", NSVG_RGB( 47, 79, 79) },
+       { "darkslategrey", NSVG_RGB( 47, 79, 79) },
+       { "darkturquoise", NSVG_RGB( 0, 206, 209) },
+       { "darkviolet", NSVG_RGB(148, 0, 211) },
+       { "deeppink", NSVG_RGB(255, 20, 147) },
+       { "deepskyblue", NSVG_RGB( 0, 191, 255) },
+       { "dimgray", NSVG_RGB(105, 105, 105) },
+       { "dimgrey", NSVG_RGB(105, 105, 105) },
+       { "dodgerblue", NSVG_RGB( 30, 144, 255) },
+       { "firebrick", NSVG_RGB(178, 34, 34) },
+       { "floralwhite", NSVG_RGB(255, 250, 240) },
+       { "forestgreen", NSVG_RGB( 34, 139, 34) },
+       { "fuchsia", NSVG_RGB(255, 0, 255) },
+       { "gainsboro", NSVG_RGB(220, 220, 220) },
+       { "ghostwhite", NSVG_RGB(248, 248, 255) },
+       { "gold", NSVG_RGB(255, 215, 0) },
+       { "goldenrod", NSVG_RGB(218, 165, 32) },
+       { "greenyellow", NSVG_RGB(173, 255, 47) },
+       { "honeydew", NSVG_RGB(240, 255, 240) },
+       { "hotpink", NSVG_RGB(255, 105, 180) },
+       { "indianred", NSVG_RGB(205, 92, 92) },
+       { "indigo", NSVG_RGB( 75, 0, 130) },
+       { "ivory", NSVG_RGB(255, 255, 240) },
+       { "khaki", NSVG_RGB(240, 230, 140) },
+       { "lavender", NSVG_RGB(230, 230, 250) },
+       { "lavenderblush", NSVG_RGB(255, 240, 245) },
+       { "lawngreen", NSVG_RGB(124, 252, 0) },
+       { "lemonchiffon", NSVG_RGB(255, 250, 205) },
+       { "lightblue", NSVG_RGB(173, 216, 230) },
+       { "lightcoral", NSVG_RGB(240, 128, 128) },
+       { "lightcyan", NSVG_RGB(224, 255, 255) },
+       { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
+       { "lightgray", NSVG_RGB(211, 211, 211) },
+       { "lightgreen", NSVG_RGB(144, 238, 144) },
+       { "lightgrey", NSVG_RGB(211, 211, 211) },
+       { "lightpink", NSVG_RGB(255, 182, 193) },
+       { "lightsalmon", NSVG_RGB(255, 160, 122) },
+       { "lightseagreen", NSVG_RGB( 32, 178, 170) },
+       { "lightskyblue", NSVG_RGB(135, 206, 250) },
+       { "lightslategray", NSVG_RGB(119, 136, 153) },
+       { "lightslategrey", NSVG_RGB(119, 136, 153) },
+       { "lightsteelblue", NSVG_RGB(176, 196, 222) },
+       { "lightyellow", NSVG_RGB(255, 255, 224) },
+       { "lime", NSVG_RGB( 0, 255, 0) },
+       { "limegreen", NSVG_RGB( 50, 205, 50) },
+       { "linen", NSVG_RGB(250, 240, 230) },
+       { "maroon", NSVG_RGB(128, 0, 0) },
+       { "mediumaquamarine", NSVG_RGB(102, 205, 170) },
+       { "mediumblue", NSVG_RGB( 0, 0, 205) },
+       { "mediumorchid", NSVG_RGB(186, 85, 211) },
+       { "mediumpurple", NSVG_RGB(147, 112, 219) },
+       { "mediumseagreen", NSVG_RGB( 60, 179, 113) },
+       { "mediumslateblue", NSVG_RGB(123, 104, 238) },
+       { "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
+       { "mediumturquoise", NSVG_RGB( 72, 209, 204) },
+       { "mediumvioletred", NSVG_RGB(199, 21, 133) },
+       { "midnightblue", NSVG_RGB( 25, 25, 112) },
+       { "mintcream", NSVG_RGB(245, 255, 250) },
+       { "mistyrose", NSVG_RGB(255, 228, 225) },
+       { "moccasin", NSVG_RGB(255, 228, 181) },
+       { "navajowhite", NSVG_RGB(255, 222, 173) },
+       { "navy", NSVG_RGB( 0, 0, 128) },
+       { "oldlace", NSVG_RGB(253, 245, 230) },
+       { "olive", NSVG_RGB(128, 128, 0) },
+       { "olivedrab", NSVG_RGB(107, 142, 35) },
+       { "orange", NSVG_RGB(255, 165, 0) },
+       { "orangered", NSVG_RGB(255, 69, 0) },
+       { "orchid", NSVG_RGB(218, 112, 214) },
+       { "palegoldenrod", NSVG_RGB(238, 232, 170) },
+       { "palegreen", NSVG_RGB(152, 251, 152) },
+       { "paleturquoise", NSVG_RGB(175, 238, 238) },
+       { "palevioletred", NSVG_RGB(219, 112, 147) },
+       { "papayawhip", NSVG_RGB(255, 239, 213) },
+       { "peachpuff", NSVG_RGB(255, 218, 185) },
+       { "peru", NSVG_RGB(205, 133, 63) },
+       { "pink", NSVG_RGB(255, 192, 203) },
+       { "plum", NSVG_RGB(221, 160, 221) },
+       { "powderblue", NSVG_RGB(176, 224, 230) },
+       { "purple", NSVG_RGB(128, 0, 128) },
+       { "rosybrown", NSVG_RGB(188, 143, 143) },
+       { "royalblue", NSVG_RGB( 65, 105, 225) },
+       { "saddlebrown", NSVG_RGB(139, 69, 19) },
+       { "salmon", NSVG_RGB(250, 128, 114) },
+       { "sandybrown", NSVG_RGB(244, 164, 96) },
+       { "seagreen", NSVG_RGB( 46, 139, 87) },
+       { "seashell", NSVG_RGB(255, 245, 238) },
+       { "sienna", NSVG_RGB(160, 82, 45) },
+       { "silver", NSVG_RGB(192, 192, 192) },
+       { "skyblue", NSVG_RGB(135, 206, 235) },
+       { "slateblue", NSVG_RGB(106, 90, 205) },
+       { "slategray", NSVG_RGB(112, 128, 144) },
+       { "slategrey", NSVG_RGB(112, 128, 144) },
+       { "snow", NSVG_RGB(255, 250, 250) },
+       { "springgreen", NSVG_RGB( 0, 255, 127) },
+       { "steelblue", NSVG_RGB( 70, 130, 180) },
+       { "tan", NSVG_RGB(210, 180, 140) },
+       { "teal", NSVG_RGB( 0, 128, 128) },
+       { "thistle", NSVG_RGB(216, 191, 216) },
+       { "tomato", NSVG_RGB(255, 99, 71) },
+       { "turquoise", NSVG_RGB( 64, 224, 208) },
+       { "violet", NSVG_RGB(238, 130, 238) },
+       { "wheat", NSVG_RGB(245, 222, 179) },
+       { "whitesmoke", NSVG_RGB(245, 245, 245) },
+       { "yellowgreen", NSVG_RGB(154, 205, 50) },
 };
 
 static unsigned int nsvg__parseColorName(const char* str)
 {
-    int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
+       int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
 
-    for (i = 0; i < ncolors; i++) {
-        if (strcmp(nsvg__colors[i].name, str) == 0) {
-            return nsvg__colors[i].color;
-        }
-    }
+       for (i = 0; i < ncolors; i++) {
+               if (strcmp(nsvg__colors[i].name, str) == 0) {
+                       return nsvg__colors[i].color;
+               }
+       }
 
-    return NSVG_RGB(128, 128, 128);
+       return NSVG_RGB(128, 128, 128);
 }
 
 static unsigned int nsvg__parseColor(const char* str)
 {
-    size_t len = 0;
-    while(*str == ' ') ++str;
-    len = strlen(str);
-    if (len >= 1 && *str == '#')
-        return nsvg__parseColorHex(str);
-    else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
-        return nsvg__parseColorRGB(str);
-    return nsvg__parseColorName(str);
+       size_t len = 0;
+       while(*str == ' ') ++str;
+       len = strlen(str);
+       if (len >= 1 && *str == '#')
+               return nsvg__parseColorHex(str);
+       else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
+               return nsvg__parseColorRGB(str);
+       return nsvg__parseColorName(str);
 }
 
 static float nsvg__parseOpacity(const char* str)
 {
-    float val = 0;
-    sscanf(str, "%f", &val);
-    if (val < 0.0f) val = 0.0f;
-    if (val > 1.0f) val = 1.0f;
-    return val;
+       float val = 0;
+       sscanf(str, "%f", &val);
+       if (val < 0.0f) val = 0.0f;
+       if (val > 1.0f) val = 1.0f;
+       return val;
+}
+
+static float nsvg__parseMiterLimit(const char* str)
+{
+       float val = 0;
+       sscanf(str, "%f", &val);
+       if (val < 0.0f) val = 0.0f;
+       return val;
 }
 
 static int nsvg__parseUnits(const char* units)
 {
-    if (units[0] == 'p' && units[1] == 'x')
-        return NSVG_UNITS_PX;
-    else if (units[0] == 'p' && units[1] == 't')
-        return NSVG_UNITS_PT;
-    else if (units[0] == 'p' && units[1] == 'c')
-        return NSVG_UNITS_PC;
-    else if (units[0] == 'm' && units[1] == 'm')
-        return NSVG_UNITS_MM;
-    else if (units[0] == 'c' && units[1] == 'm')
-        return NSVG_UNITS_CM;
-    else if (units[0] == 'i' && units[1] == 'n')
-        return NSVG_UNITS_IN;
-    else if (units[0] == '%')
-        return NSVG_UNITS_PERCENT;
-    else if (units[0] == 'e' && units[1] == 'm')
-        return NSVG_UNITS_EM;
-    else if (units[0] == 'e' && units[1] == 'x')
-        return NSVG_UNITS_EX;
-    return NSVG_UNITS_USER;
+       if (units[0] == 'p' && units[1] == 'x')
+               return NSVG_UNITS_PX;
+       else if (units[0] == 'p' && units[1] == 't')
+               return NSVG_UNITS_PT;
+       else if (units[0] == 'p' && units[1] == 'c')
+               return NSVG_UNITS_PC;
+       else if (units[0] == 'm' && units[1] == 'm')
+               return NSVG_UNITS_MM;
+       else if (units[0] == 'c' && units[1] == 'm')
+               return NSVG_UNITS_CM;
+       else if (units[0] == 'i' && units[1] == 'n')
+               return NSVG_UNITS_IN;
+       else if (units[0] == '%')
+               return NSVG_UNITS_PERCENT;
+       else if (units[0] == 'e' && units[1] == 'm')
+               return NSVG_UNITS_EM;
+       else if (units[0] == 'e' && units[1] == 'x')
+               return NSVG_UNITS_EX;
+       return NSVG_UNITS_USER;
 }
 
 static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
 {
-    NSVGcoordinate coord = {0, NSVG_UNITS_USER};
-    char units[32]="";
-
-    /**
-     * In the original file, the formatted data reading did not specify the string with width limitation.
-     * To prevent the possible overflow, we replace '%s' with '%32s' here.
-     */
-    sscanf(str, "%f%32s", &coord.value, units);
-    coord.units = nsvg__parseUnits(units);
-    return coord;
+       NSVGcoordinate coord = {0, NSVG_UNITS_USER};
+       char units[32]="";
+       /**
+        * In the original file, the formatted data reading did not specify the string with width limitation.
+        * To prevent the possible overflow, we replace '%s' with '%32s' here.
+        */
+       sscanf(str, "%f%32s", &coord.value, units);
+       coord.units = nsvg__parseUnits(units);
+       return coord;
 }
 
 static NSVGcoordinate nsvg__coord(float v, int units)
 {
-    NSVGcoordinate coord = {v, units};
-    return coord;
+       NSVGcoordinate coord = {v, units};
+       return coord;
 }
 
 static float nsvg__parseCoordinate(NSVGparser* p, const char* str, float orig, float length)
 {
-    NSVGcoordinate coord = nsvg__parseCoordinateRaw(str);
-    return nsvg__convertToPixels(p, coord, orig, length);
+       NSVGcoordinate coord = nsvg__parseCoordinateRaw(str);
+       return nsvg__convertToPixels(p, coord, orig, length);
 }
 
 static int nsvg__parseTransformArgs(const char* str, float* args, int maxNa, int* na)
 {
-    const char* end;
-    const char* ptr;
-    char it[64];
-
-    *na = 0;
-    ptr = str;
-    while (*ptr && *ptr != '(') ++ptr;
-    if (*ptr == 0)
-        return 1;
-    end = ptr;
-    while (*end && *end != ')') ++end;
-    if (*end == 0)
-        return 1;
-
-    while (ptr < end) {
-        if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) {
-            if (*na >= maxNa) return 0;
-            ptr = nsvg__parseNumber(ptr, it, 64);
-            args[(*na)++] = (float)atof(it);
-        } else {
-            ++ptr;
-        }
-    }
-    return (int)(end - str);
+       const char* end;
+       const char* ptr;
+       char it[64];
+
+       *na = 0;
+       ptr = str;
+       while (*ptr && *ptr != '(') ++ptr;
+       if (*ptr == 0)
+               return 1;
+       end = ptr;
+       while (*end && *end != ')') ++end;
+       if (*end == 0)
+               return 1;
+
+       while (ptr < end) {
+               if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) {
+                       if (*na >= maxNa) return 0;
+                       ptr = nsvg__parseNumber(ptr, it, 64);
+                       args[(*na)++] = (float)nsvg__atof(it);
+               } else {
+                       ++ptr;
+               }
+       }
+       return (int)(end - str);
 }
 
 
 static int nsvg__parseMatrix(float* xform, const char* str)
 {
-    float t[6];
-    int na = 0;
-    int len = nsvg__parseTransformArgs(str, t, 6, &na);
-    if (na != 6) return len;
-    memcpy(xform, t, sizeof(float)*6);
-    return len;
+       float t[6];
+       int na = 0;
+       int len = nsvg__parseTransformArgs(str, t, 6, &na);
+       if (na != 6) return len;
+       memcpy(xform, t, sizeof(float)*6);
+       return len;
 }
 
 static int nsvg__parseTranslate(float* xform, const char* str)
 {
-    float args[2];
-    float t[6];
-    int na = 0;
-    int len = nsvg__parseTransformArgs(str, args, 2, &na);
-    if (na == 1) args[1] = 0.0;
+       float args[2];
+       float t[6];
+       int na = 0;
+       int len = nsvg__parseTransformArgs(str, args, 2, &na);
+       if (na == 1) args[1] = 0.0;
 
-    nsvg__xformSetTranslation(t, args[0], args[1]);
-    memcpy(xform, t, sizeof(float)*6);
-    return len;
+       nsvg__xformSetTranslation(t, args[0], args[1]);
+       memcpy(xform, t, sizeof(float)*6);
+       return len;
 }
 
 static int nsvg__parseScale(float* xform, const char* str)
 {
-    float args[2];
-    int na = 0;
-    float t[6];
-    int len = nsvg__parseTransformArgs(str, args, 2, &na);
-    if (na == 1) args[1] = args[0];
-    nsvg__xformSetScale(t, args[0], args[1]);
-    memcpy(xform, t, sizeof(float)*6);
-    return len;
+       float args[2];
+       int na = 0;
+       float t[6];
+       int len = nsvg__parseTransformArgs(str, args, 2, &na);
+       if (na == 1) args[1] = args[0];
+       nsvg__xformSetScale(t, args[0], args[1]);
+       memcpy(xform, t, sizeof(float)*6);
+       return len;
 }
 
 static int nsvg__parseSkewX(float* xform, const char* str)
 {
-    float args[1];
-    int na = 0;
-    float t[6];
-    int len = nsvg__parseTransformArgs(str, args, 1, &na);
-    nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI);
-    memcpy(xform, t, sizeof(float)*6);
-    return len;
+       float args[1];
+       int na = 0;
+       float t[6];
+       int len = nsvg__parseTransformArgs(str, args, 1, &na);
+       nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI);
+       memcpy(xform, t, sizeof(float)*6);
+       return len;
 }
 
 static int nsvg__parseSkewY(float* xform, const char* str)
 {
-    float args[1];
-    int na = 0;
-    float t[6];
-    int len = nsvg__parseTransformArgs(str, args, 1, &na);
-    nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI);
-    memcpy(xform, t, sizeof(float)*6);
-    return len;
+       float args[1];
+       int na = 0;
+       float t[6];
+       int len = nsvg__parseTransformArgs(str, args, 1, &na);
+       nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI);
+       memcpy(xform, t, sizeof(float)*6);
+       return len;
 }
 
 static int nsvg__parseRotate(float* xform, const char* str)
 {
-    float args[3];
-    int na = 0;
-    float m[6];
-    float t[6];
-    int len = nsvg__parseTransformArgs(str, args, 3, &na);
-    if (na == 1)
-        args[1] = args[2] = 0.0f;
-    nsvg__xformIdentity(m);
+       float args[3];
+       int na = 0;
+       float m[6];
+       float t[6];
+       int len = nsvg__parseTransformArgs(str, args, 3, &na);
+       if (na == 1)
+               args[1] = args[2] = 0.0f;
+       nsvg__xformIdentity(m);
 
-    if (na > 1) {
-        nsvg__xformSetTranslation(t, -args[1], -args[2]);
-        nsvg__xformMultiply(m, t);
-    }
+       if (na > 1) {
+               nsvg__xformSetTranslation(t, -args[1], -args[2]);
+               nsvg__xformMultiply(m, t);
+       }
 
-    nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI);
-    nsvg__xformMultiply(m, t);
+       nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI);
+       nsvg__xformMultiply(m, t);
 
-    if (na > 1) {
-        nsvg__xformSetTranslation(t, args[1], args[2]);
-        nsvg__xformMultiply(m, t);
-    }
+       if (na > 1) {
+               nsvg__xformSetTranslation(t, args[1], args[2]);
+               nsvg__xformMultiply(m, t);
+       }
 
-    memcpy(xform, m, sizeof(float)*6);
+       memcpy(xform, m, sizeof(float)*6);
 
-    return len;
+       return len;
 }
 
 static void nsvg__parseTransform(float* xform, const char* str)
 {
-    float t[6];
-    nsvg__xformIdentity(xform);
-    while (*str)
-    {
-        if (strncmp(str, "matrix", 6) == 0)
-            str += nsvg__parseMatrix(t, str);
-        else if (strncmp(str, "translate", 9) == 0)
-            str += nsvg__parseTranslate(t, str);
-        else if (strncmp(str, "scale", 5) == 0)
-            str += nsvg__parseScale(t, str);
-        else if (strncmp(str, "rotate", 6) == 0)
-            str += nsvg__parseRotate(t, str);
-        else if (strncmp(str, "skewX", 5) == 0)
-            str += nsvg__parseSkewX(t, str);
-        else if (strncmp(str, "skewY", 5) == 0)
-            str += nsvg__parseSkewY(t, str);
-        else{
-            ++str;
-            continue;
-        }
-
-        nsvg__xformPremultiply(xform, t);
-    }
+       float t[6];
+       nsvg__xformIdentity(xform);
+       while (*str)
+       {
+               if (strncmp(str, "matrix", 6) == 0)
+                       str += nsvg__parseMatrix(t, str);
+               else if (strncmp(str, "translate", 9) == 0)
+                       str += nsvg__parseTranslate(t, str);
+               else if (strncmp(str, "scale", 5) == 0)
+                       str += nsvg__parseScale(t, str);
+               else if (strncmp(str, "rotate", 6) == 0)
+                       str += nsvg__parseRotate(t, str);
+               else if (strncmp(str, "skewX", 5) == 0)
+                       str += nsvg__parseSkewX(t, str);
+               else if (strncmp(str, "skewY", 5) == 0)
+                       str += nsvg__parseSkewY(t, str);
+               else{
+                       ++str;
+                       continue;
+               }
+
+               nsvg__xformPremultiply(xform, t);
+       }
 }
 
 static void nsvg__parseUrl(char* id, const char* str)
 {
-    int i = 0;
-    str += 4; // "url(";
-    if (*str == '#')
-        str++;
-    while (i < 63 && *str != ')') {
-        id[i] = *str++;
-        i++;
-    }
-    id[i] = '\0';
+       int i = 0;
+       str += 4; // "url(";
+       if (*str == '#')
+               str++;
+       while (i < 63 && *str != ')') {
+               id[i] = *str++;
+               i++;
+       }
+       id[i] = '\0';
 }
 
 static char nsvg__parseLineCap(const char* str)
 {
-    if (strcmp(str, "butt") == 0)
-        return NSVG_CAP_BUTT;
-    else if (strcmp(str, "round") == 0)
-        return NSVG_CAP_ROUND;
-    else if (strcmp(str, "square") == 0)
-        return NSVG_CAP_SQUARE;
-    // TODO: handle inherit.
-    return NSVG_CAP_BUTT;
+       if (strcmp(str, "butt") == 0)
+               return NSVG_CAP_BUTT;
+       else if (strcmp(str, "round") == 0)
+               return NSVG_CAP_ROUND;
+       else if (strcmp(str, "square") == 0)
+               return NSVG_CAP_SQUARE;
+       // TODO: handle inherit.
+       return NSVG_CAP_BUTT;
 }
 
 static char nsvg__parseLineJoin(const char* str)
 {
-    if (strcmp(str, "miter") == 0)
-        return NSVG_JOIN_MITER;
-    else if (strcmp(str, "round") == 0)
-        return NSVG_JOIN_ROUND;
-    else if (strcmp(str, "bevel") == 0)
-        return NSVG_JOIN_BEVEL;
-    // TODO: handle inherit.
-    return NSVG_CAP_BUTT;
+       if (strcmp(str, "miter") == 0)
+               return NSVG_JOIN_MITER;
+       else if (strcmp(str, "round") == 0)
+               return NSVG_JOIN_ROUND;
+       else if (strcmp(str, "bevel") == 0)
+               return NSVG_JOIN_BEVEL;
+       // TODO: handle inherit.
+       return NSVG_CAP_BUTT;
 }
 
 static char nsvg__parseFillRule(const char* str)
 {
-    if (strcmp(str, "nonzero") == 0)
-        return NSVG_FILLRULE_NONZERO;
-    else if (strcmp(str, "evenodd") == 0)
-        return NSVG_FILLRULE_EVENODD;
-    // TODO: handle inherit.
-    return NSVG_FILLRULE_NONZERO;
+       if (strcmp(str, "nonzero") == 0)
+               return NSVG_FILLRULE_NONZERO;
+       else if (strcmp(str, "evenodd") == 0)
+               return NSVG_FILLRULE_EVENODD;
+       // TODO: handle inherit.
+       return NSVG_FILLRULE_NONZERO;
 }
 
 static const char* nsvg__getNextDashItem(const char* s, char* it)
 {
-    int n = 0;
-    it[0] = '\0';
-    // Skip white spaces and commas
-    while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
-    // Advance until whitespace, comma or end.
-    while (*s && (!nsvg__isspace(*s) && *s != ',')) {
-        if (n < 63)
-            it[n++] = *s;
-        s++;
-    }
-    it[n++] = '\0';
-    return s;
+       int n = 0;
+       it[0] = '\0';
+       // Skip white spaces and commas
+       while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+       // Advance until whitespace, comma or end.
+       while (*s && (!nsvg__isspace(*s) && *s != ',')) {
+               if (n < 63)
+                       it[n++] = *s;
+               s++;
+       }
+       it[n++] = '\0';
+       return s;
 }
 
 static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray)
 {
-    char item[64];
-    int count = 0, i;
-    float sum = 0.0f;
+       char item[64];
+       int count = 0, i;
+       float sum = 0.0f;
 
-    // Handle "none"
-    if (str[0] == 'n')
-        return 0;
+       // Handle "none"
+       if (str[0] == 'n')
+               return 0;
 
-    // Parse dashes
-    while (*str) {
-        str = nsvg__getNextDashItem(str, item);
-        if (!*item) break;
-        if (count < NSVG_MAX_DASHES)
-            strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
-    }
+       // Parse dashes
+       while (*str) {
+               str = nsvg__getNextDashItem(str, item);
+               if (!*item) break;
+               if (count < NSVG_MAX_DASHES)
+                       strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
+       }
 
-    for (i = 0; i < count; i++)
-        sum += strokeDashArray[i];
-    if (sum <= 1e-6f)
-        count = 0;
+       for (i = 0; i < count; i++)
+               sum += strokeDashArray[i];
+       if (sum <= 1e-6f)
+               count = 0;
 
-    return count;
+       return count;
 }
 
 static void nsvg__parseStyle(NSVGparser* p, const char* str);
 
 static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
 {
-    float xform[6];
-    NSVGattrib* attr = nsvg__getAttr(p);
-    if (!attr) return 0;
-
-    if (strcmp(name, "style") == 0) {
-        nsvg__parseStyle(p, value);
-    } else if (strcmp(name, "display") == 0) {
-        if (strcmp(value, "none") == 0)
-            attr->visible = 0;
-        // Don't reset ->visible on display:inline, one display:none hides the whole subtree
-
-    } else if (strcmp(name, "fill") == 0) {
-        if (strcmp(value, "none") == 0) {
-            attr->hasFill = 0;
-        } else if (strncmp(value, "url(", 4) == 0) {
-            attr->hasFill = 2;
-            nsvg__parseUrl(attr->fillGradient, value);
-        } else {
-            attr->hasFill = 1;
-            attr->fillColor = nsvg__parseColor(value);
-        }
-    } else if (strcmp(name, "opacity") == 0) {
-        attr->opacity = nsvg__parseOpacity(value);
-    } else if (strcmp(name, "fill-opacity") == 0) {
-        attr->fillOpacity = nsvg__parseOpacity(value);
-    } else if (strcmp(name, "stroke") == 0) {
-        if (strcmp(value, "none") == 0) {
-            attr->hasStroke = 0;
-        } else if (strncmp(value, "url(", 4) == 0) {
-            attr->hasStroke = 2;
-            nsvg__parseUrl(attr->strokeGradient, value);
-        } else {
-            attr->hasStroke = 1;
-            attr->strokeColor = nsvg__parseColor(value);
-        }
-    } else if (strcmp(name, "stroke-width") == 0) {
-        attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
-    } else if (strcmp(name, "stroke-dasharray") == 0) {
-        attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
-    } else if (strcmp(name, "stroke-dashoffset") == 0) {
-        attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
-    } else if (strcmp(name, "stroke-opacity") == 0) {
-        attr->strokeOpacity = nsvg__parseOpacity(value);
-    } else if (strcmp(name, "stroke-linecap") == 0) {
-        attr->strokeLineCap = nsvg__parseLineCap(value);
-    } else if (strcmp(name, "stroke-linejoin") == 0) {
-        attr->strokeLineJoin = nsvg__parseLineJoin(value);
-    } else if (strcmp(name, "fill-rule") == 0) {
-        attr->fillRule = nsvg__parseFillRule(value);
-    } else if (strcmp(name, "font-size") == 0) {
-        attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
-    } else if (strcmp(name, "transform") == 0) {
-        nsvg__parseTransform(xform, value);
-        nsvg__xformPremultiply(attr->xform, xform);
-    } else if (strcmp(name, "stop-color") == 0) {
-        attr->stopColor = nsvg__parseColor(value);
-    } else if (strcmp(name, "stop-opacity") == 0) {
-        attr->stopOpacity = nsvg__parseOpacity(value);
-    } else if (strcmp(name, "offset") == 0) {
-        attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
-    } else if (strcmp(name, "id") == 0) {
-        strncpy(attr->id, value, 63);
-        attr->id[63] = '\0';
-    } else {
-        return 0;
-    }
-    return 1;
+       float xform[6];
+       NSVGattrib* attr = nsvg__getAttr(p);
+       if (!attr) return 0;
+
+       if (strcmp(name, "style") == 0) {
+               nsvg__parseStyle(p, value);
+       } else if (strcmp(name, "display") == 0) {
+               if (strcmp(value, "none") == 0)
+                       attr->visible = 0;
+               // Don't reset ->visible on display:inline, one display:none hides the whole subtree
+
+       } else if (strcmp(name, "fill") == 0) {
+               if (strcmp(value, "none") == 0) {
+                       attr->hasFill = 0;
+               } else if (strncmp(value, "url(", 4) == 0) {
+                       attr->hasFill = 2;
+                       nsvg__parseUrl(attr->fillGradient, value);
+               } else {
+                       attr->hasFill = 1;
+                       attr->fillColor = nsvg__parseColor(value);
+               }
+       } else if (strcmp(name, "opacity") == 0) {
+               attr->opacity = nsvg__parseOpacity(value);
+       } else if (strcmp(name, "fill-opacity") == 0) {
+               attr->fillOpacity = nsvg__parseOpacity(value);
+       } else if (strcmp(name, "stroke") == 0) {
+               if (strcmp(value, "none") == 0) {
+                       attr->hasStroke = 0;
+               } else if (strncmp(value, "url(", 4) == 0) {
+                       attr->hasStroke = 2;
+                       nsvg__parseUrl(attr->strokeGradient, value);
+               } else {
+                       attr->hasStroke = 1;
+                       attr->strokeColor = nsvg__parseColor(value);
+               }
+       } else if (strcmp(name, "stroke-width") == 0) {
+               attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+       } else if (strcmp(name, "stroke-dasharray") == 0) {
+               attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
+       } else if (strcmp(name, "stroke-dashoffset") == 0) {
+               attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+       } else if (strcmp(name, "stroke-opacity") == 0) {
+               attr->strokeOpacity = nsvg__parseOpacity(value);
+       } else if (strcmp(name, "stroke-linecap") == 0) {
+               attr->strokeLineCap = nsvg__parseLineCap(value);
+       } else if (strcmp(name, "stroke-linejoin") == 0) {
+               attr->strokeLineJoin = nsvg__parseLineJoin(value);
+       } else if (strcmp(name, "stroke-miterlimit") == 0) {
+               attr->miterLimit = nsvg__parseMiterLimit(value);
+       } else if (strcmp(name, "fill-rule") == 0) {
+               attr->fillRule = nsvg__parseFillRule(value);
+       } else if (strcmp(name, "font-size") == 0) {
+               attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+       } else if (strcmp(name, "transform") == 0) {
+               nsvg__parseTransform(xform, value);
+               nsvg__xformPremultiply(attr->xform, xform);
+       } else if (strcmp(name, "stop-color") == 0) {
+               attr->stopColor = nsvg__parseColor(value);
+       } else if (strcmp(name, "stop-opacity") == 0) {
+               attr->stopOpacity = nsvg__parseOpacity(value);
+       } else if (strcmp(name, "offset") == 0) {
+               attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
+       } else if (strcmp(name, "id") == 0) {
+               strncpy(attr->id, value, 63);
+               attr->id[63] = '\0';
+       } else {
+               return 0;
+       }
+       return 1;
 }
 
 static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end)
 {
-    const char* str;
-    const char* val;
-    char name[512];
-    char value[512];
-    int n;
+       const char* str;
+       const char* val;
+       char name[512];
+       char value[512];
+       int n;
 
-    str = start;
-    while (str < end && *str != ':') ++str;
+       str = start;
+       while (str < end && *str != ':') ++str;
 
-    val = str;
+       val = str;
 
-    // Right Trim
-    while (str > start &&  (*str == ':' || nsvg__isspace(*str))) --str;
-    ++str;
+       // Right Trim
+       while (str > start &&  (*str == ':' || nsvg__isspace(*str))) --str;
+       ++str;
 
-    n = (int)(str - start);
-    if (n > 511) n = 511;
-    if (n) memcpy(name, start, n);
-    name[n] = 0;
+       n = (int)(str - start);
+       if (n > 511) n = 511;
+       if (n) memcpy(name, start, n);
+       name[n] = 0;
 
-    while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
+       while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
 
-    n = (int)(end - val);
-    if (n > 511) n = 511;
-    if (n) memcpy(value, val, n);
-    value[n] = 0;
+       n = (int)(end - val);
+       if (n > 511) n = 511;
+       if (n) memcpy(value, val, n);
+       value[n] = 0;
 
-    return nsvg__parseAttr(p, name, value);
+       return nsvg__parseAttr(p, name, value);
 }
 
 static void nsvg__parseStyle(NSVGparser* p, const char* str)
 {
-    const char* start;
-    const char* end;
+       const char* start;
+       const char* end;
 
-    while (*str) {
-        // Left Trim
-        while(*str && nsvg__isspace(*str)) ++str;
-        start = str;
-        while(*str && *str != ';') ++str;
-        end = str;
+       while (*str) {
+               // Left Trim
+               while(*str && nsvg__isspace(*str)) ++str;
+               start = str;
+               while(*str && *str != ';') ++str;
+               end = str;
 
-        // Right Trim
-        while (end > start &&  (*end == ';' || nsvg__isspace(*end))) --end;
-        ++end;
+               // Right Trim
+               while (end > start &&  (*end == ';' || nsvg__isspace(*end))) --end;
+               ++end;
 
-        nsvg__parseNameValue(p, start, end);
-        if (*str) ++str;
-    }
+               nsvg__parseNameValue(p, start, end);
+               if (*str) ++str;
+       }
 }
 
 static void nsvg__parseAttribs(NSVGparser* p, const char** attr)
 {
-    int i;
-    for (i = 0; attr[i]; i += 2)
-    {
-        if (strcmp(attr[i], "style") == 0)
-            nsvg__parseStyle(p, attr[i + 1]);
-        else
-            nsvg__parseAttr(p, attr[i], attr[i + 1]);
-    }
+       int i;
+       for (i = 0; attr[i]; i += 2)
+       {
+               if (strcmp(attr[i], "style") == 0)
+                       nsvg__parseStyle(p, attr[i + 1]);
+               else
+                       nsvg__parseAttr(p, attr[i], attr[i + 1]);
+       }
 }
 
 static int nsvg__getArgsPerElement(char cmd)
 {
-    switch (cmd) {
-        case 'v':
-        case 'V':
-        case 'h':
-        case 'H':
-            return 1;
-        case 'm':
-        case 'M':
-        case 'l':
-        case 'L':
-        case 't':
-        case 'T':
-            return 2;
-        case 'q':
-        case 'Q':
-        case 's':
-        case 'S':
-            return 4;
-        case 'c':
-        case 'C':
-            return 6;
-        case 'a':
-        case 'A':
-            return 7;
-    }
-    return 0;
+       switch (cmd) {
+               case 'v':
+               case 'V':
+               case 'h':
+               case 'H':
+                       return 1;
+               case 'm':
+               case 'M':
+               case 'l':
+               case 'L':
+               case 't':
+               case 'T':
+                       return 2;
+               case 'q':
+               case 'Q':
+               case 's':
+               case 'S':
+                       return 4;
+               case 'c':
+               case 'C':
+                       return 6;
+               case 'a':
+               case 'A':
+                       return 7;
+       }
+       return 0;
 }
 
 static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-    if (rel) {
-        *cpx += args[0];
-        *cpy += args[1];
-    } else {
-        *cpx = args[0];
-        *cpy = args[1];
-    }
-    nsvg__moveTo(p, *cpx, *cpy);
+       if (rel) {
+               *cpx += args[0];
+               *cpy += args[1];
+       } else {
+               *cpx = args[0];
+               *cpy = args[1];
+       }
+       nsvg__moveTo(p, *cpx, *cpy);
 }
 
 static void nsvg__pathLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-    if (rel) {
-        *cpx += args[0];
-        *cpy += args[1];
-    } else {
-        *cpx = args[0];
-        *cpy = args[1];
-    }
-    nsvg__lineTo(p, *cpx, *cpy);
+       if (rel) {
+               *cpx += args[0];
+               *cpy += args[1];
+       } else {
+               *cpx = args[0];
+               *cpy = args[1];
+       }
+       nsvg__lineTo(p, *cpx, *cpy);
 }
 
 static void nsvg__pathHLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-    if (rel)
-        *cpx += args[0];
-    else
-        *cpx = args[0];
-    nsvg__lineTo(p, *cpx, *cpy);
+       if (rel)
+               *cpx += args[0];
+       else
+               *cpx = args[0];
+       nsvg__lineTo(p, *cpx, *cpy);
 }
 
 static void nsvg__pathVLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-    if (rel)
-        *cpy += args[0];
-    else
-        *cpy = args[0];
-    nsvg__lineTo(p, *cpx, *cpy);
+       if (rel)
+               *cpy += args[0];
+       else
+               *cpy = args[0];
+       nsvg__lineTo(p, *cpx, *cpy);
 }
 
 static void nsvg__pathCubicBezTo(NSVGparser* p, float* cpx, float* cpy,
-                                 float* cpx2, float* cpy2, float* args, int rel)
-{
-    float x2, y2, cx1, cy1, cx2, cy2;
-
-    if (rel) {
-        cx1 = *cpx + args[0];
-        cy1 = *cpy + args[1];
-        cx2 = *cpx + args[2];
-        cy2 = *cpy + args[3];
-        x2 = *cpx + args[4];
-        y2 = *cpy + args[5];
-    } else {
-        cx1 = args[0];
-        cy1 = args[1];
-        cx2 = args[2];
-        cy2 = args[3];
-        x2 = args[4];
-        y2 = args[5];
-    }
-
-    nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
-
-    *cpx2 = cx2;
-    *cpy2 = cy2;
-    *cpx = x2;
-    *cpy = y2;
+                                                                float* cpx2, float* cpy2, float* args, int rel)
+{
+       float x2, y2, cx1, cy1, cx2, cy2;
+
+       if (rel) {
+               cx1 = *cpx + args[0];
+               cy1 = *cpy + args[1];
+               cx2 = *cpx + args[2];
+               cy2 = *cpy + args[3];
+               x2 = *cpx + args[4];
+               y2 = *cpy + args[5];
+       } else {
+               cx1 = args[0];
+               cy1 = args[1];
+               cx2 = args[2];
+               cy2 = args[3];
+               x2 = args[4];
+               y2 = args[5];
+       }
+
+       nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+       *cpx2 = cx2;
+       *cpy2 = cy2;
+       *cpx = x2;
+       *cpy = y2;
 }
 
 static void nsvg__pathCubicBezShortTo(NSVGparser* p, float* cpx, float* cpy,
-                                      float* cpx2, float* cpy2, float* args, int rel)
+                                                                         float* cpx2, float* cpy2, float* args, int rel)
 {
-    float x1, y1, x2, y2, cx1, cy1, cx2, cy2;
+       float x1, y1, x2, y2, cx1, cy1, cx2, cy2;
 
-    x1 = *cpx;
-    y1 = *cpy;
-    if (rel) {
-        cx2 = *cpx + args[0];
-        cy2 = *cpy + args[1];
-        x2 = *cpx + args[2];
-        y2 = *cpy + args[3];
-    } else {
-        cx2 = args[0];
-        cy2 = args[1];
-        x2 = args[2];
-        y2 = args[3];
-    }
+       x1 = *cpx;
+       y1 = *cpy;
+       if (rel) {
+               cx2 = *cpx + args[0];
+               cy2 = *cpy + args[1];
+               x2 = *cpx + args[2];
+               y2 = *cpy + args[3];
+       } else {
+               cx2 = args[0];
+               cy2 = args[1];
+               x2 = args[2];
+               y2 = args[3];
+       }
 
-    cx1 = 2*x1 - *cpx2;
-    cy1 = 2*y1 - *cpy2;
+       cx1 = 2*x1 - *cpx2;
+       cy1 = 2*y1 - *cpy2;
 
-    nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+       nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
 
-    *cpx2 = cx2;
-    *cpy2 = cy2;
-    *cpx = x2;
-    *cpy = y2;
+       *cpx2 = cx2;
+       *cpy2 = cy2;
+       *cpx = x2;
+       *cpy = y2;
 }
 
 static void nsvg__pathQuadBezTo(NSVGparser* p, float* cpx, float* cpy,
-                                float* cpx2, float* cpy2, float* args, int rel)
-{
-    float x1, y1, x2, y2, cx, cy;
-    float cx1, cy1, cx2, cy2;
-
-    x1 = *cpx;
-    y1 = *cpy;
-    if (rel) {
-        cx = *cpx + args[0];
-        cy = *cpy + args[1];
-        x2 = *cpx + args[2];
-        y2 = *cpy + args[3];
-    } else {
-        cx = args[0];
-        cy = args[1];
-        x2 = args[2];
-        y2 = args[3];
-    }
-
-    // Convert to cubic bezier
-    cx1 = x1 + 2.0f/3.0f*(cx - x1);
-    cy1 = y1 + 2.0f/3.0f*(cy - y1);
-    cx2 = x2 + 2.0f/3.0f*(cx - x2);
-    cy2 = y2 + 2.0f/3.0f*(cy - y2);
-
-    nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
-
-    *cpx2 = cx;
-    *cpy2 = cy;
-    *cpx = x2;
-    *cpy = y2;
+                                                               float* cpx2, float* cpy2, float* args, int rel)
+{
+       float x1, y1, x2, y2, cx, cy;
+       float cx1, cy1, cx2, cy2;
+
+       x1 = *cpx;
+       y1 = *cpy;
+       if (rel) {
+               cx = *cpx + args[0];
+               cy = *cpy + args[1];
+               x2 = *cpx + args[2];
+               y2 = *cpy + args[3];
+       } else {
+               cx = args[0];
+               cy = args[1];
+               x2 = args[2];
+               y2 = args[3];
+       }
+
+       // Convert to cubic bezier
+       cx1 = x1 + 2.0f/3.0f*(cx - x1);
+       cy1 = y1 + 2.0f/3.0f*(cy - y1);
+       cx2 = x2 + 2.0f/3.0f*(cx - x2);
+       cy2 = y2 + 2.0f/3.0f*(cy - y2);
+
+       nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+       *cpx2 = cx;
+       *cpy2 = cy;
+       *cpx = x2;
+       *cpy = y2;
 }
 
 static void nsvg__pathQuadBezShortTo(NSVGparser* p, float* cpx, float* cpy,
-                                     float* cpx2, float* cpy2, float* args, int rel)
+                                                                        float* cpx2, float* cpy2, float* args, int rel)
 {
-    float x1, y1, x2, y2, cx, cy;
-    float cx1, cy1, cx2, cy2;
+       float x1, y1, x2, y2, cx, cy;
+       float cx1, cy1, cx2, cy2;
 
-    x1 = *cpx;
-    y1 = *cpy;
-    if (rel) {
-        x2 = *cpx + args[0];
-        y2 = *cpy + args[1];
-    } else {
-        x2 = args[0];
-        y2 = args[1];
-    }
+       x1 = *cpx;
+       y1 = *cpy;
+       if (rel) {
+               x2 = *cpx + args[0];
+               y2 = *cpy + args[1];
+       } else {
+               x2 = args[0];
+               y2 = args[1];
+       }
 
-    cx = 2*x1 - *cpx2;
-    cy = 2*y1 - *cpy2;
+       cx = 2*x1 - *cpx2;
+       cy = 2*y1 - *cpy2;
 
-    // Convert to cubix bezier
-    cx1 = x1 + 2.0f/3.0f*(cx - x1);
-    cy1 = y1 + 2.0f/3.0f*(cy - y1);
-    cx2 = x2 + 2.0f/3.0f*(cx - x2);
-    cy2 = y2 + 2.0f/3.0f*(cy - y2);
+       // Convert to cubix bezier
+       cx1 = x1 + 2.0f/3.0f*(cx - x1);
+       cy1 = y1 + 2.0f/3.0f*(cy - y1);
+       cx2 = x2 + 2.0f/3.0f*(cx - x2);
+       cy2 = y2 + 2.0f/3.0f*(cy - y2);
 
-    nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+       nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
 
-    *cpx2 = cx;
-    *cpy2 = cy;
-    *cpx = x2;
-    *cpy = y2;
+       *cpx2 = cx;
+       *cpy2 = cy;
+       *cpx = x2;
+       *cpy = y2;
 }
 
 static float nsvg__sqr(float x) { return x*x; }
@@ -1860,880 +1916,881 @@ static float nsvg__vmag(float x, float y) { return sqrtf(x*x + y*y); }
 
 static float nsvg__vecrat(float ux, float uy, float vx, float vy)
 {
-    return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy));
+       return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy));
 }
 
 static float nsvg__vecang(float ux, float uy, float vx, float vy)
 {
-    float r = nsvg__vecrat(ux,uy, vx,vy);
-    if (r < -1.0f) r = -1.0f;
-    if (r > 1.0f) r = 1.0f;
-    return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
+       float r = nsvg__vecrat(ux,uy, vx,vy);
+       if (r < -1.0f) r = -1.0f;
+       if (r > 1.0f) r = 1.0f;
+       return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
 }
 
 static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
 {
-    // Ported from canvg (https://code.google.com/p/canvg/)
-    float rx, ry, rotx;
-    float x1, y1, x2, y2, cx, cy, dx, dy, d;
-    float x1p, y1p, cxp, cyp, s, sa, sb;
-    float ux, uy, vx, vy, a1, da;
-    float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
-    float sinrx, cosrx;
-    int fa, fs;
-    int i, ndivs;
-    float hda, kappa;
-
-    rx = fabsf(args[0]);                // y radius
-    ry = fabsf(args[1]);                // x radius
-    rotx = args[2] / 180.0f * NSVG_PI;      // x rotation engle
-    fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc
-    fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction
-    x1 = *cpx;                          // start point
-    y1 = *cpy;
-    if (rel) {                          // end point
-        x2 = *cpx + args[5];
-        y2 = *cpy + args[6];
-    } else {
-        x2 = args[5];
-        y2 = args[6];
-    }
-
-    dx = x1 - x2;
-    dy = y1 - y2;
-    d = sqrtf(dx*dx + dy*dy);
-    if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
-        // The arc degenerates to a line
-        nsvg__lineTo(p, x2, y2);
-        *cpx = x2;
-        *cpy = y2;
-        return;
-    }
-
-    sinrx = sinf(rotx);
-    cosrx = cosf(rotx);
-
-    // Convert to center point parameterization.
-    // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
-    // 1) Compute x1', y1'
-    x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
-    y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
-    d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
-    if (d > 1) {
-        d = sqrtf(d);
-        rx *= d;
-        ry *= d;
-    }
-    // 2) Compute cx', cy'
-    s = 0.0f;
-    sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
-    sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
-    if (sa < 0.0f) sa = 0.0f;
-    if (sb > 0.0f)
-        s = sqrtf(sa / sb);
-    if (fa == fs)
-        s = -s;
-    cxp = s * rx * y1p / ry;
-    cyp = s * -ry * x1p / rx;
-
-    // 3) Compute cx,cy from cx',cy'
-    cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
-    cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
-
-    // 4) Calculate theta1, and delta theta.
-    ux = (x1p - cxp) / rx;
-    uy = (y1p - cyp) / ry;
-    vx = (-x1p - cxp) / rx;
-    vy = (-y1p - cyp) / ry;
-    a1 = nsvg__vecang(1.0f,0.0f, ux,uy);    // Initial angle
-    da = nsvg__vecang(ux,uy, vx,vy);        // Delta angle
-
-//  if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI;
-//  if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0;
-
-    if (fa) {
-        // Choose large arc
-        if (da > 0.0f)
-            da = da - 2*NSVG_PI;
-        else
-            da = 2*NSVG_PI + da;
-    }
-
-    // Approximate the arc using cubic spline segments.
-    t[0] = cosrx; t[1] = sinrx;
-    t[2] = -sinrx; t[3] = cosrx;
-    t[4] = cx; t[5] = cy;
-
-    // Split arc into max 90 degree segments.
-    // The loop assumes an iteration per end point (including start and end), this +1.
-    ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
-    hda = (da / (float)ndivs) / 2.0f;
-    kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
-    if (da < 0.0f)
-        kappa = -kappa;
-
-    for (i = 0; i <= ndivs; i++) {
-        a = a1 + da * (i/(float)ndivs);
-        dx = cosf(a);
-        dy = sinf(a);
-        nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
-        nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
-        if (i > 0)
-            nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
-        px = x;
-        py = y;
-        ptanx = tanx;
-        ptany = tany;
-    }
-
-    *cpx = x2;
-    *cpy = y2;
+       // Ported from canvg (https://code.google.com/p/canvg/)
+       float rx, ry, rotx;
+       float x1, y1, x2, y2, cx, cy, dx, dy, d;
+       float x1p, y1p, cxp, cyp, s, sa, sb;
+       float ux, uy, vx, vy, a1, da;
+       float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
+       float sinrx, cosrx;
+       int fa, fs;
+       int i, ndivs;
+       float hda, kappa;
+
+       rx = fabsf(args[0]);                            // y radius
+       ry = fabsf(args[1]);                            // x radius
+       rotx = args[2] / 180.0f * NSVG_PI;              // x rotation angle
+       fa = fabsf(args[3]) > 1e-6 ? 1 : 0;     // Large arc
+       fs = fabsf(args[4]) > 1e-6 ? 1 : 0;     // Sweep direction
+       x1 = *cpx;                                                      // start point
+       y1 = *cpy;
+       if (rel) {                                                      // end point
+               x2 = *cpx + args[5];
+               y2 = *cpy + args[6];
+       } else {
+               x2 = args[5];
+               y2 = args[6];
+       }
+
+       dx = x1 - x2;
+       dy = y1 - y2;
+       d = sqrtf(dx*dx + dy*dy);
+       if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
+               // The arc degenerates to a line
+               nsvg__lineTo(p, x2, y2);
+               *cpx = x2;
+               *cpy = y2;
+               return;
+       }
+
+       sinrx = sinf(rotx);
+       cosrx = cosf(rotx);
+
+       // Convert to center point parameterization.
+       // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
+       // 1) Compute x1', y1'
+       x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
+       y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
+       d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
+       if (d > 1) {
+               d = sqrtf(d);
+               rx *= d;
+               ry *= d;
+       }
+       // 2) Compute cx', cy'
+       s = 0.0f;
+       sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
+       sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
+       if (sa < 0.0f) sa = 0.0f;
+       if (sb > 0.0f)
+               s = sqrtf(sa / sb);
+       if (fa == fs)
+               s = -s;
+       cxp = s * rx * y1p / ry;
+       cyp = s * -ry * x1p / rx;
+
+       // 3) Compute cx,cy from cx',cy'
+       cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
+       cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
+
+       // 4) Calculate theta1, and delta theta.
+       ux = (x1p - cxp) / rx;
+       uy = (y1p - cyp) / ry;
+       vx = (-x1p - cxp) / rx;
+       vy = (-y1p - cyp) / ry;
+       a1 = nsvg__vecang(1.0f,0.0f, ux,uy);    // Initial angle
+       da = nsvg__vecang(ux,uy, vx,vy);                // Delta angle
+
+//     if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI;
+//     if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0;
+
+       if (fs == 0 && da > 0)
+               da -= 2 * NSVG_PI;
+       else if (fs == 1 && da < 0)
+               da += 2 * NSVG_PI;
+
+       // Approximate the arc using cubic spline segments.
+       t[0] = cosrx; t[1] = sinrx;
+       t[2] = -sinrx; t[3] = cosrx;
+       t[4] = cx; t[5] = cy;
+
+       // Split arc into max 90 degree segments.
+       // The loop assumes an iteration per end point (including start and end), this +1.
+       ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
+       hda = (da / (float)ndivs) / 2.0f;
+       kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
+       if (da < 0.0f)
+               kappa = -kappa;
+
+       for (i = 0; i <= ndivs; i++) {
+               a = a1 + da * ((float)i/(float)ndivs);
+               dx = cosf(a);
+               dy = sinf(a);
+               nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
+               nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
+               if (i > 0)
+                       nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
+               px = x;
+               py = y;
+               ptanx = tanx;
+               ptany = tany;
+       }
+
+       *cpx = x2;
+       *cpy = y2;
 }
 
 static void nsvg__parsePath(NSVGparser* p, const char** attr)
 {
-    const char* s = NULL;
-    char cmd = '\0';
-    float args[10];
-    int nargs;
-    int rargs = 0;
-    float cpx, cpy, cpx2, cpy2;
-    const char* tmp[4];
-    char closedFlag;
-    int i;
-    char item[64];
-
-    for (i = 0; attr[i]; i += 2) {
-        if (strcmp(attr[i], "d") == 0) {
-            s = attr[i + 1];
-        } else {
-            tmp[0] = attr[i];
-            tmp[1] = attr[i + 1];
-            tmp[2] = 0;
-            tmp[3] = 0;
-            nsvg__parseAttribs(p, tmp);
-        }
-    }
-
-    if (s) {
-        nsvg__resetPath(p);
-        cpx = 0; cpy = 0;
-        cpx2 = 0; cpy2 = 0;
-        closedFlag = 0;
-        nargs = 0;
-
-        while (*s) {
-            s = nsvg__getNextPathItem(s, item);
-            if (!*item) break;
-            if (nsvg__isnum(item[0])) {
-                if (nargs < 10)
-                    args[nargs++] = (float)atof(item);
-                if (nargs >= rargs) {
-                    switch (cmd) {
-                        case 'm':
-                        case 'M':
-                            nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
-                            // Moveto can be followed by multiple coordinate pairs,
-                            // which should be treated as linetos.
-                            cmd = (cmd == 'm') ? 'l' : 'L';
-                            rargs = nsvg__getArgsPerElement(cmd);
-                            cpx2 = cpx; cpy2 = cpy;
-                            break;
-                        case 'l':
-                        case 'L':
-                            nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);
-                            cpx2 = cpx; cpy2 = cpy;
-                            break;
-                        case 'H':
-                        case 'h':
-                            nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0);
-                            cpx2 = cpx; cpy2 = cpy;
-                            break;
-                        case 'V':
-                        case 'v':
-                            nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0);
-                            cpx2 = cpx; cpy2 = cpy;
-                            break;
-                        case 'C':
-                        case 'c':
-                            nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0);
-                            break;
-                        case 'S':
-                        case 's':
-                            nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0);
-                            break;
-                        case 'Q':
-                        case 'q':
-                            nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0);
-                            break;
-                        case 'T':
-                        case 't':
-                            nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0);
-                            break;
-                        case 'A':
-                        case 'a':
-                            nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0);
-                            cpx2 = cpx; cpy2 = cpy;
-                            break;
-                        default:
-                            if (nargs >= 2) {
-                                cpx = args[nargs-2];
-                                cpy = args[nargs-1];
-                                cpx2 = cpx; cpy2 = cpy;
-                            }
-                            break;
-                    }
-                    nargs = 0;
-                }
-            } else {
-                cmd = item[0];
-                rargs = nsvg__getArgsPerElement(cmd);
-                if (cmd == 'M' || cmd == 'm') {
-                    // Commit path.
-                    if (p->npts > 0)
-                        nsvg__addPath(p, closedFlag);
-                    // Start new subpath.
-                    nsvg__resetPath(p);
-                    closedFlag = 0;
-                    nargs = 0;
-                } else if (cmd == 'Z' || cmd == 'z') {
-                    closedFlag = 1;
-                    // Commit path.
-                    if (p->npts > 0) {
-                        // Move current point to first point
-                        cpx = p->pts[0];
-                        cpy = p->pts[1];
-                        cpx2 = cpx; cpy2 = cpy;
-                        nsvg__addPath(p, closedFlag);
-                    }
-                    // Start new subpath.
-                    nsvg__resetPath(p);
-                    nsvg__moveTo(p, cpx, cpy);
-                    closedFlag = 0;
-                    nargs = 0;
-                }
-            }
-        }
-        // Commit path.
-        if (p->npts)
-            nsvg__addPath(p, closedFlag);
-    }
-
-    nsvg__addShape(p);
+       const char* s = NULL;
+       char cmd = '\0';
+       float args[10];
+       int nargs;
+       int rargs = 0;
+       float cpx, cpy, cpx2, cpy2;
+       const char* tmp[4];
+       char closedFlag;
+       int i;
+       char item[64];
+
+       for (i = 0; attr[i]; i += 2) {
+               if (strcmp(attr[i], "d") == 0) {
+                       s = attr[i + 1];
+               } else {
+                       tmp[0] = attr[i];
+                       tmp[1] = attr[i + 1];
+                       tmp[2] = 0;
+                       tmp[3] = 0;
+                       nsvg__parseAttribs(p, tmp);
+               }
+       }
+
+       if (s) {
+               nsvg__resetPath(p);
+               cpx = 0; cpy = 0;
+               cpx2 = 0; cpy2 = 0;
+               closedFlag = 0;
+               nargs = 0;
+
+               while (*s) {
+                       s = nsvg__getNextPathItem(s, item);
+                       if (!*item) break;
+                       if (nsvg__isnum(item[0])) {
+                               if (nargs < 10)
+                                       args[nargs++] = (float)nsvg__atof(item);
+                               if (nargs >= rargs) {
+                                       switch (cmd) {
+                                               case 'm':
+                                               case 'M':
+                                                       nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
+                                                       // Moveto can be followed by multiple coordinate pairs,
+                                                       // which should be treated as linetos.
+                                                       cmd = (cmd == 'm') ? 'l' : 'L';
+                                                       rargs = nsvg__getArgsPerElement(cmd);
+                                                       cpx2 = cpx; cpy2 = cpy;
+                                                       break;
+                                               case 'l':
+                                               case 'L':
+                                                       nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);
+                                                       cpx2 = cpx; cpy2 = cpy;
+                                                       break;
+                                               case 'H':
+                                               case 'h':
+                                                       nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0);
+                                                       cpx2 = cpx; cpy2 = cpy;
+                                                       break;
+                                               case 'V':
+                                               case 'v':
+                                                       nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0);
+                                                       cpx2 = cpx; cpy2 = cpy;
+                                                       break;
+                                               case 'C':
+                                               case 'c':
+                                                       nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0);
+                                                       break;
+                                               case 'S':
+                                               case 's':
+                                                       nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0);
+                                                       break;
+                                               case 'Q':
+                                               case 'q':
+                                                       nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0);
+                                                       break;
+                                               case 'T':
+                                               case 't':
+                                                       nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0);
+                                                       break;
+                                               case 'A':
+                                               case 'a':
+                                                       nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0);
+                                                       cpx2 = cpx; cpy2 = cpy;
+                                                       break;
+                                               default:
+                                                       if (nargs >= 2) {
+                                                               cpx = args[nargs-2];
+                                                               cpy = args[nargs-1];
+                                                               cpx2 = cpx; cpy2 = cpy;
+                                                       }
+                                                       break;
+                                       }
+                                       nargs = 0;
+                               }
+                       } else {
+                               cmd = item[0];
+                               rargs = nsvg__getArgsPerElement(cmd);
+                               if (cmd == 'M' || cmd == 'm') {
+                                       // Commit path.
+                                       if (p->npts > 0)
+                                               nsvg__addPath(p, closedFlag);
+                                       // Start new subpath.
+                                       nsvg__resetPath(p);
+                                       closedFlag = 0;
+                                       nargs = 0;
+                               } else if (cmd == 'Z' || cmd == 'z') {
+                                       closedFlag = 1;
+                                       // Commit path.
+                                       if (p->npts > 0) {
+                                               // Move current point to first point
+                                               cpx = p->pts[0];
+                                               cpy = p->pts[1];
+                                               cpx2 = cpx; cpy2 = cpy;
+                                               nsvg__addPath(p, closedFlag);
+                                       }
+                                       // Start new subpath.
+                                       nsvg__resetPath(p);
+                                       nsvg__moveTo(p, cpx, cpy);
+                                       closedFlag = 0;
+                                       nargs = 0;
+                               }
+                       }
+               }
+               // Commit path.
+               if (p->npts)
+                       nsvg__addPath(p, closedFlag);
+       }
+
+       nsvg__addShape(p);
 }
 
 static void nsvg__parseRect(NSVGparser* p, const char** attr)
 {
-    float x = 0.0f;
-    float y = 0.0f;
-    float w = 0.0f;
-    float h = 0.0f;
-    float rx = -1.0f; // marks not set
-    float ry = -1.0f;
-    int i;
-
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
-            if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
-            if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
-            if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
-            if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
-            if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
-        }
-    }
-
-    if (rx < 0.0f && ry > 0.0f) rx = ry;
-    if (ry < 0.0f && rx > 0.0f) ry = rx;
-    if (rx < 0.0f) rx = 0.0f;
-    if (ry < 0.0f) ry = 0.0f;
-    if (rx > w/2.0f) rx = w/2.0f;
-    if (ry > h/2.0f) ry = h/2.0f;
-
-    if (w != 0.0f && h != 0.0f) {
-        nsvg__resetPath(p);
-
-        if (rx < 0.00001f || ry < 0.0001f) {
-            nsvg__moveTo(p, x, y);
-            nsvg__lineTo(p, x+w, y);
-            nsvg__lineTo(p, x+w, y+h);
-            nsvg__lineTo(p, x, y+h);
-        } else {
-            // Rounded rectangle
-            nsvg__moveTo(p, x+rx, y);
-            nsvg__lineTo(p, x+w-rx, y);
-            nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
-            nsvg__lineTo(p, x+w, y+h-ry);
-            nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
-            nsvg__lineTo(p, x+rx, y+h);
-            nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
-            nsvg__lineTo(p, x, y+ry);
-            nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
-        }
-
-        nsvg__addPath(p, 1);
-
-        nsvg__addShape(p);
-    }
+       float x = 0.0f;
+       float y = 0.0f;
+       float w = 0.0f;
+       float h = 0.0f;
+       float rx = -1.0f; // marks not set
+       float ry = -1.0f;
+       int i;
+
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+                       if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
+                       if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+                       if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+               }
+       }
+
+       if (rx < 0.0f && ry > 0.0f) rx = ry;
+       if (ry < 0.0f && rx > 0.0f) ry = rx;
+       if (rx < 0.0f) rx = 0.0f;
+       if (ry < 0.0f) ry = 0.0f;
+       if (rx > w/2.0f) rx = w/2.0f;
+       if (ry > h/2.0f) ry = h/2.0f;
+
+       if (w != 0.0f && h != 0.0f) {
+               nsvg__resetPath(p);
+
+               if (rx < 0.00001f || ry < 0.0001f) {
+                       nsvg__moveTo(p, x, y);
+                       nsvg__lineTo(p, x+w, y);
+                       nsvg__lineTo(p, x+w, y+h);
+                       nsvg__lineTo(p, x, y+h);
+               } else {
+                       // Rounded rectangle
+                       nsvg__moveTo(p, x+rx, y);
+                       nsvg__lineTo(p, x+w-rx, y);
+                       nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
+                       nsvg__lineTo(p, x+w, y+h-ry);
+                       nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
+                       nsvg__lineTo(p, x+rx, y+h);
+                       nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
+                       nsvg__lineTo(p, x, y+ry);
+                       nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
+               }
+
+               nsvg__addPath(p, 1);
+
+               nsvg__addShape(p);
+       }
 }
 
 static void nsvg__parseCircle(NSVGparser* p, const char** attr)
 {
-    float cx = 0.0f;
-    float cy = 0.0f;
-    float r = 0.0f;
-    int i;
+       float cx = 0.0f;
+       float cy = 0.0f;
+       float r = 0.0f;
+       int i;
 
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
-            if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
-            if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p)));
-        }
-    }
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+                       if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p)));
+               }
+       }
 
-    if (r > 0.0f) {
-        nsvg__resetPath(p);
+       if (r > 0.0f) {
+               nsvg__resetPath(p);
 
-        nsvg__moveTo(p, cx+r, cy);
-        nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r);
-        nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy);
-        nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r);
-        nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy);
+               nsvg__moveTo(p, cx+r, cy);
+               nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r);
+               nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy);
+               nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r);
+               nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy);
 
-        nsvg__addPath(p, 1);
+               nsvg__addPath(p, 1);
 
-        nsvg__addShape(p);
-    }
+               nsvg__addShape(p);
+       }
 }
 
 static void nsvg__parseEllipse(NSVGparser* p, const char** attr)
 {
-    float cx = 0.0f;
-    float cy = 0.0f;
-    float rx = 0.0f;
-    float ry = 0.0f;
-    int i;
+       float cx = 0.0f;
+       float cy = 0.0f;
+       float rx = 0.0f;
+       float ry = 0.0f;
+       int i;
 
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
-            if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
-            if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
-            if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
-        }
-    }
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+                       if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+                       if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+               }
+       }
 
-    if (rx > 0.0f && ry > 0.0f) {
+       if (rx > 0.0f && ry > 0.0f) {
 
-        nsvg__resetPath(p);
+               nsvg__resetPath(p);
 
-        nsvg__moveTo(p, cx+rx, cy);
-        nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry);
-        nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy);
-        nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry);
-        nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy);
+               nsvg__moveTo(p, cx+rx, cy);
+               nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry);
+               nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy);
+               nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry);
+               nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy);
 
-        nsvg__addPath(p, 1);
+               nsvg__addPath(p, 1);
 
-        nsvg__addShape(p);
-    }
+               nsvg__addShape(p);
+       }
 }
 
 static void nsvg__parseLine(NSVGparser* p, const char** attr)
 {
-    float x1 = 0.0;
-    float y1 = 0.0;
-    float x2 = 0.0;
-    float y2 = 0.0;
-    int i;
+       float x1 = 0.0;
+       float y1 = 0.0;
+       float x2 = 0.0;
+       float y2 = 0.0;
+       int i;
 
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
-            if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
-            if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
-            if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
-        }
-    }
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+                       if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+                       if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+               }
+       }
 
-    nsvg__resetPath(p);
+       nsvg__resetPath(p);
 
-    nsvg__moveTo(p, x1, y1);
-    nsvg__lineTo(p, x2, y2);
+       nsvg__moveTo(p, x1, y1);
+       nsvg__lineTo(p, x2, y2);
 
-    nsvg__addPath(p, 0);
+       nsvg__addPath(p, 0);
 
-    nsvg__addShape(p);
+       nsvg__addShape(p);
 }
 
 static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag)
 {
-    int i;
-    const char* s;
-    float args[2];
-    int nargs, npts = 0;
-    char item[64];
-
-    nsvg__resetPath(p);
-
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "points") == 0) {
-                s = attr[i + 1];
-                nargs = 0;
-                while (*s) {
-                    s = nsvg__getNextPathItem(s, item);
-                    args[nargs++] = (float)atof(item);
-                    if (nargs >= 2) {
-                        if (npts == 0)
-                            nsvg__moveTo(p, args[0], args[1]);
-                        else
-                            nsvg__lineTo(p, args[0], args[1]);
-                        nargs = 0;
-                        npts++;
-                    }
-                }
-            }
-        }
-    }
-
-    nsvg__addPath(p, (char)closeFlag);
-
-    nsvg__addShape(p);
+       int i;
+       const char* s;
+       float args[2];
+       int nargs, npts = 0;
+       char item[64];
+
+       nsvg__resetPath(p);
+
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "points") == 0) {
+                               s = attr[i + 1];
+                               nargs = 0;
+                               while (*s) {
+                                       s = nsvg__getNextPathItem(s, item);
+                                       args[nargs++] = (float)nsvg__atof(item);
+                                       if (nargs >= 2) {
+                                               if (npts == 0)
+                                                       nsvg__moveTo(p, args[0], args[1]);
+                                               else
+                                                       nsvg__lineTo(p, args[0], args[1]);
+                                               nargs = 0;
+                                               npts++;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       nsvg__addPath(p, (char)closeFlag);
+
+       nsvg__addShape(p);
 }
 
 static void nsvg__parseSVG(NSVGparser* p, const char** attr)
 {
-    int i;
-    for (i = 0; attr[i]; i += 2) {
-        if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "width") == 0) {
-                p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
-            } else if (strcmp(attr[i], "height") == 0) {
-                p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
-            } else if (strcmp(attr[i], "viewBox") == 0) {
-                sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
-            } else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
-                if (strstr(attr[i + 1], "none") != 0) {
-                    // No uniform scaling
-                    p->alignType = NSVG_ALIGN_NONE;
-                } else {
-                    // Parse X align
-                    if (strstr(attr[i + 1], "xMin") != 0)
-                        p->alignX = NSVG_ALIGN_MIN;
-                    else if (strstr(attr[i + 1], "xMid") != 0)
-                        p->alignX = NSVG_ALIGN_MID;
-                    else if (strstr(attr[i + 1], "xMax") != 0)
-                        p->alignX = NSVG_ALIGN_MAX;
-                    // Parse X align
-                    if (strstr(attr[i + 1], "yMin") != 0)
-                        p->alignY = NSVG_ALIGN_MIN;
-                    else if (strstr(attr[i + 1], "yMid") != 0)
-                        p->alignY = NSVG_ALIGN_MID;
-                    else if (strstr(attr[i + 1], "yMax") != 0)
-                        p->alignY = NSVG_ALIGN_MAX;
-                    // Parse meet/slice
-                    p->alignType = NSVG_ALIGN_MEET;
-                    if (strstr(attr[i + 1], "slice") != 0)
-                        p->alignType = NSVG_ALIGN_SLICE;
-                }
-            }
-        }
-    }
+       int i;
+       for (i = 0; attr[i]; i += 2) {
+               if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "width") == 0) {
+                               p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+                       } else if (strcmp(attr[i], "height") == 0) {
+                               p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+                       } else if (strcmp(attr[i], "viewBox") == 0) {
+                               sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
+                       } else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
+                               if (strstr(attr[i + 1], "none") != 0) {
+                                       // No uniform scaling
+                                       p->alignType = NSVG_ALIGN_NONE;
+                               } else {
+                                       // Parse X align
+                                       if (strstr(attr[i + 1], "xMin") != 0)
+                                               p->alignX = NSVG_ALIGN_MIN;
+                                       else if (strstr(attr[i + 1], "xMid") != 0)
+                                               p->alignX = NSVG_ALIGN_MID;
+                                       else if (strstr(attr[i + 1], "xMax") != 0)
+                                               p->alignX = NSVG_ALIGN_MAX;
+                                       // Parse X align
+                                       if (strstr(attr[i + 1], "yMin") != 0)
+                                               p->alignY = NSVG_ALIGN_MIN;
+                                       else if (strstr(attr[i + 1], "yMid") != 0)
+                                               p->alignY = NSVG_ALIGN_MID;
+                                       else if (strstr(attr[i + 1], "yMax") != 0)
+                                               p->alignY = NSVG_ALIGN_MAX;
+                                       // Parse meet/slice
+                                       p->alignType = NSVG_ALIGN_MEET;
+                                       if (strstr(attr[i + 1], "slice") != 0)
+                                               p->alignType = NSVG_ALIGN_SLICE;
+                               }
+                       }
+               }
+       }
 }
 
 static void nsvg__parseGradient(NSVGparser* p, const char** attr, char type)
 {
-    int i;
-    NSVGgradientData* grad = (NSVGgradientData*)malloc(sizeof(NSVGgradientData));
-    if (grad == NULL) return;
-    memset(grad, 0, sizeof(NSVGgradientData));
-    grad->units = NSVG_OBJECT_SPACE;
-    grad->type = type;
-    if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
-        grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
-        grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
-        grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
-        grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
-    } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
-        grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
-        grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
-        grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
-    }
-
-    nsvg__xformIdentity(grad->xform);
-
-    for (i = 0; attr[i]; i += 2) {
-        if (strcmp(attr[i], "id") == 0) {
-            strncpy(grad->id, attr[i+1], 63);
-            grad->id[63] = '\0';
-        } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
-            if (strcmp(attr[i], "gradientUnits") == 0) {
-                if (strcmp(attr[i+1], "objectBoundingBox") == 0)
-                    grad->units = NSVG_OBJECT_SPACE;
-                else
-                    grad->units = NSVG_USER_SPACE;
-            } else if (strcmp(attr[i], "gradientTransform") == 0) {
-                nsvg__parseTransform(grad->xform, attr[i + 1]);
-            } else if (strcmp(attr[i], "cx") == 0) {
-                grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "cy") == 0) {
-                grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "r") == 0) {
-                grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "fx") == 0) {
-                grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "fy") == 0) {
-                grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "x1") == 0) {
-                grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "y1") == 0) {
-                grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "x2") == 0) {
-                grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "y2") == 0) {
-                grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
-            } else if (strcmp(attr[i], "spreadMethod") == 0) {
-                if (strcmp(attr[i+1], "pad") == 0)
-                    grad->spread = NSVG_SPREAD_PAD;
-                else if (strcmp(attr[i+1], "reflect") == 0)
-                    grad->spread = NSVG_SPREAD_REFLECT;
-                else if (strcmp(attr[i+1], "repeat") == 0)
-                    grad->spread = NSVG_SPREAD_REPEAT;
-            } else if (strcmp(attr[i], "xlink:href") == 0) {
-                const char *href = attr[i+1];
-                strncpy(grad->ref, href+1, 62);
-                grad->ref[62] = '\0';
-            }
-        }
-    }
-
-    grad->next = p->gradients;
-    p->gradients = grad;
+       int i;
+       NSVGgradientData* grad = (NSVGgradientData*)malloc(sizeof(NSVGgradientData));
+       if (grad == NULL) return;
+       memset(grad, 0, sizeof(NSVGgradientData));
+       grad->units = NSVG_OBJECT_SPACE;
+       grad->type = type;
+       if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
+               grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+               grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+               grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
+               grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+       } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
+               grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+               grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+               grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+       }
+
+       nsvg__xformIdentity(grad->xform);
+
+       for (i = 0; attr[i]; i += 2) {
+               if (strcmp(attr[i], "id") == 0) {
+                       strncpy(grad->id, attr[i+1], 63);
+                       grad->id[63] = '\0';
+               } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+                       if (strcmp(attr[i], "gradientUnits") == 0) {
+                               if (strcmp(attr[i+1], "objectBoundingBox") == 0)
+                                       grad->units = NSVG_OBJECT_SPACE;
+                               else
+                                       grad->units = NSVG_USER_SPACE;
+                       } else if (strcmp(attr[i], "gradientTransform") == 0) {
+                               nsvg__parseTransform(grad->xform, attr[i + 1]);
+                       } else if (strcmp(attr[i], "cx") == 0) {
+                               grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "cy") == 0) {
+                               grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "r") == 0) {
+                               grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "fx") == 0) {
+                               grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "fy") == 0) {
+                               grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "x1") == 0) {
+                               grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "y1") == 0) {
+                               grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "x2") == 0) {
+                               grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "y2") == 0) {
+                               grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+                       } else if (strcmp(attr[i], "spreadMethod") == 0) {
+                               if (strcmp(attr[i+1], "pad") == 0)
+                                       grad->spread = NSVG_SPREAD_PAD;
+                               else if (strcmp(attr[i+1], "reflect") == 0)
+                                       grad->spread = NSVG_SPREAD_REFLECT;
+                               else if (strcmp(attr[i+1], "repeat") == 0)
+                                       grad->spread = NSVG_SPREAD_REPEAT;
+                       } else if (strcmp(attr[i], "xlink:href") == 0) {
+                               const char *href = attr[i+1];
+                               strncpy(grad->ref, href+1, 62);
+                               grad->ref[62] = '\0';
+                       }
+               }
+       }
+
+       grad->next = p->gradients;
+       p->gradients = grad;
 }
 
 static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
 {
-    NSVGattrib* curAttr = nsvg__getAttr(p);
-    NSVGgradientData* grad;
-    NSVGgradientStop* stop;
-    int i, idx;
-
-    curAttr->stopOffset = 0;
-    curAttr->stopColor = 0;
-    curAttr->stopOpacity = 1.0f;
-
-    for (i = 0; attr[i]; i += 2) {
-        nsvg__parseAttr(p, attr[i], attr[i + 1]);
-    }
-
-    // Add stop to the last gradient.
-    grad = p->gradients;
-    if (grad == NULL) return;
-
-    grad->nstops++;
-    grad->stops = (NSVGgradientStop*)realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
-    if (grad->stops == NULL) return;
-
-    // Insert
-    idx = grad->nstops-1;
-    for (i = 0; i < grad->nstops-1; i++) {
-        if (curAttr->stopOffset < grad->stops[i].offset) {
-            idx = i;
-            break;
-        }
-    }
-    if (idx != grad->nstops-1) {
-        for (i = grad->nstops-1; i > idx; i--)
-            grad->stops[i] = grad->stops[i-1];
-    }
-
-    stop = &grad->stops[idx];
-    stop->color = curAttr->stopColor;
-    stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
-    stop->offset = curAttr->stopOffset;
+       NSVGattrib* curAttr = nsvg__getAttr(p);
+       NSVGgradientData* grad;
+       NSVGgradientStop* stop;
+       int i, idx;
+
+       curAttr->stopOffset = 0;
+       curAttr->stopColor = 0;
+       curAttr->stopOpacity = 1.0f;
+
+       for (i = 0; attr[i]; i += 2) {
+               nsvg__parseAttr(p, attr[i], attr[i + 1]);
+       }
+
+       // Add stop to the last gradient.
+       grad = p->gradients;
+       if (grad == NULL) return;
+
+       grad->nstops++;
+       grad->stops = (NSVGgradientStop*)realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
+       if (grad->stops == NULL) return;
+
+       // Insert
+       idx = grad->nstops-1;
+       for (i = 0; i < grad->nstops-1; i++) {
+               if (curAttr->stopOffset < grad->stops[i].offset) {
+                       idx = i;
+                       break;
+               }
+       }
+       if (idx != grad->nstops-1) {
+               for (i = grad->nstops-1; i > idx; i--)
+                       grad->stops[i] = grad->stops[i-1];
+       }
+
+       stop = &grad->stops[idx];
+       stop->color = curAttr->stopColor;
+       stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
+       stop->offset = curAttr->stopOffset;
 }
 
 static void nsvg__startElement(void* ud, const char* el, const char** attr)
 {
-    NSVGparser* p = (NSVGparser*)ud;
-
-    if (p->defsFlag) {
-        // Skip everything but gradients in defs
-        if (strcmp(el, "linearGradient") == 0) {
-            nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
-        } else if (strcmp(el, "radialGradient") == 0) {
-            nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
-        } else if (strcmp(el, "stop") == 0) {
-            nsvg__parseGradientStop(p, attr);
-        }
-        return;
-    }
-
-    if (strcmp(el, "g") == 0) {
-        nsvg__pushAttr(p);
-        nsvg__parseAttribs(p, attr);
-    } else if (strcmp(el, "path") == 0) {
-        if (p->pathFlag)    // Do not allow nested paths.
-            return;
-        nsvg__pushAttr(p);
-        nsvg__parsePath(p, attr);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "rect") == 0) {
-        nsvg__pushAttr(p);
-        nsvg__parseRect(p, attr);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "circle") == 0) {
-        nsvg__pushAttr(p);
-        nsvg__parseCircle(p, attr);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "ellipse") == 0) {
-        nsvg__pushAttr(p);
-        nsvg__parseEllipse(p, attr);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "line") == 0)  {
-        nsvg__pushAttr(p);
-        nsvg__parseLine(p, attr);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "polyline") == 0)  {
-        nsvg__pushAttr(p);
-        nsvg__parsePoly(p, attr, 0);
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "polygon") == 0)  {
-        nsvg__pushAttr(p);
-        nsvg__parsePoly(p, attr, 1);
-        nsvg__popAttr(p);
-    } else  if (strcmp(el, "linearGradient") == 0) {
-        nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
-    } else if (strcmp(el, "radialGradient") == 0) {
-        nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
-    } else if (strcmp(el, "stop") == 0) {
-        nsvg__parseGradientStop(p, attr);
-    } else if (strcmp(el, "defs") == 0) {
-        p->defsFlag = 1;
-    } else if (strcmp(el, "svg") == 0) {
-        nsvg__parseSVG(p, attr);
-    }
+       NSVGparser* p = (NSVGparser*)ud;
+
+       if (p->defsFlag) {
+               // Skip everything but gradients in defs
+               if (strcmp(el, "linearGradient") == 0) {
+                       nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+               } else if (strcmp(el, "radialGradient") == 0) {
+                       nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+               } else if (strcmp(el, "stop") == 0) {
+                       nsvg__parseGradientStop(p, attr);
+               }
+               return;
+       }
+
+       if (strcmp(el, "g") == 0) {
+               nsvg__pushAttr(p);
+               nsvg__parseAttribs(p, attr);
+       } else if (strcmp(el, "path") == 0) {
+               if (p->pathFlag)        // Do not allow nested paths.
+                       return;
+               nsvg__pushAttr(p);
+               nsvg__parsePath(p, attr);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "rect") == 0) {
+               nsvg__pushAttr(p);
+               nsvg__parseRect(p, attr);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "circle") == 0) {
+               nsvg__pushAttr(p);
+               nsvg__parseCircle(p, attr);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "ellipse") == 0) {
+               nsvg__pushAttr(p);
+               nsvg__parseEllipse(p, attr);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "line") == 0)  {
+               nsvg__pushAttr(p);
+               nsvg__parseLine(p, attr);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "polyline") == 0)  {
+               nsvg__pushAttr(p);
+               nsvg__parsePoly(p, attr, 0);
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "polygon") == 0)  {
+               nsvg__pushAttr(p);
+               nsvg__parsePoly(p, attr, 1);
+               nsvg__popAttr(p);
+       } else  if (strcmp(el, "linearGradient") == 0) {
+               nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+       } else if (strcmp(el, "radialGradient") == 0) {
+               nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+       } else if (strcmp(el, "stop") == 0) {
+               nsvg__parseGradientStop(p, attr);
+       } else if (strcmp(el, "defs") == 0) {
+               p->defsFlag = 1;
+       } else if (strcmp(el, "svg") == 0) {
+               nsvg__parseSVG(p, attr);
+       }
 }
 
 static void nsvg__endElement(void* ud, const char* el)
 {
-    NSVGparser* p = (NSVGparser*)ud;
+       NSVGparser* p = (NSVGparser*)ud;
 
-    if (strcmp(el, "g") == 0) {
-        nsvg__popAttr(p);
-    } else if (strcmp(el, "path") == 0) {
-        p->pathFlag = 0;
-    } else if (strcmp(el, "defs") == 0) {
-        p->defsFlag = 0;
-    }
+       if (strcmp(el, "g") == 0) {
+               nsvg__popAttr(p);
+       } else if (strcmp(el, "path") == 0) {
+               p->pathFlag = 0;
+       } else if (strcmp(el, "defs") == 0) {
+               p->defsFlag = 0;
+       }
 }
 
 static void nsvg__content(void* ud, const char* s)
 {
-    NSVG_NOTUSED(ud);
-    NSVG_NOTUSED(s);
-    // empty
+       NSVG_NOTUSED(ud);
+       NSVG_NOTUSED(s);
+       // empty
 }
 
 static void nsvg__imageBounds(NSVGparser* p, float* bounds)
 {
-    NSVGshape* shape;
-    shape = p->image->shapes;
-    if (shape == NULL) {
-        bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
-        return;
-    }
-    bounds[0] = shape->bounds[0];
-    bounds[1] = shape->bounds[1];
-    bounds[2] = shape->bounds[2];
-    bounds[3] = shape->bounds[3];
-    for (shape = shape->next; shape != NULL; shape = shape->next) {
-        bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
-        bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
-        bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
-        bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
-    }
+       NSVGshape* shape;
+       shape = p->image->shapes;
+       if (shape == NULL) {
+               bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
+               return;
+       }
+       bounds[0] = shape->bounds[0];
+       bounds[1] = shape->bounds[1];
+       bounds[2] = shape->bounds[2];
+       bounds[3] = shape->bounds[3];
+       for (shape = shape->next; shape != NULL; shape = shape->next) {
+               bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
+               bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
+               bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
+               bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
+       }
 }
 
 static float nsvg__viewAlign(float content, float container, int type)
 {
-    if (type == NSVG_ALIGN_MIN)
-        return 0;
-    else if (type == NSVG_ALIGN_MAX)
-        return container - content;
-    // mid
-    return (container - content) * 0.5f;
+       if (type == NSVG_ALIGN_MIN)
+               return 0;
+       else if (type == NSVG_ALIGN_MAX)
+               return container - content;
+       // mid
+       return (container - content) * 0.5f;
 }
 
 static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
 {
-    grad->xform[0] *= sx;
-    grad->xform[1] *= sx;
-    grad->xform[2] *= sy;
-    grad->xform[3] *= sy;
-    grad->xform[4] += tx*sx;
-    grad->xform[5] += ty*sx;
+       float t[6];
+       nsvg__xformSetTranslation(t, tx, ty);
+       nsvg__xformMultiply (grad->xform, t);
+
+       nsvg__xformSetScale(t, sx, sy);
+       nsvg__xformMultiply (grad->xform, t);
 }
 
 static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
 {
-    NSVGshape* shape;
-    NSVGpath* path;
-    float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
-    int i;
-    float* pt;
-
-    // Guess image size if not set completely.
-    nsvg__imageBounds(p, bounds);
-
-    if (p->viewWidth == 0) {
-        if (p->image->width > 0) {
-            p->viewWidth = p->image->width;
-        } else {
-            p->viewMinx = bounds[0];
-            p->viewWidth = bounds[2] - bounds[0];
-        }
-    }
-    if (p->viewHeight == 0) {
-        if (p->image->height > 0) {
-            p->viewHeight = p->image->height;
-        } else {
-            p->viewMiny = bounds[1];
-            p->viewHeight = bounds[3] - bounds[1];
-        }
-    }
-    if (p->image->width <= 1)
-        p->image->width = p->viewWidth;
-    if (p->image->height <= 1)
-        p->image->height = p->viewHeight;
-
-    tx = -p->viewMinx;
-    ty = -p->viewMiny;
-    sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
-    sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
-    // Unit scaling
-    us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
-
-    // Fix aspect ratio
-    if (p->alignType == NSVG_ALIGN_MEET) {
-        // fit whole image into viewbox
-        sx = sy = nsvg__minf(sx, sy);
-        tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
-        ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
-    } else if (p->alignType == NSVG_ALIGN_SLICE) {
-        // fill whole viewbox with image
-        sx = sy = nsvg__maxf(sx, sy);
-        tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
-        ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
-    }
-
-    // Transform
-    sx *= us;
-    sy *= us;
-    avgs = (sx+sy) / 2.0f;
-    for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
-        shape->bounds[0] = (shape->bounds[0] + tx) * sx;
-        shape->bounds[1] = (shape->bounds[1] + ty) * sy;
-        shape->bounds[2] = (shape->bounds[2] + tx) * sx;
-        shape->bounds[3] = (shape->bounds[3] + ty) * sy;
-        for (path = shape->paths; path != NULL; path = path->next) {
-            path->bounds[0] = (path->bounds[0] + tx) * sx;
-            path->bounds[1] = (path->bounds[1] + ty) * sy;
-            path->bounds[2] = (path->bounds[2] + tx) * sx;
-            path->bounds[3] = (path->bounds[3] + ty) * sy;
-            for (i =0; i < path->npts; i++) {
-                pt = &path->pts[i*2];
-                pt[0] = (pt[0] + tx) * sx;
-                pt[1] = (pt[1] + ty) * sy;
-            }
-        }
-
-        if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
-            nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
-            memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
-            nsvg__xformInverse(shape->fill.gradient->xform, t);
-        }
-        if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
-            nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
-            memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
-            nsvg__xformInverse(shape->stroke.gradient->xform, t);
-        }
-
-        shape->strokeWidth *= avgs;
-        shape->strokeDashOffset *= avgs;
-        for (i = 0; i < shape->strokeDashCount; i++)
-            shape->strokeDashArray[i] *= avgs;
-    }
+       NSVGshape* shape;
+       NSVGpath* path;
+       float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
+       int i;
+       float* pt;
+
+       // Guess image size if not set completely.
+       nsvg__imageBounds(p, bounds);
+
+       if (p->viewWidth == 0) {
+               if (p->image->width > 0) {
+                       p->viewWidth = p->image->width;
+               } else {
+                       p->viewMinx = bounds[0];
+                       p->viewWidth = bounds[2] - bounds[0];
+               }
+       }
+       if (p->viewHeight == 0) {
+               if (p->image->height > 0) {
+                       p->viewHeight = p->image->height;
+               } else {
+                       p->viewMiny = bounds[1];
+                       p->viewHeight = bounds[3] - bounds[1];
+               }
+       }
+
+       /**
+        * We have sample images with the width and height set to 1, whereas the viewbox aspect ratio 
+        * is not square. Use the viewbox in this case.
+        */
+       if (p->image->width <= 1)
+               p->image->width = p->viewWidth;
+       if (p->image->height <= 1)
+               p->image->height = p->viewHeight;
+
+       tx = -p->viewMinx;
+       ty = -p->viewMiny;
+       sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
+       sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
+       // Unit scaling
+       us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
+
+       // Fix aspect ratio
+       if (p->alignType == NSVG_ALIGN_MEET) {
+               // fit whole image into viewbox
+               sx = sy = nsvg__minf(sx, sy);
+               tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+               ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+       } else if (p->alignType == NSVG_ALIGN_SLICE) {
+               // fill whole viewbox with image
+               sx = sy = nsvg__maxf(sx, sy);
+               tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+               ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+       }
+
+       // Transform
+       sx *= us;
+       sy *= us;
+       avgs = (sx+sy) / 2.0f;
+       for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
+               shape->bounds[0] = (shape->bounds[0] + tx) * sx;
+               shape->bounds[1] = (shape->bounds[1] + ty) * sy;
+               shape->bounds[2] = (shape->bounds[2] + tx) * sx;
+               shape->bounds[3] = (shape->bounds[3] + ty) * sy;
+               for (path = shape->paths; path != NULL; path = path->next) {
+                       path->bounds[0] = (path->bounds[0] + tx) * sx;
+                       path->bounds[1] = (path->bounds[1] + ty) * sy;
+                       path->bounds[2] = (path->bounds[2] + tx) * sx;
+                       path->bounds[3] = (path->bounds[3] + ty) * sy;
+                       for (i =0; i < path->npts; i++) {
+                               pt = &path->pts[i*2];
+                               pt[0] = (pt[0] + tx) * sx;
+                               pt[1] = (pt[1] + ty) * sy;
+                       }
+               }
+
+               if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
+                       nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
+                       memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
+                       nsvg__xformInverse(shape->fill.gradient->xform, t);
+               }
+               if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
+                       nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
+                       memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
+                       nsvg__xformInverse(shape->stroke.gradient->xform, t);
+               }
+
+               shape->strokeWidth *= avgs;
+               shape->strokeDashOffset *= avgs;
+               for (i = 0; i < shape->strokeDashCount; i++)
+                       shape->strokeDashArray[i] *= avgs;
+       }
 }
 
 NSVGimage* nsvgParse(char* input, const char* units, float dpi)
 {
-    NSVGparser* p;
-    NSVGimage* ret = 0;
+       NSVGparser* p;
+       NSVGimage* ret = 0;
 
-    p = nsvg__createParser();
-    if (p == NULL) {
-        return NULL;
-    }
-    p->dpi = dpi;
+       p = nsvg__createParser();
+       if (p == NULL) {
+               return NULL;
+       }
+       p->dpi = dpi;
 
-    nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
+       nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
 
-    // Scale to viewBox
-    nsvg__scaleToViewbox(p, units);
+       // Scale to viewBox
+       nsvg__scaleToViewbox(p, units);
 
-    ret = p->image;
-    p->image = NULL;
+       ret = p->image;
+       p->image = NULL;
 
-    nsvg__deleteParser(p);
+       nsvg__deleteParser(p);
 
-    return ret;
+       return ret;
 }
 
 NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
 {
-    FILE* fp = NULL;
-    size_t size;
-    char* data = NULL;
-    NSVGimage* image = NULL;
-
-    fp = fopen(filename, "rb");
-    if (!fp) goto error;
-    fseek(fp, 0, SEEK_END);
-    size = ftell(fp);
-    fseek(fp, 0, SEEK_SET);
-    data = (char*)malloc(size+1);
-    if (data == NULL) goto error;
-    if (fread(data, 1, size, fp) != size) goto error;
-    data[size] = '\0';  // Must be null terminated.
-    fclose(fp);
-    image = nsvgParse(data, units, dpi);
-    free(data);
-
-    return image;
+       FILE* fp = NULL;
+       size_t size;
+       char* data = NULL;
+       NSVGimage* image = NULL;
+
+       fp = fopen(filename, "rb");
+       if (!fp) goto error;
+       fseek(fp, 0, SEEK_END);
+       size = ftell(fp);
+       fseek(fp, 0, SEEK_SET);
+       data = (char*)malloc(size+1);
+       if (data == NULL) goto error;
+       if (fread(data, 1, size, fp) != size) goto error;
+       data[size] = '\0';      // Must be null terminated.
+       fclose(fp);
+       image = nsvgParse(data, units, dpi);
+       free(data);
+
+       return image;
 
 error:
-    if (fp) fclose(fp);
-    if (data) free(data);
-    if (image) nsvgDelete(image);
-    return NULL;
+       if (fp) fclose(fp);
+       if (data) free(data);
+       if (image) nsvgDelete(image);
+       return NULL;
 }
 
 void nsvgDelete(NSVGimage* image)
 {
     if (image == NULL) return;
-
-    NSVGshape *snext, *shape;
-    shape = image->shapes;
-    while (shape != NULL) {
-        snext = shape->next;
-        nsvg__deletePaths(shape->paths);
-        nsvg__deletePaint(&shape->fill);
-        nsvg__deletePaint(&shape->stroke);
-        free(shape);
-        shape = snext;
-    }
-    free(image);
+       NSVGshape *snext, *shape;
+       shape = image->shapes;
+       while (shape != NULL) {
+               snext = shape->next;
+               nsvg__deletePaths(shape->paths);
+               nsvg__deletePaint(&shape->fill);
+               nsvg__deletePaint(&shape->stroke);
+               free(shape);
+               shape = snext;
+       }
+       free(image);
 }
index 2634297..0e2bad8 100644 (file)
 
 
 /* Example Usage:
-       // Load
-       SNVGImage* image;
-       image = nsvgParseFromFile("test.svg", "px", 96);
-       printf("size: %f x %f\n", image->width, image->height);
-       // Use...
-       for (shape = image->shapes; shape != NULL; shape = shape->next) {
-               for (path = shape->paths; path != NULL; path = path->next) {
-                       for (i = 0; i < path->npts-1; i += 3) {
-                               float* p = &path->pts[i*2];
-                               drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
-                       }
-               }
-       }
-       // Delete
-       nsvgDelete(image);
+  // Load
+  SNVGImage* image;
+  image = nsvgParseFromFile("test.svg", "px", 96);
+  printf("size: %f x %f\n", image->width, image->height);
+  // Use...
+  for (shape = image->shapes; shape != NULL; shape = shape->next) {
+    for (path = shape->paths; path != NULL; path = path->next) {
+      for (i = 0; i < path->npts-1; i += 3) {
+        float* p = &path->pts[i*2];
+        drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
+      }
+    }
+  }
+  // Delete
+  nsvgDelete(image);
 */
 
 enum NSVGpaintType {
-       NSVG_PAINT_NONE = 0,
-       NSVG_PAINT_COLOR = 1,
-       NSVG_PAINT_LINEAR_GRADIENT = 2,
-       NSVG_PAINT_RADIAL_GRADIENT = 3,
+  NSVG_PAINT_NONE = 0,
+  NSVG_PAINT_COLOR = 1,
+  NSVG_PAINT_LINEAR_GRADIENT = 2,
+  NSVG_PAINT_RADIAL_GRADIENT = 3,
 };
 
 enum NSVGspreadType {
-       NSVG_SPREAD_PAD = 0,
-       NSVG_SPREAD_REFLECT = 1,
-       NSVG_SPREAD_REPEAT = 2,
+  NSVG_SPREAD_PAD = 0,
+  NSVG_SPREAD_REFLECT = 1,
+  NSVG_SPREAD_REPEAT = 2,
 };
 
 enum NSVGlineJoin {
-       NSVG_JOIN_MITER = 0,
-       NSVG_JOIN_ROUND = 1,
-       NSVG_JOIN_BEVEL = 2,
+  NSVG_JOIN_MITER = 0,
+  NSVG_JOIN_ROUND = 1,
+  NSVG_JOIN_BEVEL = 2,
 };
 
 enum NSVGlineCap {
-       NSVG_CAP_BUTT = 0,
-       NSVG_CAP_ROUND = 1,
-       NSVG_CAP_SQUARE = 2,
+  NSVG_CAP_BUTT = 0,
+  NSVG_CAP_ROUND = 1,
+  NSVG_CAP_SQUARE = 2,
 };
 
 enum NSVGfillRule {
-       NSVG_FILLRULE_NONZERO = 0,
-       NSVG_FILLRULE_EVENODD = 1,
+  NSVG_FILLRULE_NONZERO = 0,
+  NSVG_FILLRULE_EVENODD = 1,
 };
 
 enum NSVGflags {
-       NSVG_FLAGS_VISIBLE = 0x01
+  NSVG_FLAGS_VISIBLE = 0x01
 };
 
 typedef struct NSVGgradientStop {
-       unsigned int color;
-       float offset;
+  unsigned int color;
+  float offset;
 } NSVGgradientStop;
 
 typedef struct NSVGgradient {
-       float xform[6];
-       char spread;
-       float fx, fy;
-       int nstops;
-       NSVGgradientStop stops[1];
+  float xform[6];
+  char spread;
+  float fx, fy;
+  int nstops;
+  NSVGgradientStop stops[1];
 } NSVGgradient;
 
 typedef struct NSVGpaint {
-       /**
-        * In the original file, using char type (without signed or unsigned) can be interpreted
-        * as 'unsigned char' in some build environments, like ARM architecture.
-        * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
-        */
-       signed char type;
-       union {
-               unsigned int color;
-               NSVGgradient* gradient;
-       };
+  /**
+   * In the original file, using char type (without signed or unsigned) can be interpreted
+   * as 'unsigned char' in some build environments, like ARM architecture.
+   * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
+   */
+  signed char type;
+  union {
+    unsigned int  color;
+    NSVGgradient* gradient;
+  };
 } NSVGpaint;
 
 typedef struct NSVGpath
 {
-       float* pts;                                     // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
-       int npts;                                       // Total number of bezier points.
-       char closed;                            // Flag indicating if shapes should be treated as closed.
-       float bounds[4];                        // Tight bounding box of the shape [minx,miny,maxx,maxy].
-       struct NSVGpath* next;          // Pointer to next path, or NULL if last element.
+  float*           pts;         // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
+  int              npts;        // Total number of bezier points.
+  char             closed;      // Flag indicating if shapes should be treated as closed.
+  float            bounds[4];   // Tight bounding box of the shape [minx,miny,maxx,maxy].
+  struct NSVGpath* next;        // Pointer to next path, or NULL if last element.
 } NSVGpath;
 
 typedef struct NSVGshape
 {
-       char id[64];                            // Optional 'id' attr of the shape or its group
-       NSVGpaint fill;                         // Fill paint
-       NSVGpaint stroke;                       // Stroke paint
-       float opacity;                          // Opacity of the shape.
-       float strokeWidth;                      // Stroke width (scaled).
-       float strokeDashOffset;         // Stroke dash offset (scaled).
-       float strokeDashArray[8];                       // Stroke dash array (scaled).
-       char strokeDashCount;                           // Number of dash values in dash array.
-       char strokeLineJoin;            // Stroke join type.
-       char strokeLineCap;                     // Stroke cap type.
-       char fillRule;                          // Fill rule, see NSVGfillRule.
-       unsigned char flags;            // Logical or of NSVG_FLAGS_* flags
-       float bounds[4];                        // Tight bounding box of the shape [minx,miny,maxx,maxy].
-       NSVGpath* paths;                        // Linked list of paths in the image.
-       struct NSVGshape* next;         // Pointer to next shape, or NULL if last element.
+  char              id[64];     // Optional 'id' attr of the shape or its group
+  NSVGpaint         fill;       // Fill paint
+  NSVGpaint         stroke;     // Stroke paint
+  float             opacity;    // Opacity of the shape.
+  float             strokeWidth; // Stroke width (scaled).
+  float             strokeDashOffset; // Stroke dash offset (scaled).
+  float             strokeDashArray[8]; // Stroke dash array (scaled).
+  char              strokeDashCount; // Number of dash values in dash array.
+  char              strokeLineJoin; // Stroke join type.
+  char              strokeLineCap; // Stroke cap type.
+  float             miterLimit; // Miter limit
+  char              fillRule;   // Fill rule, see NSVGfillRule.
+  unsigned char     flags;      // Logical or of NSVG_FLAGS_* flags
+  float             bounds[4];  // Tight bounding box of the shape [minx,miny,maxx,maxy].
+  NSVGpath*         paths;      // Linked list of paths in the image.
+  struct NSVGshape* next;       // Pointer to next shape, or NULL if last element.
 } NSVGshape;
 
 typedef struct NSVGimage
 {
-       float width;                            // Width of the image.
-       float height;                           // Height of the image.
-       NSVGshape* shapes;                      // Linked list of shapes in the image.
+  float      width;             // Width of the image.
+  float      height;            // Height of the image.
+  NSVGshape* shapes;            // Linked list of shapes in the image.
 } NSVGimage;
 
 // Parses SVG file from a file, returns SVG image as paths.
index a3f3bdb..f0bff2e 100644 (file)
 #define NSVG__MEMPAGE_SIZE  1024
 
 typedef struct NSVGedge {
-    float x0,y0, x1,y1;
-    int dir;
-    struct NSVGedge* next;
+       float x0,y0, x1,y1;
+       int dir;
+       struct NSVGedge* next;
 } NSVGedge;
 
 typedef struct NSVGpoint {
-    float x, y;
-    float dx, dy;
-    float len;
-    float dmx, dmy;
-    unsigned char flags;
+       float x, y;
+       float dx, dy;
+       float len;
+       float dmx, dmy;
+       unsigned char flags;
 } NSVGpoint;
 
 typedef struct NSVGactiveEdge {
-    int x,dx;
-    float ey;
-    int dir;
-    struct NSVGactiveEdge *next;
+       int x,dx;
+       float ey;
+       int dir;
+       struct NSVGactiveEdge *next;
 } NSVGactiveEdge;
 
 typedef struct NSVGmemPage {
-    unsigned char mem[NSVG__MEMPAGE_SIZE];
-    int size;
-    struct NSVGmemPage* next;
+       unsigned char mem[NSVG__MEMPAGE_SIZE];
+       int size;
+       struct NSVGmemPage* next;
 } NSVGmemPage;
 
 typedef struct NSVGcachedPaint {
-    /**
-     * In the original file, using char type (without signed or unsigned) can be interpreted
-     * as 'unsigned char' in some build environments, like ARM architecture.
-     * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
-     */
-    signed char type;
-    char spread;
-    float xform[6];
-    unsigned int colors[256];
+  /**
+   * In the original file, using char type (without signed or unsigned) can be interpreted
+   * as 'unsigned char' in some build environments, like ARM architecture.
+   * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here.
+   */
+  signed char type;
+       char spread;
+       float xform[6];
+       unsigned int colors[256];
 } NSVGcachedPaint;
 
 struct NSVGrasterizer
 {
-    float px, py;
+       float px, py;
 
-    float tessTol;
-    float distTol;
+       float tessTol;
+       float distTol;
 
-    NSVGedge* edges;
-    int nedges;
-    int cedges;
+       NSVGedge* edges;
+       int nedges;
+       int cedges;
 
-    NSVGpoint* points;
-    int npoints;
-    int cpoints;
+       NSVGpoint* points;
+       int npoints;
+       int cpoints;
 
-    NSVGpoint* points2;
-    int npoints2;
-    int cpoints2;
+       NSVGpoint* points2;
+       int npoints2;
+       int cpoints2;
 
-    NSVGactiveEdge* freelist;
-    NSVGmemPage* pages;
-    NSVGmemPage* curpage;
+       NSVGactiveEdge* freelist;
+       NSVGmemPage* pages;
+       NSVGmemPage* curpage;
 
-    unsigned char* scanline;
-    int cscanline;
+       unsigned char* scanline;
+       int cscanline;
 
-    unsigned char* bitmap;
-    int width, height, stride;
+       unsigned char* bitmap;
+       int width, height, stride;
 };
 
 NSVGrasterizer* nsvgCreateRasterizer()
 {
-    NSVGrasterizer* r = (NSVGrasterizer*)malloc(sizeof(NSVGrasterizer));
-    if (r == NULL) goto error;
-    memset(r, 0, sizeof(NSVGrasterizer));
+       NSVGrasterizer* r = (NSVGrasterizer*)malloc(sizeof(NSVGrasterizer));
+       if (r == NULL) goto error;
+       memset(r, 0, sizeof(NSVGrasterizer));
 
-    r->tessTol = 0.25f;
-    r->distTol = 0.01f;
+       r->tessTol = 0.25f;
+       r->distTol = 0.01f;
 
-    return r;
+       return r;
 
 error:
-    nsvgDeleteRasterizer(r);
-    return NULL;
+       nsvgDeleteRasterizer(r);
+       return NULL;
 }
 
 void nsvgDeleteRasterizer(NSVGrasterizer* r)
 {
-    if (r == NULL) return;
-
-    NSVGmemPage* p;
-    p = r->pages;
-    while (p != NULL) {
-        NSVGmemPage* next = p->next;
-        free(p);
-        p = next;
-    }
-
-    if (r->edges) free(r->edges);
-    if (r->points) free(r->points);
-    if (r->points2) free(r->points2);
-    if (r->scanline) free(r->scanline);
-
-    free(r);
+       if (r == NULL) return;
+
+       NSVGmemPage* p;
+
+       p = r->pages;
+       while (p != NULL) {
+               NSVGmemPage* next = p->next;
+               free(p);
+               p = next;
+       }
+
+       if (r->edges) free(r->edges);
+       if (r->points) free(r->points);
+       if (r->points2) free(r->points2);
+       if (r->scanline) free(r->scanline);
+
+       free(r);
 }
 
 static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur)
 {
-    NSVGmemPage *newp;
+       NSVGmemPage *newp;
 
-    // If using existing chain, return the next page in chain
-    if (cur != NULL && cur->next != NULL) {
-        return cur->next;
-    }
+       // If using existing chain, return the next page in chain
+       if (cur != NULL && cur->next != NULL) {
+               return cur->next;
+       }
 
-    // Alloc new page
-    newp = (NSVGmemPage*)malloc(sizeof(NSVGmemPage));
-    if (newp == NULL) return NULL;
-    memset(newp, 0, sizeof(NSVGmemPage));
+       // Alloc new page
+       newp = (NSVGmemPage*)malloc(sizeof(NSVGmemPage));
+       if (newp == NULL) return NULL;
+       memset(newp, 0, sizeof(NSVGmemPage));
 
-    // Add to linked list
-    if (cur != NULL)
-        cur->next = newp;
-    else
-        r->pages = newp;
+       // Add to linked list
+       if (cur != NULL)
+               cur->next = newp;
+       else
+               r->pages = newp;
 
-    return newp;
+       return newp;
 }
 
 static void nsvg__resetPool(NSVGrasterizer* r)
 {
-    NSVGmemPage* p = r->pages;
-    while (p != NULL) {
-        p->size = 0;
-        p = p->next;
-    }
-    r->curpage = r->pages;
+       NSVGmemPage* p = r->pages;
+       while (p != NULL) {
+               p->size = 0;
+               p = p->next;
+       }
+       r->curpage = r->pages;
 }
 
 static unsigned char* nsvg__alloc(NSVGrasterizer* r, int size)
 {
-    unsigned char* buf;
-    if (size > NSVG__MEMPAGE_SIZE) return NULL;
-    if (r->curpage == NULL || r->curpage->size+size > NSVG__MEMPAGE_SIZE) {
-        r->curpage = nsvg__nextPage(r, r->curpage);
-    }
-    buf = &r->curpage->mem[r->curpage->size];
-    r->curpage->size += size;
-    return buf;
+       unsigned char* buf;
+       if (size > NSVG__MEMPAGE_SIZE) return NULL;
+       if (r->curpage == NULL || r->curpage->size+size > NSVG__MEMPAGE_SIZE) {
+               r->curpage = nsvg__nextPage(r, r->curpage);
+       }
+       buf = &r->curpage->mem[r->curpage->size];
+       r->curpage->size += size;
+       return buf;
 }
 
 static int nsvg__ptEquals(float x1, float y1, float x2, float y2, float tol)
 {
-    float dx = x2 - x1;
-    float dy = y2 - y1;
-    return dx*dx + dy*dy < tol*tol;
+       float dx = x2 - x1;
+       float dy = y2 - y1;
+       return dx*dx + dy*dy < tol*tol;
 }
 
 static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags)
 {
-    NSVGpoint* pt;
-
-    if (r->npoints > 0) {
-        pt = &r->points[r->npoints-1];
-        if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
-            pt->flags |= flags;
-            return;
-        }
-    }
-
-    if (r->npoints+1 > r->cpoints) {
-        r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
-        r->points = (NSVGpoint*)realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
-        if (r->points == NULL) return;
-    }
-
-    pt = &r->points[r->npoints];
-    pt->x = x;
-    pt->y = y;
-    pt->flags = (unsigned char)flags;
-    r->npoints++;
+       NSVGpoint* pt;
+
+       if (r->npoints > 0) {
+               pt = &r->points[r->npoints-1];
+               if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
+                       pt->flags = (unsigned char)(pt->flags | flags);
+                       return;
+               }
+       }
+
+       if (r->npoints+1 > r->cpoints) {
+               r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+               r->points = (NSVGpoint*)realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+               if (r->points == NULL) return;
+       }
+
+       pt = &r->points[r->npoints];
+       pt->x = x;
+       pt->y = y;
+       pt->flags = (unsigned char)flags;
+       r->npoints++;
 }
 
 static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint pt)
 {
-    if (r->npoints+1 > r->cpoints) {
-        r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
-        r->points = (NSVGpoint*)realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
-        if (r->points == NULL) return;
-    }
-    r->points[r->npoints] = pt;
-    r->npoints++;
+       if (r->npoints+1 > r->cpoints) {
+               r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+               r->points = (NSVGpoint*)realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+               if (r->points == NULL) return;
+       }
+       r->points[r->npoints] = pt;
+       r->npoints++;
 }
 
 static void nsvg__duplicatePoints(NSVGrasterizer* r)
 {
-    if (r->npoints > r->cpoints2) {
-        r->cpoints2 = r->npoints;
-        r->points2 = (NSVGpoint*)realloc(r->points2, sizeof(NSVGpoint) * r->cpoints2);
-        if (r->points2 == NULL) return;
-    }
-
-    memcpy(r->points2, r->points, sizeof(NSVGpoint) * r->npoints);
-    r->npoints2 = r->npoints;
+       if (r->npoints > r->cpoints2) {
+               r->cpoints2 = r->npoints;
+               r->points2 = (NSVGpoint*)realloc(r->points2, sizeof(NSVGpoint) * r->cpoints2);
+               if (r->points2 == NULL) return;
+       }
+
+       memcpy(r->points2, r->points, sizeof(NSVGpoint) * r->npoints);
+       r->npoints2 = r->npoints;
 }
 
 static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
 {
-    NSVGedge* e;
-
-    // Skip horizontal edges
-    if (y0 == y1)
-        return;
-
-    if (r->nedges+1 > r->cedges) {
-        r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
-        r->edges = (NSVGedge*)realloc(r->edges, sizeof(NSVGedge) * r->cedges);
-        if (r->edges == NULL) return;
-    }
-
-    e = &r->edges[r->nedges];
-    r->nedges++;
-
-    if (y0 < y1) {
-        e->x0 = x0;
-        e->y0 = y0;
-        e->x1 = x1;
-        e->y1 = y1;
-        e->dir = 1;
-    } else {
-        e->x0 = x1;
-        e->y0 = y1;
-        e->x1 = x0;
-        e->y1 = y0;
-        e->dir = -1;
-    }
+       NSVGedge* e;
+
+       // Skip horizontal edges
+       if (y0 == y1)
+               return;
+
+       if (r->nedges+1 > r->cedges) {
+               r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
+               r->edges = (NSVGedge*)realloc(r->edges, sizeof(NSVGedge) * r->cedges);
+               if (r->edges == NULL) return;
+       }
+
+       e = &r->edges[r->nedges];
+       r->nedges++;
+
+       if (y0 < y1) {
+               e->x0 = x0;
+               e->y0 = y0;
+               e->x1 = x1;
+               e->y1 = y1;
+               e->dir = 1;
+       } else {
+               e->x0 = x1;
+               e->y0 = y1;
+               e->x1 = x0;
+               e->y1 = y0;
+               e->dir = -1;
+       }
 }
 
 static float nsvg__normalize(float *x, float* y)
 {
-    float d = sqrtf((*x)*(*x) + (*y)*(*y));
-    if (d > 1e-6f) {
-        float id = 1.0f / d;
-        *x *= id;
-        *y *= id;
-    }
-    return d;
+       float d = sqrtf((*x)*(*x) + (*y)*(*y));
+       if (d > 1e-6f) {
+               float id = 1.0f / d;
+               *x *= id;
+               *y *= id;
+       }
+       return d;
 }
 
 static float nsvg__absf(float x) { return x < 0 ? -x : x; }
 
 static void nsvg__flattenCubicBez(NSVGrasterizer* r,
-                                  float x1, float y1, float x2, float y2,
-                                  float x3, float y3, float x4, float y4,
-                                  int level, int type)
+                                                                 float x1, float y1, float x2, float y2,
+                                                                 float x3, float y3, float x4, float y4,
+                                                                 int level, int type)
 {
-    float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
-    float dx,dy,d2,d3;
-
-    if (level > 10) return;
-
-    x12 = (x1+x2)*0.5f;
-    y12 = (y1+y2)*0.5f;
-    x23 = (x2+x3)*0.5f;
-    y23 = (y2+y3)*0.5f;
-    x34 = (x3+x4)*0.5f;
-    y34 = (y3+y4)*0.5f;
-    x123 = (x12+x23)*0.5f;
-    y123 = (y12+y23)*0.5f;
-
-    dx = x4 - x1;
-    dy = y4 - y1;
-    d2 = nsvg__absf(((x2 - x4) * dy - (y2 - y4) * dx));
-    d3 = nsvg__absf(((x3 - x4) * dy - (y3 - y4) * dx));
-
-    if ((d2 + d3)*(d2 + d3) < r->tessTol * (dx*dx + dy*dy)) {
-        nsvg__addPathPoint(r, x4, y4, type);
-        return;
-    }
-
-    x234 = (x23+x34)*0.5f;
-    y234 = (y23+y34)*0.5f;
-    x1234 = (x123+x234)*0.5f;
-    y1234 = (y123+y234)*0.5f;
-
-    nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
-    nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
+       float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
+       float dx,dy,d2,d3;
+
+       if (level > 10) return;
+
+       x12 = (x1+x2)*0.5f;
+       y12 = (y1+y2)*0.5f;
+       x23 = (x2+x3)*0.5f;
+       y23 = (y2+y3)*0.5f;
+       x34 = (x3+x4)*0.5f;
+       y34 = (y3+y4)*0.5f;
+       x123 = (x12+x23)*0.5f;
+       y123 = (y12+y23)*0.5f;
+
+       dx = x4 - x1;
+       dy = y4 - y1;
+       d2 = nsvg__absf(((x2 - x4) * dy - (y2 - y4) * dx));
+       d3 = nsvg__absf(((x3 - x4) * dy - (y3 - y4) * dx));
+
+       if ((d2 + d3)*(d2 + d3) < r->tessTol * (dx*dx + dy*dy)) {
+               nsvg__addPathPoint(r, x4, y4, type);
+               return;
+       }
+
+       x234 = (x23+x34)*0.5f;
+       y234 = (y23+y34)*0.5f;
+       x1234 = (x123+x234)*0.5f;
+       y1234 = (y123+y234)*0.5f;
+
+       nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
+       nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
 }
 
 static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
 {
-    int i, j;
-    NSVGpath* path;
-
-    for (path = shape->paths; path != NULL; path = path->next) {
-        r->npoints = 0;
-        // Flatten path
-        nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
-        for (i = 0; i < path->npts-1; i += 3) {
-            float* p = &path->pts[i*2];
-            nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
-        }
-        // Close path
-        nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
-        // Build edges
-        for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
-            nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
-    }
+       int i, j;
+       NSVGpath* path;
+
+       for (path = shape->paths; path != NULL; path = path->next) {
+               r->npoints = 0;
+               // Flatten path
+               nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+               for (i = 0; i < path->npts-1; i += 3) {
+                       float* p = &path->pts[i*2];
+                       nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
+               }
+               // Close path
+               nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+               // Build edges
+               for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
+                       nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
+       }
 }
 
 enum NSVGpointFlags
 {
-    NSVG_PT_CORNER = 0x01,
-    NSVG_PT_BEVEL = 0x02,
-    NSVG_PT_LEFT = 0x04,
+       NSVG_PT_CORNER = 0x01,
+       NSVG_PT_BEVEL = 0x02,
+       NSVG_PT_LEFT = 0x04
 };
 
 static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
 {
-    float w = lineWidth * 0.5f;
-    float dx = p1->x - p0->x;
-    float dy = p1->y - p0->y;
-    float len = nsvg__normalize(&dx, &dy);
-    float px = p0->x + dx*len*0.5f, py = p0->y + dy*len*0.5f;
-    float dlx = dy, dly = -dx;
-    float lx = px - dlx*w, ly = py - dly*w;
-    float rx = px + dlx*w, ry = py + dly*w;
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       float w = lineWidth * 0.5f;
+       float dx = p1->x - p0->x;
+       float dy = p1->y - p0->y;
+       float len = nsvg__normalize(&dx, &dy);
+       float px = p0->x + dx*len*0.5f, py = p0->y + dy*len*0.5f;
+       float dlx = dy, dly = -dx;
+       float lx = px - dlx*w, ly = py - dly*w;
+       float rx = px + dlx*w, ry = py + dly*w;
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 static void nsvg__buttCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
 {
-    float w = lineWidth * 0.5f;
-    float px = p->x, py = p->y;
-    float dlx = dy, dly = -dx;
-    float lx = px - dlx*w, ly = py - dly*w;
-    float rx = px + dlx*w, ry = py + dly*w;
-
-    nsvg__addEdge(r, lx, ly, rx, ry);
-
-    if (connect) {
-        nsvg__addEdge(r, left->x, left->y, lx, ly);
-        nsvg__addEdge(r, rx, ry, right->x, right->y);
-    }
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       float w = lineWidth * 0.5f;
+       float px = p->x, py = p->y;
+       float dlx = dy, dly = -dx;
+       float lx = px - dlx*w, ly = py - dly*w;
+       float rx = px + dlx*w, ry = py + dly*w;
+
+       nsvg__addEdge(r, lx, ly, rx, ry);
+
+       if (connect) {
+               nsvg__addEdge(r, left->x, left->y, lx, ly);
+               nsvg__addEdge(r, rx, ry, right->x, right->y);
+       }
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
 {
-    float w = lineWidth * 0.5f;
-    float px = p->x - dx*w, py = p->y - dy*w;
-    float dlx = dy, dly = -dx;
-    float lx = px - dlx*w, ly = py - dly*w;
-    float rx = px + dlx*w, ry = py + dly*w;
-
-    nsvg__addEdge(r, lx, ly, rx, ry);
-
-    if (connect) {
-        nsvg__addEdge(r, left->x, left->y, lx, ly);
-        nsvg__addEdge(r, rx, ry, right->x, right->y);
-    }
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       float w = lineWidth * 0.5f;
+       float px = p->x - dx*w, py = p->y - dy*w;
+       float dlx = dy, dly = -dx;
+       float lx = px - dlx*w, ly = py - dly*w;
+       float rx = px + dlx*w, ry = py + dly*w;
+
+       nsvg__addEdge(r, lx, ly, rx, ry);
+
+       if (connect) {
+               nsvg__addEdge(r, left->x, left->y, lx, ly);
+               nsvg__addEdge(r, rx, ry, right->x, right->y);
+       }
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 #ifndef NSVG_PI
@@ -412,537 +413,537 @@ static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right
 
 static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int ncap, int connect)
 {
-    int i;
-    float w = lineWidth * 0.5f;
-    float px = p->x, py = p->y;
-    float dlx = dy, dly = -dx;
-    float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
-
-    for (i = 0; i < ncap; i++) {
-        float a = i/(float)(ncap-1)*NSVG_PI;
-        float ax = cosf(a) * w, ay = sinf(a) * w;
-        float x = px - dlx*ax - dx*ay;
-        float y = py - dly*ax - dy*ay;
-
-        if (i > 0)
-            nsvg__addEdge(r, prevx, prevy, x, y);
-
-        prevx = x;
-        prevy = y;
-
-        if (i == 0) {
-            lx = x; ly = y;
-        } else if (i == ncap-1) {
-            rx = x; ry = y;
-        }
-    }
-
-    if (connect) {
-        nsvg__addEdge(r, left->x, left->y, lx, ly);
-        nsvg__addEdge(r, rx, ry, right->x, right->y);
-    }
-
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       int i;
+       float w = lineWidth * 0.5f;
+       float px = p->x, py = p->y;
+       float dlx = dy, dly = -dx;
+       float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
+
+       for (i = 0; i < ncap; i++) {
+               float a = (float)i/(float)(ncap-1)*NSVG_PI;
+               float ax = cosf(a) * w, ay = sinf(a) * w;
+               float x = px - dlx*ax - dx*ay;
+               float y = py - dly*ax - dy*ay;
+
+               if (i > 0)
+                       nsvg__addEdge(r, prevx, prevy, x, y);
+
+               prevx = x;
+               prevy = y;
+
+               if (i == 0) {
+                       lx = x; ly = y;
+               } else if (i == ncap-1) {
+                       rx = x; ry = y;
+               }
+       }
+
+       if (connect) {
+               nsvg__addEdge(r, left->x, left->y, lx, ly);
+               nsvg__addEdge(r, rx, ry, right->x, right->y);
+       }
+
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
 {
-    float w = lineWidth * 0.5f;
-    float dlx0 = p0->dy, dly0 = -p0->dx;
-    float dlx1 = p1->dy, dly1 = -p1->dx;
-    float lx0 = p1->x - (dlx0 * w), ly0 = p1->y - (dly0 * w);
-    float rx0 = p1->x + (dlx0 * w), ry0 = p1->y + (dly0 * w);
-    float lx1 = p1->x - (dlx1 * w), ly1 = p1->y - (dly1 * w);
-    float rx1 = p1->x + (dlx1 * w), ry1 = p1->y + (dly1 * w);
-
-    nsvg__addEdge(r, lx0, ly0, left->x, left->y);
-    nsvg__addEdge(r, lx1, ly1, lx0, ly0);
-
-    nsvg__addEdge(r, right->x, right->y, rx0, ry0);
-    nsvg__addEdge(r, rx0, ry0, rx1, ry1);
-
-    left->x = lx1; left->y = ly1;
-    right->x = rx1; right->y = ry1;
+       float w = lineWidth * 0.5f;
+       float dlx0 = p0->dy, dly0 = -p0->dx;
+       float dlx1 = p1->dy, dly1 = -p1->dx;
+       float lx0 = p1->x - (dlx0 * w), ly0 = p1->y - (dly0 * w);
+       float rx0 = p1->x + (dlx0 * w), ry0 = p1->y + (dly0 * w);
+       float lx1 = p1->x - (dlx1 * w), ly1 = p1->y - (dly1 * w);
+       float rx1 = p1->x + (dlx1 * w), ry1 = p1->y + (dly1 * w);
+
+       nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+       nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+       nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+       nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+
+       left->x = lx1; left->y = ly1;
+       right->x = rx1; right->y = ry1;
 }
 
 static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
 {
-    float w = lineWidth * 0.5f;
-    float dlx0 = p0->dy, dly0 = -p0->dx;
-    float dlx1 = p1->dy, dly1 = -p1->dx;
-    float lx0, rx0, lx1, rx1;
-    float ly0, ry0, ly1, ry1;
-
-    if (p1->flags & NSVG_PT_LEFT) {
-        lx0 = lx1 = p1->x - p1->dmx * w;
-        ly0 = ly1 = p1->y - p1->dmy * w;
-        nsvg__addEdge(r, lx1, ly1, left->x, left->y);
-
-        rx0 = p1->x + (dlx0 * w);
-        ry0 = p1->y + (dly0 * w);
-        rx1 = p1->x + (dlx1 * w);
-        ry1 = p1->y + (dly1 * w);
-        nsvg__addEdge(r, right->x, right->y, rx0, ry0);
-        nsvg__addEdge(r, rx0, ry0, rx1, ry1);
-    } else {
-        lx0 = p1->x - (dlx0 * w);
-        ly0 = p1->y - (dly0 * w);
-        lx1 = p1->x - (dlx1 * w);
-        ly1 = p1->y - (dly1 * w);
-        nsvg__addEdge(r, lx0, ly0, left->x, left->y);
-        nsvg__addEdge(r, lx1, ly1, lx0, ly0);
-
-        rx0 = rx1 = p1->x + p1->dmx * w;
-        ry0 = ry1 = p1->y + p1->dmy * w;
-        nsvg__addEdge(r, right->x, right->y, rx1, ry1);
-    }
-
-    left->x = lx1; left->y = ly1;
-    right->x = rx1; right->y = ry1;
+       float w = lineWidth * 0.5f;
+       float dlx0 = p0->dy, dly0 = -p0->dx;
+       float dlx1 = p1->dy, dly1 = -p1->dx;
+       float lx0, rx0, lx1, rx1;
+       float ly0, ry0, ly1, ry1;
+
+       if (p1->flags & NSVG_PT_LEFT) {
+               lx0 = lx1 = p1->x - p1->dmx * w;
+               ly0 = ly1 = p1->y - p1->dmy * w;
+               nsvg__addEdge(r, lx1, ly1, left->x, left->y);
+
+               rx0 = p1->x + (dlx0 * w);
+               ry0 = p1->y + (dly0 * w);
+               rx1 = p1->x + (dlx1 * w);
+               ry1 = p1->y + (dly1 * w);
+               nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+               nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+       } else {
+               lx0 = p1->x - (dlx0 * w);
+               ly0 = p1->y - (dly0 * w);
+               lx1 = p1->x - (dlx1 * w);
+               ly1 = p1->y - (dly1 * w);
+               nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+               nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+               rx0 = rx1 = p1->x + p1->dmx * w;
+               ry0 = ry1 = p1->y + p1->dmy * w;
+               nsvg__addEdge(r, right->x, right->y, rx1, ry1);
+       }
+
+       left->x = lx1; left->y = ly1;
+       right->x = rx1; right->y = ry1;
 }
 
 static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth, int ncap)
 {
-    int i, n;
-    float w = lineWidth * 0.5f;
-    float dlx0 = p0->dy, dly0 = -p0->dx;
-    float dlx1 = p1->dy, dly1 = -p1->dx;
-    float a0 = atan2f(dly0, dlx0);
-    float a1 = atan2f(dly1, dlx1);
-    float da = a1 - a0;
-    float lx, ly, rx, ry;
-
-    if (da < NSVG_PI) da += NSVG_PI*2;
-    if (da > NSVG_PI) da -= NSVG_PI*2;
-
-    n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * ncap);
-    if (n < 2) n = 2;
-    if (n > ncap) n = ncap;
-
-    lx = left->x;
-    ly = left->y;
-    rx = right->x;
-    ry = right->y;
-
-    for (i = 0; i < n; i++) {
-        float u = i/(float)(n-1);
-        float a = a0 + u*da;
-        float ax = cosf(a) * w, ay = sinf(a) * w;
-        float lx1 = p1->x - ax, ly1 = p1->y - ay;
-        float rx1 = p1->x + ax, ry1 = p1->y + ay;
-
-        nsvg__addEdge(r, lx1, ly1, lx, ly);
-        nsvg__addEdge(r, rx, ry, rx1, ry1);
-
-        lx = lx1; ly = ly1;
-        rx = rx1; ry = ry1;
-    }
-
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       int i, n;
+       float w = lineWidth * 0.5f;
+       float dlx0 = p0->dy, dly0 = -p0->dx;
+       float dlx1 = p1->dy, dly1 = -p1->dx;
+       float a0 = atan2f(dly0, dlx0);
+       float a1 = atan2f(dly1, dlx1);
+       float da = a1 - a0;
+       float lx, ly, rx, ry;
+
+       if (da < NSVG_PI) da += NSVG_PI*2;
+       if (da > NSVG_PI) da -= NSVG_PI*2;
+
+       n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * (float)ncap);
+       if (n < 2) n = 2;
+       if (n > ncap) n = ncap;
+
+       lx = left->x;
+       ly = left->y;
+       rx = right->x;
+       ry = right->y;
+
+       for (i = 0; i < n; i++) {
+               float u = (float)i/(float)(n-1);
+               float a = a0 + u*da;
+               float ax = cosf(a) * w, ay = sinf(a) * w;
+               float lx1 = p1->x - ax, ly1 = p1->y - ay;
+               float rx1 = p1->x + ax, ry1 = p1->y + ay;
+
+               nsvg__addEdge(r, lx1, ly1, lx, ly);
+               nsvg__addEdge(r, rx, ry, rx1, ry1);
+
+               lx = lx1; ly = ly1;
+               rx = rx1; ry = ry1;
+       }
+
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 static void nsvg__straightJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p1, float lineWidth)
 {
-    float w = lineWidth * 0.5f;
-    float lx = p1->x - (p1->dmx * w), ly = p1->y - (p1->dmy * w);
-    float rx = p1->x + (p1->dmx * w), ry = p1->y + (p1->dmy * w);
+       float w = lineWidth * 0.5f;
+       float lx = p1->x - (p1->dmx * w), ly = p1->y - (p1->dmy * w);
+       float rx = p1->x + (p1->dmx * w), ry = p1->y + (p1->dmy * w);
 
-    nsvg__addEdge(r, lx, ly, left->x, left->y);
-    nsvg__addEdge(r, right->x, right->y, rx, ry);
+       nsvg__addEdge(r, lx, ly, left->x, left->y);
+       nsvg__addEdge(r, right->x, right->y, rx, ry);
 
-    left->x = lx; left->y = ly;
-    right->x = rx; right->y = ry;
+       left->x = lx; left->y = ly;
+       right->x = rx; right->y = ry;
 }
 
 static int nsvg__curveDivs(float r, float arc, float tol)
 {
-    float da = acosf(r / (r + tol)) * 2.0f;
-    int divs = (int)ceilf(arc / da);
-    if (divs < 2) divs = 2;
-    return divs;
+       float da = acosf(r / (r + tol)) * 2.0f;
+       int divs = (int)ceilf(arc / da);
+       if (divs < 2) divs = 2;
+       return divs;
 }
 
 static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
 {
-    int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol);    // Calculate divisions per half circle.
-    NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
-    NSVGpoint* p0, *p1;
-    int j, s, e;
-
-    // Build stroke edges
-    if (closed) {
-        // Looping
-        p0 = &points[npoints-1];
-        p1 = &points[0];
-        s = 0;
-        e = npoints;
-    } else {
-        // Add cap
-        p0 = &points[0];
-        p1 = &points[1];
-        s = 1;
-        e = npoints-1;
-    }
-
-    if (closed) {
-        nsvg__initClosed(&left, &right, p0, p1, lineWidth);
-        firstLeft = left;
-        firstRight = right;
-    } else {
-        // Add cap
-        float dx = p1->x - p0->x;
-        float dy = p1->y - p0->y;
-        nsvg__normalize(&dx, &dy);
-        if (lineCap == NSVG_CAP_BUTT)
-            nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
-        else if (lineCap == NSVG_CAP_SQUARE)
-            nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
-        else if (lineCap == NSVG_CAP_ROUND)
-            nsvg__roundCap(r, &left, &right, p0, dx, dy, lineWidth, ncap, 0);
-    }
-
-    for (j = s; j < e; ++j) {
-        if (p1->flags & NSVG_PT_CORNER) {
-            if (lineJoin == NSVG_JOIN_ROUND)
-                nsvg__roundJoin(r, &left, &right, p0, p1, lineWidth, ncap);
-            else if (lineJoin == NSVG_JOIN_BEVEL || (p1->flags & NSVG_PT_BEVEL))
-                nsvg__bevelJoin(r, &left, &right, p0, p1, lineWidth);
-            else
-                nsvg__miterJoin(r, &left, &right, p0, p1, lineWidth);
-        } else {
-            nsvg__straightJoin(r, &left, &right, p1, lineWidth);
-        }
-        p0 = p1++;
-    }
-
-    if (closed) {
-        // Loop it
-        nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
-        nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
-    } else {
-        // Add cap
-        float dx = p1->x - p0->x;
-        float dy = p1->y - p0->y;
-        nsvg__normalize(&dx, &dy);
-        if (lineCap == NSVG_CAP_BUTT)
-            nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
-        else if (lineCap == NSVG_CAP_SQUARE)
-            nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
-        else if (lineCap == NSVG_CAP_ROUND)
-            nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1);
-    }
+       int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol);        // Calculate divisions per half circle.
+       NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
+       NSVGpoint* p0, *p1;
+       int j, s, e;
+
+       // Build stroke edges
+       if (closed) {
+               // Looping
+               p0 = &points[npoints-1];
+               p1 = &points[0];
+               s = 0;
+               e = npoints;
+       } else {
+               // Add cap
+               p0 = &points[0];
+               p1 = &points[1];
+               s = 1;
+               e = npoints-1;
+       }
+
+       if (closed) {
+               nsvg__initClosed(&left, &right, p0, p1, lineWidth);
+               firstLeft = left;
+               firstRight = right;
+       } else {
+               // Add cap
+               float dx = p1->x - p0->x;
+               float dy = p1->y - p0->y;
+               nsvg__normalize(&dx, &dy);
+               if (lineCap == NSVG_CAP_BUTT)
+                       nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+               else if (lineCap == NSVG_CAP_SQUARE)
+                       nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+               else if (lineCap == NSVG_CAP_ROUND)
+                       nsvg__roundCap(r, &left, &right, p0, dx, dy, lineWidth, ncap, 0);
+       }
+
+       for (j = s; j < e; ++j) {
+               if (p1->flags & NSVG_PT_CORNER) {
+                       if (lineJoin == NSVG_JOIN_ROUND)
+                               nsvg__roundJoin(r, &left, &right, p0, p1, lineWidth, ncap);
+                       else if (lineJoin == NSVG_JOIN_BEVEL || (p1->flags & NSVG_PT_BEVEL))
+                               nsvg__bevelJoin(r, &left, &right, p0, p1, lineWidth);
+                       else
+                               nsvg__miterJoin(r, &left, &right, p0, p1, lineWidth);
+               } else {
+                       nsvg__straightJoin(r, &left, &right, p1, lineWidth);
+               }
+               p0 = p1++;
+       }
+
+       if (closed) {
+               // Loop it
+               nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
+               nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
+       } else {
+               // Add cap
+               float dx = p1->x - p0->x;
+               float dy = p1->y - p0->y;
+               nsvg__normalize(&dx, &dy);
+               if (lineCap == NSVG_CAP_BUTT)
+                       nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+               else if (lineCap == NSVG_CAP_SQUARE)
+                       nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+               else if (lineCap == NSVG_CAP_ROUND)
+                       nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1);
+       }
 }
 
 static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin)
 {
-    int i, j;
-    NSVGpoint* p0, *p1;
-
-    p0 = &r->points[r->npoints-1];
-    p1 = &r->points[0];
-    for (i = 0; i < r->npoints; i++) {
-        // Calculate segment direction and length
-        p0->dx = p1->x - p0->x;
-        p0->dy = p1->y - p0->y;
-        p0->len = nsvg__normalize(&p0->dx, &p0->dy);
-        // Advance
-        p0 = p1++;
-    }
-
-    // calculate joins
-    p0 = &r->points[r->npoints-1];
-    p1 = &r->points[0];
-    for (j = 0; j < r->npoints; j++) {
-        float dlx0, dly0, dlx1, dly1, dmr2, cross;
-        dlx0 = p0->dy;
-        dly0 = -p0->dx;
-        dlx1 = p1->dy;
-        dly1 = -p1->dx;
-        // Calculate extrusions
-        p1->dmx = (dlx0 + dlx1) * 0.5f;
-        p1->dmy = (dly0 + dly1) * 0.5f;
-        dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
-        if (dmr2 > 0.000001f) {
-            float s2 = 1.0f / dmr2;
-            if (s2 > 600.0f) {
-                s2 = 600.0f;
-            }
-            p1->dmx *= s2;
-            p1->dmy *= s2;
-        }
-
-        // Clear flags, but keep the corner.
-        p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
-
-        // Keep track of left turns.
-        cross = p1->dx * p0->dy - p0->dx * p1->dy;
-        if (cross > 0.0f)
-            p1->flags |= NSVG_PT_LEFT;
-
-        // Check to see if the corner needs to be beveled.
-        if (p1->flags & NSVG_PT_CORNER) {
-            if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
-                p1->flags |= NSVG_PT_BEVEL;
-            }
-        }
-
-        p0 = p1++;
-    }
+       int i, j;
+       NSVGpoint* p0, *p1;
+
+       p0 = &r->points[r->npoints-1];
+       p1 = &r->points[0];
+       for (i = 0; i < r->npoints; i++) {
+               // Calculate segment direction and length
+               p0->dx = p1->x - p0->x;
+               p0->dy = p1->y - p0->y;
+               p0->len = nsvg__normalize(&p0->dx, &p0->dy);
+               // Advance
+               p0 = p1++;
+       }
+
+       // calculate joins
+       p0 = &r->points[r->npoints-1];
+       p1 = &r->points[0];
+       for (j = 0; j < r->npoints; j++) {
+               float dlx0, dly0, dlx1, dly1, dmr2, cross;
+               dlx0 = p0->dy;
+               dly0 = -p0->dx;
+               dlx1 = p1->dy;
+               dly1 = -p1->dx;
+               // Calculate extrusions
+               p1->dmx = (dlx0 + dlx1) * 0.5f;
+               p1->dmy = (dly0 + dly1) * 0.5f;
+               dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
+               if (dmr2 > 0.000001f) {
+                       float s2 = 1.0f / dmr2;
+                       if (s2 > 600.0f) {
+                               s2 = 600.0f;
+                       }
+                       p1->dmx *= s2;
+                       p1->dmy *= s2;
+               }
+
+               // Clear flags, but keep the corner.
+               p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
+
+               // Keep track of left turns.
+               cross = p1->dx * p0->dy - p0->dx * p1->dy;
+               if (cross > 0.0f)
+                       p1->flags |= NSVG_PT_LEFT;
+
+               // Check to see if the corner needs to be beveled.
+               if (p1->flags & NSVG_PT_CORNER) {
+                       if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
+                               p1->flags |= NSVG_PT_BEVEL;
+                       }
+               }
+
+               p0 = p1++;
+       }
 }
 
 static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
 {
-    int i, j, closed;
-    NSVGpath* path;
-    NSVGpoint* p0, *p1;
-    float miterLimit = 4;
-    int lineJoin = shape->strokeLineJoin;
-    int lineCap = shape->strokeLineCap;
-    float lineWidth = shape->strokeWidth * scale;
-
-    for (path = shape->paths; path != NULL; path = path->next) {
-        // Flatten path
-        r->npoints = 0;
-        nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
-        for (i = 0; i < path->npts-1; i += 3) {
-            float* p = &path->pts[i*2];
-            nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
-        }
-        if (r->npoints < 2)
-            continue;
-
-        closed = path->closed;
-
-        // If the first and last points are the same, remove the last, mark as closed path.
-        p0 = &r->points[r->npoints-1];
-        p1 = &r->points[0];
-        if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
-            r->npoints--;
-            p0 = &r->points[r->npoints-1];
-            closed = 1;
-        }
-
-        if (shape->strokeDashCount > 0) {
-            int idash = 0, dashState = 1;
-            float totalDist = 0, dashLen, allDashLen, dashOffset;
-            NSVGpoint cur;
-
-            if (closed)
-                nsvg__appendPathPoint(r, r->points[0]);
-
-            // Duplicate points -> points2.
-            nsvg__duplicatePoints(r);
-
-            r->npoints = 0;
-            cur = r->points2[0];
-            nsvg__appendPathPoint(r, cur);
-
-            // Figure out dash offset.
-            allDashLen = 0;
-            for (j = 0; j < shape->strokeDashCount; j++)
-                allDashLen += shape->strokeDashArray[j];
-            if (shape->strokeDashCount & 1)
-                allDashLen *= 2.0f;
-            // Find location inside pattern
-            dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
-            if (dashOffset < 0.0f)
-                dashOffset += allDashLen;
-
-            while (dashOffset > shape->strokeDashArray[idash]) {
-                dashOffset -= shape->strokeDashArray[idash];
-                idash = (idash + 1) % shape->strokeDashCount;
-            }
-            dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
-
-            for (j = 1; j < r->npoints2; ) {
-                float dx = r->points2[j].x - cur.x;
-                float dy = r->points2[j].y - cur.y;
-                float dist = sqrtf(dx*dx + dy*dy);
-
-                if ((totalDist + dist) > dashLen) {
-                    // Calculate intermediate point
-                    float d = (dashLen - totalDist) / dist;
-                    float x = cur.x + dx * d;
-                    float y = cur.y + dy * d;
-                    nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
-
-                    // Stroke
-                    if (r->npoints > 1 && dashState) {
-                        nsvg__prepareStroke(r, miterLimit, lineJoin);
-                        nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
-                    }
-                    // Advance dash pattern
-                    dashState = !dashState;
-                    idash = (idash+1) % shape->strokeDashCount;
-                    dashLen = shape->strokeDashArray[idash] * scale;
-                    // Restart
-                    cur.x = x;
-                    cur.y = y;
-                    cur.flags = NSVG_PT_CORNER;
-                    totalDist = 0.0f;
-                    r->npoints = 0;
-                    nsvg__appendPathPoint(r, cur);
-                } else {
-                    totalDist += dist;
-                    cur = r->points2[j];
-                    nsvg__appendPathPoint(r, cur);
-                    j++;
-                }
-            }
-            // Stroke any leftover path
-            if (r->npoints > 1 && dashState)
-                nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
-        } else {
-            nsvg__prepareStroke(r, miterLimit, lineJoin);
-            nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
-        }
-    }
+       int i, j, closed;
+       NSVGpath* path;
+       NSVGpoint* p0, *p1;
+       float miterLimit = shape->miterLimit;
+       int lineJoin = shape->strokeLineJoin;
+       int lineCap = shape->strokeLineCap;
+       float lineWidth = shape->strokeWidth * scale;
+
+       for (path = shape->paths; path != NULL; path = path->next) {
+               // Flatten path
+               r->npoints = 0;
+               nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
+               for (i = 0; i < path->npts-1; i += 3) {
+                       float* p = &path->pts[i*2];
+                       nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
+               }
+               if (r->npoints < 2)
+                       continue;
+
+               closed = path->closed;
+
+               // If the first and last points are the same, remove the last, mark as closed path.
+               p0 = &r->points[r->npoints-1];
+               p1 = &r->points[0];
+               if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
+                       r->npoints--;
+                       p0 = &r->points[r->npoints-1];
+                       closed = 1;
+               }
+
+               if (shape->strokeDashCount > 0) {
+                       int idash = 0, dashState = 1;
+                       float totalDist = 0, dashLen, allDashLen, dashOffset;
+                       NSVGpoint cur;
+
+                       if (closed)
+                               nsvg__appendPathPoint(r, r->points[0]);
+
+                       // Duplicate points -> points2.
+                       nsvg__duplicatePoints(r);
+
+                       r->npoints = 0;
+                       cur = r->points2[0];
+                       nsvg__appendPathPoint(r, cur);
+
+                       // Figure out dash offset.
+                       allDashLen = 0;
+                       for (j = 0; j < shape->strokeDashCount; j++)
+                               allDashLen += shape->strokeDashArray[j];
+                       if (shape->strokeDashCount & 1)
+                               allDashLen *= 2.0f;
+                       // Find location inside pattern
+                       dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
+                       if (dashOffset < 0.0f)
+                               dashOffset += allDashLen;
+
+                       while (dashOffset > shape->strokeDashArray[idash]) {
+                               dashOffset -= shape->strokeDashArray[idash];
+                               idash = (idash + 1) % shape->strokeDashCount;
+                       }
+                       dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
+
+                       for (j = 1; j < r->npoints2; ) {
+                               float dx = r->points2[j].x - cur.x;
+                               float dy = r->points2[j].y - cur.y;
+                               float dist = sqrtf(dx*dx + dy*dy);
+
+                               if ((totalDist + dist) > dashLen) {
+                                       // Calculate intermediate point
+                                       float d = (dashLen - totalDist) / dist;
+                                       float x = cur.x + dx * d;
+                                       float y = cur.y + dy * d;
+                                       nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
+
+                                       // Stroke
+                                       if (r->npoints > 1 && dashState) {
+                                               nsvg__prepareStroke(r, miterLimit, lineJoin);
+                                               nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+                                       }
+                                       // Advance dash pattern
+                                       dashState = !dashState;
+                                       idash = (idash+1) % shape->strokeDashCount;
+                                       dashLen = shape->strokeDashArray[idash] * scale;
+                                       // Restart
+                                       cur.x = x;
+                                       cur.y = y;
+                                       cur.flags = NSVG_PT_CORNER;
+                                       totalDist = 0.0f;
+                                       r->npoints = 0;
+                                       nsvg__appendPathPoint(r, cur);
+                               } else {
+                                       totalDist += dist;
+                                       cur = r->points2[j];
+                                       nsvg__appendPathPoint(r, cur);
+                                       j++;
+                               }
+                       }
+                       // Stroke any leftover path
+                       if (r->npoints > 1 && dashState)
+                               nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+               } else {
+                       nsvg__prepareStroke(r, miterLimit, lineJoin);
+                       nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
+               }
+       }
 }
 
 static int nsvg__cmpEdge(const void *p, const void *q)
 {
-    NSVGedge* a = (NSVGedge*)p;
-    NSVGedge* b = (NSVGedge*)q;
+       const NSVGedge* a = (const NSVGedge*)p;
+       const NSVGedge* b = (const NSVGedge*)q;
 
-    if (a->y0 < b->y0) return -1;
-    if (a->y0 > b->y0) return  1;
-    return 0;
+       if (a->y0 < b->y0) return -1;
+       if (a->y0 > b->y0) return  1;
+       return 0;
 }
 
 
 static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint)
 {
-     NSVGactiveEdge* z;
-
-    if (r->freelist != NULL) {
-        // Restore from freelist.
-        z = r->freelist;
-        r->freelist = z->next;
-    } else {
-        // Alloc new edge.
-        z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
-        if (z == NULL) return NULL;
-    }
-
-    float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-//  STBTT_assert(e->y0 <= start_point);
-    // round dx down to avoid going too far
-    if (dxdy < 0)
-        z->dx = (int)(-floorf(NSVG__FIX * -dxdy));
-    else
-        z->dx = (int)floorf(NSVG__FIX * dxdy);
-    z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
-//  z->x -= off_x * FIX;
-    z->ey = e->y1;
-    z->next = 0;
-    z->dir = e->dir;
-
-    return z;
+        NSVGactiveEdge* z;
+
+       if (r->freelist != NULL) {
+               // Restore from freelist.
+               z = r->freelist;
+               r->freelist = z->next;
+       } else {
+               // Alloc new edge.
+               z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
+               if (z == NULL) return NULL;
+       }
+
+       float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+//     STBTT_assert(e->y0 <= start_point);
+       // round dx down to avoid going too far
+       if (dxdy < 0)
+               z->dx = (int)(-floorf(NSVG__FIX * -dxdy));
+       else
+               z->dx = (int)floorf(NSVG__FIX * dxdy);
+       z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
+//     z->x -= off_x * FIX;
+       z->ey = e->y1;
+       z->next = 0;
+       z->dir = e->dir;
+
+       return z;
 }
 
 static void nsvg__freeActive(NSVGrasterizer* r, NSVGactiveEdge* z)
 {
-    z->next = r->freelist;
-    r->freelist = z;
+       z->next = r->freelist;
+       r->freelist = z;
 }
 
 static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1, int maxWeight, int* xmin, int* xmax)
 {
-    int i = x0 >> NSVG__FIXSHIFT;
-    int j = x1 >> NSVG__FIXSHIFT;
-    if (i < *xmin) *xmin = i;
-    if (j > *xmax) *xmax = j;
-    if (i < len && j >= 0) {
-        if (i == j) {
-            // x0,x1 are the same pixel, so compute combined coverage
-            scanline[i] += (unsigned char)((x1 - x0) * maxWeight >> NSVG__FIXSHIFT);
-        } else {
-            if (i >= 0) // add antialiasing for x0
-                scanline[i] += (unsigned char)(((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT);
-            else
-                i = -1; // clip
-
-            if (j < len) // add antialiasing for x1
-                scanline[j] += (unsigned char)(((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT);
-            else
-                j = len; // clip
-
-            for (++i; i < j; ++i) // fill pixels between x0 and x1
-                scanline[i] += (unsigned char)maxWeight;
-        }
-    }
+       int i = x0 >> NSVG__FIXSHIFT;
+       int j = x1 >> NSVG__FIXSHIFT;
+       if (i < *xmin) *xmin = i;
+       if (j > *xmax) *xmax = j;
+       if (i < len && j >= 0) {
+               if (i == j) {
+                       // x0,x1 are the same pixel, so compute combined coverage
+                       scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
+               } else {
+                       if (i >= 0) // add antialiasing for x0
+                               scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
+                       else
+                               i = -1; // clip
+
+                       if (j < len) // add antialiasing for x1
+                               scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
+                       else
+                               j = len; // clip
+
+                       for (++i; i < j; ++i) // fill pixels between x0 and x1
+                               scanline[i] = (unsigned char)(scanline[i] + maxWeight);
+               }
+       }
 }
 
 // note: this routine clips fills that extend off the edges... ideally this
 // wouldn't happen, but it could happen if the truetype glyph bounding boxes
 // are wrong, or if the user supplies a too-small bitmap
 
- /**
 * In the original file, using char type (without signed or unsigned) can be interpreted
 * as 'unsigned char' in some build environments, like ARM architecture.
 * To prevent the unexpected behavior, we replace 'char fillRule' with 'signed char fillRule' here.
 */
+/**
+ * In the original file, using char type (without signed or unsigned) can be interpreted
+ * as 'unsigned char' in some build environments, like ARM architecture.
+ * To prevent the unexpected behavior, we replace 'char fillRule' with 'signed char fillRule' here.
+ */
 static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, signed char fillRule)
 {
-    // non-zero winding fill
-    int x0 = 0, w = 0;
-
-    if (fillRule == NSVG_FILLRULE_NONZERO) {
-        // Non-zero
-        while (e != NULL) {
-            if (w == 0) {
-                // if we're currently at zero, we need to record the edge start point
-                x0 = e->x; w += e->dir;
-            } else {
-                int x1 = e->x; w += e->dir;
-                // if we went to zero, we need to draw
-                if (w == 0)
-                    nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
-            }
-            e = e->next;
-        }
-    } else if (fillRule == NSVG_FILLRULE_EVENODD) {
-        // Even-odd
-        while (e != NULL) {
-            if (w == 0) {
-                // if we're currently at zero, we need to record the edge start point
-                x0 = e->x; w = 1;
-            } else {
-                int x1 = e->x; w = 0;
-                nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
-            }
-            e = e->next;
-        }
-    }
+       // non-zero winding fill
+       int x0 = 0, w = 0;
+
+       if (fillRule == NSVG_FILLRULE_NONZERO) {
+               // Non-zero
+               while (e != NULL) {
+                       if (w == 0) {
+                               // if we're currently at zero, we need to record the edge start point
+                               x0 = e->x; w += e->dir;
+                       } else {
+                               int x1 = e->x; w += e->dir;
+                               // if we went to zero, we need to draw
+                               if (w == 0)
+                                       nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+                       }
+                       e = e->next;
+               }
+       } else if (fillRule == NSVG_FILLRULE_EVENODD) {
+               // Even-odd
+               while (e != NULL) {
+                       if (w == 0) {
+                               // if we're currently at zero, we need to record the edge start point
+                               x0 = e->x; w = 1;
+                       } else {
+                               int x1 = e->x; w = 0;
+                               nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+                       }
+                       e = e->next;
+               }
+       }
 }
 
 static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
 
 static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 {
-    return (r) | (g << 8) | (b << 16) | (a << 24);
+       return (r) | (g << 8) | (b << 16) | (a << 24);
 }
 
 static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
 {
-    int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
-    int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8;
-    int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8;
-    int b = (((c0>>16) & 0xff)*(256-iu) + (((c1>>16) & 0xff)*iu)) >> 8;
-    int a = (((c0>>24) & 0xff)*(256-iu) + (((c1>>24) & 0xff)*iu)) >> 8;
-    return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+       int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+       int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8;
+       int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8;
+       int b = (((c0>>16) & 0xff)*(256-iu) + (((c1>>16) & 0xff)*iu)) >> 8;
+       int a = (((c0>>24) & 0xff)*(256-iu) + (((c1>>24) & 0xff)*iu)) >> 8;
+       return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
 }
 
 static unsigned int nsvg__applyOpacity(unsigned int c, float u)
 {
-    int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
-    int r = (c) & 0xff;
-    int g = (c>>8) & 0xff;
-    int b = (c>>16) & 0xff;
-    int a = (((c>>24) & 0xff)*iu) >> 8;
-    return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+       int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+       int r = (c) & 0xff;
+       int g = (c>>8) & 0xff;
+       int b = (c>>16) & 0xff;
+       int a = (((c>>24) & 0xff)*iu) >> 8;
+       return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
 }
 
 static inline int nsvg__div255(int x)
@@ -951,218 +952,218 @@ static inline int nsvg__div255(int x)
 }
 
 static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* cover, int x, int y,
-                                float tx, float ty, float scale, NSVGcachedPaint* cache)
+                                                               float tx, float ty, float scale, NSVGcachedPaint* cache)
 {
 
-    if (cache->type == NSVG_PAINT_COLOR) {
-        int i, cr, cg, cb, ca;
-        cr = cache->colors[0] & 0xff;
-        cg = (cache->colors[0] >> 8) & 0xff;
-        cb = (cache->colors[0] >> 16) & 0xff;
-        ca = (cache->colors[0] >> 24) & 0xff;
-
-        for (i = 0; i < count; i++) {
-            int r,g,b;
-            int a = nsvg__div255((int)cover[0] * ca);
-            int ia = 255 - a;
-            // Premultiply
-            r = nsvg__div255(cr * a);
-            g = nsvg__div255(cg * a);
-            b = nsvg__div255(cb * a);
-
-            // Blend over
-            r += nsvg__div255(ia * (int)dst[0]);
-            g += nsvg__div255(ia * (int)dst[1]);
-            b += nsvg__div255(ia * (int)dst[2]);
-            a += nsvg__div255(ia * (int)dst[3]);
-
-            dst[0] = (unsigned char)r;
-            dst[1] = (unsigned char)g;
-            dst[2] = (unsigned char)b;
-            dst[3] = (unsigned char)a;
-
-            cover++;
-            dst += 4;
-        }
-    } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
-        // TODO: spread modes.
-        // TODO: plenty of opportunities to optimize.
-        float fx, fy, dx, gy;
-        float* t = cache->xform;
-        int i, cr, cg, cb, ca;
-        unsigned int c;
-
-        fx = (x - tx) / scale;
-        fy = (y - ty) / scale;
-        dx = 1.0f / scale;
-
-        for (i = 0; i < count; i++) {
-            int r,g,b,a,ia;
-            gy = fx*t[1] + fy*t[3] + t[5];
-            c = cache->colors[(int)nsvg__clampf(gy*255.0f, 0, 255.0f)];
-            cr = (c) & 0xff;
-            cg = (c >> 8) & 0xff;
-            cb = (c >> 16) & 0xff;
-            ca = (c >> 24) & 0xff;
-
-            a = nsvg__div255((int)cover[0] * ca);
-            ia = 255 - a;
-
-            // Premultiply
-            r = nsvg__div255(cr * a);
-            g = nsvg__div255(cg * a);
-            b = nsvg__div255(cb * a);
-
-            // Blend over
-            r += nsvg__div255(ia * (int)dst[0]);
-            g += nsvg__div255(ia * (int)dst[1]);
-            b += nsvg__div255(ia * (int)dst[2]);
-            a += nsvg__div255(ia * (int)dst[3]);
-
-            dst[0] = (unsigned char)r;
-            dst[1] = (unsigned char)g;
-            dst[2] = (unsigned char)b;
-            dst[3] = (unsigned char)a;
-
-            cover++;
-            dst += 4;
-            fx += dx;
-        }
-    } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
-        // TODO: spread modes.
-        // TODO: plenty of opportunities to optimize.
-        // TODO: focus (fx,fy)
-        float fx, fy, dx, gx, gy, gd;
-        float* t = cache->xform;
-        int i, cr, cg, cb, ca;
-        unsigned int c;
-
-        fx = (x - tx) / scale;
-        fy = (y - ty) / scale;
-        dx = 1.0f / scale;
-
-        for (i = 0; i < count; i++) {
-            int r,g,b,a,ia;
-            gx = fx*t[0] + fy*t[2] + t[4];
-            gy = fx*t[1] + fy*t[3] + t[5];
-            gd = sqrtf(gx*gx + gy*gy);
-            c = cache->colors[(int)nsvg__clampf(gd*255.0f, 0, 255.0f)];
-            cr = (c) & 0xff;
-            cg = (c >> 8) & 0xff;
-            cb = (c >> 16) & 0xff;
-            ca = (c >> 24) & 0xff;
-
-            a = nsvg__div255((int)cover[0] * ca);
-            ia = 255 - a;
-
-            // Premultiply
-            r = nsvg__div255(cr * a);
-            g = nsvg__div255(cg * a);
-            b = nsvg__div255(cb * a);
-
-            // Blend over
-            r += nsvg__div255(ia * (int)dst[0]);
-            g += nsvg__div255(ia * (int)dst[1]);
-            b += nsvg__div255(ia * (int)dst[2]);
-            a += nsvg__div255(ia * (int)dst[3]);
-
-            dst[0] = (unsigned char)r;
-            dst[1] = (unsigned char)g;
-            dst[2] = (unsigned char)b;
-            dst[3] = (unsigned char)a;
-
-            cover++;
-            dst += 4;
-            fx += dx;
-        }
-    }
+       if (cache->type == NSVG_PAINT_COLOR) {
+               int i, cr, cg, cb, ca;
+               cr = cache->colors[0] & 0xff;
+               cg = (cache->colors[0] >> 8) & 0xff;
+               cb = (cache->colors[0] >> 16) & 0xff;
+               ca = (cache->colors[0] >> 24) & 0xff;
+
+               for (i = 0; i < count; i++) {
+                       int r,g,b;
+                       int a = nsvg__div255((int)cover[0] * ca);
+                       int ia = 255 - a;
+                       // Premultiply
+                       r = nsvg__div255(cr * a);
+                       g = nsvg__div255(cg * a);
+                       b = nsvg__div255(cb * a);
+
+                       // Blend over
+                       r += nsvg__div255(ia * (int)dst[0]);
+                       g += nsvg__div255(ia * (int)dst[1]);
+                       b += nsvg__div255(ia * (int)dst[2]);
+                       a += nsvg__div255(ia * (int)dst[3]);
+
+                       dst[0] = (unsigned char)r;
+                       dst[1] = (unsigned char)g;
+                       dst[2] = (unsigned char)b;
+                       dst[3] = (unsigned char)a;
+
+                       cover++;
+                       dst += 4;
+               }
+       } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
+               // TODO: spread modes.
+               // TODO: plenty of opportunities to optimize.
+               float fx, fy, dx, gy;
+               float* t = cache->xform;
+               int i, cr, cg, cb, ca;
+               unsigned int c;
+
+               fx = ((float)x - tx) / scale;
+               fy = ((float)y - ty) / scale;
+               dx = 1.0f / scale;
+
+               for (i = 0; i < count; i++) {
+                       int r,g,b,a,ia;
+                       gy = fx*t[1] + fy*t[3] + t[5];
+                       c = cache->colors[(int)nsvg__clampf(gy*255.0f, 0, 255.0f)];
+                       cr = (c) & 0xff;
+                       cg = (c >> 8) & 0xff;
+                       cb = (c >> 16) & 0xff;
+                       ca = (c >> 24) & 0xff;
+
+                       a = nsvg__div255((int)cover[0] * ca);
+                       ia = 255 - a;
+
+                       // Premultiply
+                       r = nsvg__div255(cr * a);
+                       g = nsvg__div255(cg * a);
+                       b = nsvg__div255(cb * a);
+
+                       // Blend over
+                       r += nsvg__div255(ia * (int)dst[0]);
+                       g += nsvg__div255(ia * (int)dst[1]);
+                       b += nsvg__div255(ia * (int)dst[2]);
+                       a += nsvg__div255(ia * (int)dst[3]);
+
+                       dst[0] = (unsigned char)r;
+                       dst[1] = (unsigned char)g;
+                       dst[2] = (unsigned char)b;
+                       dst[3] = (unsigned char)a;
+
+                       cover++;
+                       dst += 4;
+                       fx += dx;
+               }
+       } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
+               // TODO: spread modes.
+               // TODO: plenty of opportunities to optimize.
+               // TODO: focus (fx,fy)
+               float fx, fy, dx, gx, gy, gd;
+               float* t = cache->xform;
+               int i, cr, cg, cb, ca;
+               unsigned int c;
+
+               fx = ((float)x - tx) / scale;
+               fy = ((float)y - ty) / scale;
+               dx = 1.0f / scale;
+
+               for (i = 0; i < count; i++) {
+                       int r,g,b,a,ia;
+                       gx = fx*t[0] + fy*t[2] + t[4];
+                       gy = fx*t[1] + fy*t[3] + t[5];
+                       gd = sqrtf(gx*gx + gy*gy);
+                       c = cache->colors[(int)nsvg__clampf(gd*255.0f, 0, 255.0f)];
+                       cr = (c) & 0xff;
+                       cg = (c >> 8) & 0xff;
+                       cb = (c >> 16) & 0xff;
+                       ca = (c >> 24) & 0xff;
+
+                       a = nsvg__div255((int)cover[0] * ca);
+                       ia = 255 - a;
+
+                       // Premultiply
+                       r = nsvg__div255(cr * a);
+                       g = nsvg__div255(cg * a);
+                       b = nsvg__div255(cb * a);
+
+                       // Blend over
+                       r += nsvg__div255(ia * (int)dst[0]);
+                       g += nsvg__div255(ia * (int)dst[1]);
+                       b += nsvg__div255(ia * (int)dst[2]);
+                       a += nsvg__div255(ia * (int)dst[3]);
+
+                       dst[0] = (unsigned char)r;
+                       dst[1] = (unsigned char)g;
+                       dst[2] = (unsigned char)b;
+                       dst[3] = (unsigned char)a;
+
+                       cover++;
+                       dst += 4;
+                       fx += dx;
+               }
+       }
 }
 
 static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
 {
-    NSVGactiveEdge *active = NULL;
-    int y, s;
-    int e = 0;
-    int maxWeight = (255 / NSVG__SUBSAMPLES);  // weight per vertical scanline
-    int xmin, xmax;
-
-    for (y = 0; y < r->height; y++) {
-        memset(r->scanline, 0, r->width);
-        xmin = r->width;
-        xmax = 0;
-        for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
-            // find center of pixel for this scanline
-            float scany = y*NSVG__SUBSAMPLES + s + 0.5f;
-            NSVGactiveEdge **step = &active;
-
-            // update all active edges;
-            // remove all active edges that terminate before the center of this scanline
-            while (*step) {
-                NSVGactiveEdge *z = *step;
-                if (z->ey <= scany) {
-                    *step = z->next; // delete from list
-//                  NSVG__assert(z->valid);
-                    nsvg__freeActive(r, z);
-                } else {
-                    z->x += z->dx; // advance to position for current scanline
-                    step = &((*step)->next); // advance through list
-                }
-            }
-
-            // resort the list if needed
-            for (;;) {
-                int changed = 0;
-                step = &active;
-                while (*step && (*step)->next) {
-                    if ((*step)->x > (*step)->next->x) {
-                        NSVGactiveEdge* t = *step;
-                        NSVGactiveEdge* q = t->next;
-                        t->next = q->next;
-                        q->next = t;
-                        *step = q;
-                        changed = 1;
-                    }
-                    step = &(*step)->next;
-                }
-                if (!changed) break;
-            }
-
-            // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
-            while (e < r->nedges && r->edges[e].y0 <= scany) {
-                if (r->edges[e].y1 > scany) {
-                    NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
-                    if (z == NULL) break;
-                    // find insertion point
-                    if (active == NULL) {
-                        active = z;
-                    } else if (z->x < active->x) {
-                        // insert at front
-                        z->next = active;
-                        active = z;
-                    } else {
-                        // find thing to insert AFTER
-                        NSVGactiveEdge* p = active;
-                        while (p->next && p->next->x < z->x)
-                            p = p->next;
-                        // at this point, p->next->x is NOT < z->x
-                        z->next = p->next;
-                        p->next = z;
-                    }
-                }
-                e++;
-            }
-
-            // now process all active edges in non-zero fashion
-            if (active != NULL)
-                nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
-        }
-        // Blit
-        if (xmin < 0) xmin = 0;
-        if (xmax > r->width-1) xmax = r->width-1;
-        if (xmin <= xmax) {
-            nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
-        }
-    }
+       NSVGactiveEdge *active = NULL;
+       int y, s;
+       int e = 0;
+       int maxWeight = (255 / NSVG__SUBSAMPLES);  // weight per vertical scanline
+       int xmin, xmax;
+
+       for (y = 0; y < r->height; y++) {
+               memset(r->scanline, 0, r->width);
+               xmin = r->width;
+               xmax = 0;
+               for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
+                       // find center of pixel for this scanline
+                       float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
+                       NSVGactiveEdge **step = &active;
+
+                       // update all active edges;
+                       // remove all active edges that terminate before the center of this scanline
+                       while (*step) {
+                               NSVGactiveEdge *z = *step;
+                               if (z->ey <= scany) {
+                                       *step = z->next; // delete from list
+//                                     NSVG__assert(z->valid);
+                                       nsvg__freeActive(r, z);
+                               } else {
+                                       z->x += z->dx; // advance to position for current scanline
+                                       step = &((*step)->next); // advance through list
+                               }
+                       }
+
+                       // resort the list if needed
+                       for (;;) {
+                               int changed = 0;
+                               step = &active;
+                               while (*step && (*step)->next) {
+                                       if ((*step)->x > (*step)->next->x) {
+                                               NSVGactiveEdge* t = *step;
+                                               NSVGactiveEdge* q = t->next;
+                                               t->next = q->next;
+                                               q->next = t;
+                                               *step = q;
+                                               changed = 1;
+                                       }
+                                       step = &(*step)->next;
+                               }
+                               if (!changed) break;
+                       }
+
+                       // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
+                       while (e < r->nedges && r->edges[e].y0 <= scany) {
+                               if (r->edges[e].y1 > scany) {
+                                       NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
+                                       if (z == NULL) break;
+                                       // find insertion point
+                                       if (active == NULL) {
+                                               active = z;
+                                       } else if (z->x < active->x) {
+                                               // insert at front
+                                               z->next = active;
+                                               active = z;
+                                       } else {
+                                               // find thing to insert AFTER
+                                               NSVGactiveEdge* p = active;
+                                               while (p->next && p->next->x < z->x)
+                                                       p = p->next;
+                                               // at this point, p->next->x is NOT < z->x
+                                               z->next = p->next;
+                                               p->next = z;
+                                       }
+                               }
+                               e++;
+                       }
+
+                       // now process all active edges in non-zero fashion
+                       if (active != NULL)
+                               nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
+               }
+               // Blit
+               if (xmin < 0) xmin = 0;
+               if (xmax > r->width-1) xmax = r->width-1;
+               if (xmin <= xmax) {
+                       nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
+               }
+       }
 
 }
 
@@ -1174,150 +1175,150 @@ static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, fl
 
 static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opacity)
 {
-    int i, j;
-    NSVGgradient* grad;
-
-    cache->type = paint->type;
-
-    if (paint->type == NSVG_PAINT_COLOR) {
-        cache->colors[0] = nsvg__applyOpacity(paint->color, opacity);
-        return;
-    }
-
-    grad = paint->gradient;
-
-    cache->spread = grad->spread;
-    memcpy(cache->xform, grad->xform, sizeof(float)*6);
-
-    if (grad->nstops == 0) {
-        for (i = 0; i < 256; i++)
-            cache->colors[i] = 0;
-    } if (grad->nstops == 1) {
-        for (i = 0; i < 256; i++)
-            cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
-    } else {
-        unsigned int ca, cb = 0;
-        float ua, ub, du, u;
-        int ia, ib, count;
-
-        ca = nsvg__applyOpacity(grad->stops[0].color, opacity);
-        ua = nsvg__clampf(grad->stops[0].offset, 0, 1);
-        ub = nsvg__clampf(grad->stops[grad->nstops-1].offset, ua, 1);
-        ia = (int)(ua * 255.0f);
-        ib = (int)(ub * 255.0f);
-        for (i = 0; i < ia; i++) {
-            cache->colors[i] = ca;
-        }
-
-        for (i = 0; i < grad->nstops-1; i++) {
-            ca = nsvg__applyOpacity(grad->stops[i].color, opacity);
-            cb = nsvg__applyOpacity(grad->stops[i+1].color, opacity);
-            ua = nsvg__clampf(grad->stops[i].offset, 0, 1);
-            ub = nsvg__clampf(grad->stops[i+1].offset, 0, 1);
-            ia = (int)(ua * 255.0f);
-            ib = (int)(ub * 255.0f);
-            count = ib - ia;
-            if (count <= 0) continue;
-            u = 0;
-            du = 1.0f / (float)count;
-            for (j = 0; j < count; j++) {
-                cache->colors[ia+j] = nsvg__lerpRGBA(ca,cb,u);
-                u += du;
-            }
-        }
-
-        for (i = ib; i < 256; i++)
-            cache->colors[i] = cb;
-    }
+       int i, j;
+       NSVGgradient* grad;
+
+       cache->type = paint->type;
+
+       if (paint->type == NSVG_PAINT_COLOR) {
+               cache->colors[0] = nsvg__applyOpacity(paint->color, opacity);
+               return;
+       }
+
+       grad = paint->gradient;
+
+       cache->spread = grad->spread;
+       memcpy(cache->xform, grad->xform, sizeof(float)*6);
+
+       if (grad->nstops == 0) {
+               for (i = 0; i < 256; i++)
+                       cache->colors[i] = 0;
+       } if (grad->nstops == 1) {
+               for (i = 0; i < 256; i++)
+                       cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
+       } else {
+               unsigned int ca, cb = 0;
+               float ua, ub, du, u;
+               int ia, ib, count;
+
+               ca = nsvg__applyOpacity(grad->stops[0].color, opacity);
+               ua = nsvg__clampf(grad->stops[0].offset, 0, 1);
+               ub = nsvg__clampf(grad->stops[grad->nstops-1].offset, ua, 1);
+               ia = (int)(ua * 255.0f);
+               ib = (int)(ub * 255.0f);
+               for (i = 0; i < ia; i++) {
+                       cache->colors[i] = ca;
+               }
+
+               for (i = 0; i < grad->nstops-1; i++) {
+                       ca = nsvg__applyOpacity(grad->stops[i].color, opacity);
+                       cb = nsvg__applyOpacity(grad->stops[i+1].color, opacity);
+                       ua = nsvg__clampf(grad->stops[i].offset, 0, 1);
+                       ub = nsvg__clampf(grad->stops[i+1].offset, 0, 1);
+                       ia = (int)(ua * 255.0f);
+                       ib = (int)(ub * 255.0f);
+                       count = ib - ia;
+                       if (count <= 0) continue;
+                       u = 0;
+                       du = 1.0f / (float)count;
+                       for (j = 0; j < count; j++) {
+                               cache->colors[ia+j] = nsvg__lerpRGBA(ca,cb,u);
+                               u += du;
+                       }
+               }
+
+               for (i = ib; i < 256; i++)
+                       cache->colors[i] = cb;
+       }
 
 }
 
 void nsvgRasterize(NSVGrasterizer* r,
-                   NSVGimage* image, float tx, float ty, float scale,
-                   unsigned char* dst, int w, int h, int stride)
+                                  NSVGimage* image, float tx, float ty, float scale,
+                                  unsigned char* dst, int w, int h, int stride)
 {
-    NSVGshape *shape = NULL;
-    NSVGedge *e = NULL;
-    NSVGcachedPaint cache;
-    int i;
-
-    r->bitmap = dst;
-    r->width = w;
-    r->height = h;
-    r->stride = stride;
-
-    if (w > r->cscanline) {
-        r->cscanline = w;
-        r->scanline = (unsigned char*)realloc(r->scanline, w);
-        if (r->scanline == NULL) return;
-    }
-
-    for (i = 0; i < h; i++)
-        memset(&dst[i*stride], 0, w*4);
-
-    for (shape = image->shapes; shape != NULL; shape = shape->next) {
-        if (!(shape->flags & NSVG_FLAGS_VISIBLE))
-            continue;
-
-        if (shape->fill.type != NSVG_PAINT_NONE) {
-            nsvg__resetPool(r);
-            r->freelist = NULL;
-            r->nedges = 0;
-
-            nsvg__flattenShape(r, shape, scale);
-
-            // Scale and translate edges
-            for (i = 0; i < r->nedges; i++) {
-                e = &r->edges[i];
-                e->x0 = tx + e->x0;
-                e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
-                e->x1 = tx + e->x1;
-                e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
-            }
-
-            // Rasterize edges
-            qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
-
-            // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
-            nsvg__initPaint(&cache, &shape->fill, shape->opacity);
-
-            nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
-        }
-        if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
-            nsvg__resetPool(r);
-            r->freelist = NULL;
-            r->nedges = 0;
-
-            nsvg__flattenShapeStroke(r, shape, scale);
-
-//          dumpEdges(r, "edge.svg");
-
-            // Scale and translate edges
-            for (i = 0; i < r->nedges; i++) {
-                e = &r->edges[i];
-                e->x0 = tx + e->x0;
-                e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
-                e->x1 = tx + e->x1;
-                e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
-            }
-
-            // Rasterize edges
-            qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
-
-            // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
-            nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
-
-            nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
-        }
-    }
+       NSVGshape *shape = NULL;
+       NSVGedge *e = NULL;
+       NSVGcachedPaint cache;
+       int i;
+
+       r->bitmap = dst;
+       r->width = w;
+       r->height = h;
+       r->stride = stride;
+
+       if (w > r->cscanline) {
+               r->cscanline = w;
+               r->scanline = (unsigned char*)realloc(r->scanline, w);
+               if (r->scanline == NULL) return;
+       }
+
+       for (i = 0; i < h; i++)
+               memset(&dst[i*stride], 0, w*4);
+
+       for (shape = image->shapes; shape != NULL; shape = shape->next) {
+               if (!(shape->flags & NSVG_FLAGS_VISIBLE))
+                       continue;
+
+               if (shape->fill.type != NSVG_PAINT_NONE) {
+                       nsvg__resetPool(r);
+                       r->freelist = NULL;
+                       r->nedges = 0;
+
+                       nsvg__flattenShape(r, shape, scale);
+
+                       // Scale and translate edges
+                       for (i = 0; i < r->nedges; i++) {
+                               e = &r->edges[i];
+                               e->x0 = tx + e->x0;
+                               e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+                               e->x1 = tx + e->x1;
+                               e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+                       }
+
+                       // Rasterize edges
+                       qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+                       // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+                       nsvg__initPaint(&cache, &shape->fill, shape->opacity);
+
+                       nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
+               }
+               if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
+                       nsvg__resetPool(r);
+                       r->freelist = NULL;
+                       r->nedges = 0;
+
+                       nsvg__flattenShapeStroke(r, shape, scale);
+
+//                     dumpEdges(r, "edge.svg");
+
+                       // Scale and translate edges
+                       for (i = 0; i < r->nedges; i++) {
+                               e = &r->edges[i];
+                               e->x0 = tx + e->x0;
+                               e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+                               e->x1 = tx + e->x1;
+                               e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+                       }
+
+                       // Rasterize edges
+                       qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+                       // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+                       nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
+
+                       nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
+               }
+       }
 
     /**
      * In the original file, the pre-multiplied alpha format is transformed to the convertional non-pre format.
      * We skip this process here, and render the pre-multiplied alpha format directly in our svg renderer.
      */
 
-    r->bitmap = NULL;
-    r->width = 0;
-    r->height = 0;
-    r->stride = 0;
+       r->bitmap = NULL;
+       r->width = 0;
+       r->height = 0;
+       r->stride = 0;
 }
index 3b52600..92f31ea 100644 (file)
@@ -10,7 +10,7 @@
  * freely, subject to the following restrictions:
  *
  * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
+ * claim that you wrote the original software. If you use this softwarue
  * in a product, an acknowledgment in the product documentation would be
  * appreciated but is not required.
  * 2. Altered source versions must be plainly marked as such, and must not be
 typedef struct NSVGrasterizer NSVGrasterizer;
 
 /* Example Usage:
-       // Load SVG
-       struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+  // Load SVG
+  struct SNVGImage* image = nsvgParseFromFile("test.svg.");
 
-       // Create rasterizer (can be used to render multiple images).
-       struct NSVGrasterizer* rast = nsvgCreateRasterizer();
-       // Allocate memory for image
-       unsigned char* img = malloc(w*h*4);
-       // Rasterize
-       nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
+  // Create rasterizer (can be used to render multiple images).
+  struct NSVGrasterizer* rast = nsvgCreateRasterizer();
+  // Allocate memory for image
+  unsigned char* img = malloc(w*h*4);
+  // Rasterize
+  nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
 */
 
 // Allocated rasterizer context.
@@ -54,8 +54,8 @@ NSVGrasterizer* nsvgCreateRasterizer();
 //   h - height of the image to render
 //   stride - number of bytes per scaleline in the destination buffer
 void nsvgRasterize(NSVGrasterizer* r,
-                                  NSVGimage* image, float tx, float ty, float scale,
-                                  unsigned char* dst, int w, int h, int stride);
+                   NSVGimage* image, float tx, float ty, float scale,
+                   unsigned char* dst, int w, int h, int stride);
 
 // Deletes rasterizer context.
 void nsvgDeleteRasterizer(NSVGrasterizer*);
index 4cbdb9e..b08ff39 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    1.3.2
+Version:    1.3.5
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT