@react-native-ohos/react-native-svg 15.12.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/css/package.json +6 -0
- package/harmony/svg/BuildProfile.ets +17 -0
- package/harmony/svg/build-profile.json5 +9 -0
- package/harmony/svg/hvigorfile.ts +2 -0
- package/harmony/svg/index.ets +7 -0
- package/harmony/svg/oh-package.json5 +13 -0
- package/harmony/svg/src/main/cpp/Attribute.h +52 -0
- package/harmony/svg/src/main/cpp/CMakeLists.txt +32 -0
- package/harmony/svg/src/main/cpp/FallbackProps.h +0 -0
- package/harmony/svg/src/main/cpp/FontHolderBase.cpp +22 -0
- package/harmony/svg/src/main/cpp/FontHolderBase.h +54 -0
- package/harmony/svg/src/main/cpp/SVGPackage.cpp +135 -0
- package/harmony/svg/src/main/cpp/SVGPackage.h +153 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +75 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.h +45 -0
- package/harmony/svg/src/main/cpp/SvgBaseAttribute.h +83 -0
- package/harmony/svg/src/main/cpp/SvgCircle.cpp +29 -0
- package/harmony/svg/src/main/cpp/SvgCircle.h +29 -0
- package/harmony/svg/src/main/cpp/SvgClipPath.h +22 -0
- package/harmony/svg/src/main/cpp/SvgContext.cpp +56 -0
- package/harmony/svg/src/main/cpp/SvgContext.h +71 -0
- package/harmony/svg/src/main/cpp/SvgDefs.h +46 -0
- package/harmony/svg/src/main/cpp/SvgEllipse.cpp +32 -0
- package/harmony/svg/src/main/cpp/SvgEllipse.h +34 -0
- package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -0
- package/harmony/svg/src/main/cpp/SvgFilter.h +112 -0
- package/harmony/svg/src/main/cpp/SvgGradient.cpp +116 -0
- package/harmony/svg/src/main/cpp/SvgGradient.h +49 -0
- package/harmony/svg/src/main/cpp/SvgGraphic.cpp +553 -0
- package/harmony/svg/src/main/cpp/SvgGraphic.h +77 -0
- package/harmony/svg/src/main/cpp/SvgGroup.cpp +86 -0
- package/harmony/svg/src/main/cpp/SvgGroup.h +41 -0
- package/harmony/svg/src/main/cpp/SvgHost.cpp +27 -0
- package/harmony/svg/src/main/cpp/SvgHost.h +38 -0
- package/harmony/svg/src/main/cpp/SvgImage.cpp +168 -0
- package/harmony/svg/src/main/cpp/SvgImage.h +52 -0
- package/harmony/svg/src/main/cpp/SvgLine.cpp +28 -0
- package/harmony/svg/src/main/cpp/SvgLine.h +32 -0
- package/harmony/svg/src/main/cpp/SvgMarker.cpp +61 -0
- package/harmony/svg/src/main/cpp/SvgMarker.h +86 -0
- package/harmony/svg/src/main/cpp/SvgMask.cpp +72 -0
- package/harmony/svg/src/main/cpp/SvgMask.h +68 -0
- package/harmony/svg/src/main/cpp/SvgNode.cpp +289 -0
- package/harmony/svg/src/main/cpp/SvgNode.h +347 -0
- package/harmony/svg/src/main/cpp/SvgPath.cpp +42 -0
- package/harmony/svg/src/main/cpp/SvgPath.h +29 -0
- package/harmony/svg/src/main/cpp/SvgPattern.cpp +77 -0
- package/harmony/svg/src/main/cpp/SvgPattern.h +64 -0
- package/harmony/svg/src/main/cpp/SvgQuote.h +87 -0
- package/harmony/svg/src/main/cpp/SvgRect.cpp +58 -0
- package/harmony/svg/src/main/cpp/SvgRect.h +33 -0
- package/harmony/svg/src/main/cpp/SvgSvg.cpp +83 -0
- package/harmony/svg/src/main/cpp/SvgSvg.h +52 -0
- package/harmony/svg/src/main/cpp/SvgSymbol.cpp +25 -0
- package/harmony/svg/src/main/cpp/SvgSymbol.h +37 -0
- package/harmony/svg/src/main/cpp/SvgTSpan.cpp +501 -0
- package/harmony/svg/src/main/cpp/SvgTSpan.h +101 -0
- package/harmony/svg/src/main/cpp/SvgText.cpp +48 -0
- package/harmony/svg/src/main/cpp/SvgText.h +29 -0
- package/harmony/svg/src/main/cpp/SvgTextPath.cpp +35 -0
- package/harmony/svg/src/main/cpp/SvgTextPath.h +51 -0
- package/harmony/svg/src/main/cpp/SvgUse.cpp +65 -0
- package/harmony/svg/src/main/cpp/SvgUse.h +46 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.cpp +36 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.h +37 -0
- package/harmony/svg/src/main/cpp/TextBase.cpp +20 -0
- package/harmony/svg/src/main/cpp/TextBase.h +114 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGBaseComponentInstance.h +212 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.cpp +31 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.cpp +23 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.cpp +23 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +46 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +199 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +100 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.h +43 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.cpp +35 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.h +29 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.cpp +40 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.cpp +36 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +86 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +47 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.cpp +25 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.h +32 -0
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +207 -0
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.h +88 -0
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +106 -0
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +97 -0
- package/harmony/svg/src/main/cpp/downloadUtils/LRUCache.h +98 -0
- package/harmony/svg/src/main/cpp/drawing/Brush.cpp +50 -0
- package/harmony/svg/src/main/cpp/drawing/Brush.h +52 -0
- package/harmony/svg/src/main/cpp/drawing/GlyPathBag.cpp +20 -0
- package/harmony/svg/src/main/cpp/drawing/GlyPathBag.h +31 -0
- package/harmony/svg/src/main/cpp/drawing/Matrix.cpp +100 -0
- package/harmony/svg/src/main/cpp/drawing/Matrix.h +68 -0
- package/harmony/svg/src/main/cpp/drawing/Path.cpp +173 -0
- package/harmony/svg/src/main/cpp/drawing/Path.h +127 -0
- package/harmony/svg/src/main/cpp/drawing/Pen.cpp +57 -0
- package/harmony/svg/src/main/cpp/drawing/Pen.h +59 -0
- package/harmony/svg/src/main/cpp/drawing/Rect.cpp +47 -0
- package/harmony/svg/src/main/cpp/drawing/Rect.h +56 -0
- package/harmony/svg/src/main/cpp/drawing/RoundRect.cpp +24 -0
- package/harmony/svg/src/main/cpp/drawing/RoundRect.h +39 -0
- package/harmony/svg/src/main/cpp/drawing/ShaderEffect.cpp +37 -0
- package/harmony/svg/src/main/cpp/drawing/ShaderEffect.h +51 -0
- package/harmony/svg/src/main/cpp/drawing/TextStyle.cpp +49 -0
- package/harmony/svg/src/main/cpp/drawing/TextStyle.h +41 -0
- package/harmony/svg/src/main/cpp/drawing/Typography.cpp +9 -0
- package/harmony/svg/src/main/cpp/drawing/Typography.h +25 -0
- package/harmony/svg/src/main/cpp/drawing/TypographyStyle.cpp +31 -0
- package/harmony/svg/src/main/cpp/drawing/TypographyStyle.h +41 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGCircleJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGClipPathJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGDefsJSIBinder.h +38 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGEllipseJSIBinder.h +55 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +27 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGForeignObjectJSIBinder.h +57 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGGroupJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGImageJSIBinder.h +58 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLineJSIBinder.h +55 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLinearGradientJSIBinder.h +45 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMarkerJSIBinder.h +66 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMaskJSIBinder.h +60 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPathJSIBinder.h +52 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPatternJSIBinder.h +67 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRadialGradientJSIBinder.h +47 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRectJSIBinder.h +57 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewAndroidJSIBinder.h +67 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewJSIBinder.h +36 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSymbolJSIBinder.h +60 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTSpanJSIBinder.h +66 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextJSIBinder.h +65 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextPathJSIBinder.h +71 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGUseJSIBinder.h +56 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ComponentDescriptors.h +48 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.cpp +20 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.h +253 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.cpp +45 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.h +331 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.cpp +18 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.h +441 -0
- package/harmony/svg/src/main/cpp/properties/Color.cpp +458 -0
- package/harmony/svg/src/main/cpp/properties/Color.h +144 -0
- package/harmony/svg/src/main/cpp/properties/Decoration.cpp +41 -0
- package/harmony/svg/src/main/cpp/properties/Decoration.h +483 -0
- package/harmony/svg/src/main/cpp/properties/Dimension.cpp +64 -0
- package/harmony/svg/src/main/cpp/properties/Dimension.h +243 -0
- package/harmony/svg/src/main/cpp/properties/Font.cpp +166 -0
- package/harmony/svg/src/main/cpp/properties/Font.h +163 -0
- package/harmony/svg/src/main/cpp/properties/Offset.h +119 -0
- package/harmony/svg/src/main/cpp/properties/PaintState.h +240 -0
- package/harmony/svg/src/main/cpp/properties/Rect.h +423 -0
- package/harmony/svg/src/main/cpp/properties/Size.h +246 -0
- package/harmony/svg/src/main/cpp/properties/SvgPaintState.h +452 -0
- package/harmony/svg/src/main/cpp/properties/TextProperties.cpp +91 -0
- package/harmony/svg/src/main/cpp/properties/TextProperties.h +56 -0
- package/harmony/svg/src/main/cpp/properties/ViewBox.h +108 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageComponentDescriptor.h +41 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.cpp +62 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.h +63 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.cpp +17 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.h +58 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +54 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.h +32 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.cpp +101 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.h +32 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.cpp +71 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.h +32 -0
- package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -0
- package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -0
- package/harmony/svg/src/main/cpp/utils/GlyphContext.cpp +221 -0
- package/harmony/svg/src/main/cpp/utils/GlyphContext.h +106 -0
- package/harmony/svg/src/main/cpp/utils/LinearMap.h +69 -0
- package/harmony/svg/src/main/cpp/utils/PathParserUtils.cpp +591 -0
- package/harmony/svg/src/main/cpp/utils/PathParserUtils.h +93 -0
- package/harmony/svg/src/main/cpp/utils/StringUtils.cpp +134 -0
- package/harmony/svg/src/main/cpp/utils/StringUtils.h +644 -0
- package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.cpp +239 -0
- package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.h +277 -0
- package/harmony/svg/src/main/cpp/utils/SvgMarkerPositionUtils.h +200 -0
- package/harmony/svg/src/main/cpp/utils/SvgUtils.h +176 -0
- package/harmony/svg/src/main/cpp/utils/TextPathHelper.cpp +94 -0
- package/harmony/svg/src/main/cpp/utils/TextPathHelper.h +61 -0
- package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -0
- package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -0
- package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -0
- package/harmony/svg/src/main/ets/SvgPackage.ts +58 -0
- package/harmony/svg/src/main/module.json5 +7 -0
- package/harmony/svg/src/main/resources/base/element/string.json +8 -0
- package/harmony/svg/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/svg/ts.ts +8 -0
- package/harmony/svg.har +0 -0
- package/lib/commonjs/css/index.js +55 -0
- package/lib/commonjs/css/index.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/css/index.js +4 -0
- package/lib/module/css/index.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +8 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/babel.config.d.ts +3 -0
- package/lib/typescript/example/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/contexts.d.ts +3 -0
- package/lib/typescript/example/contexts.d.ts.map +1 -0
- package/lib/typescript/example/harmony/entry/hvigorfile.d.ts +2 -0
- package/lib/typescript/example/harmony/entry/hvigorfile.d.ts.map +1 -0
- package/lib/typescript/example/harmony/hvigorfile.d.ts +2 -0
- package/lib/typescript/example/harmony/hvigorfile.d.ts.map +1 -0
- package/lib/typescript/example/index.d.ts +2 -0
- package/lib/typescript/example/index.d.ts.map +1 -0
- package/lib/typescript/example/jest.config.d.ts +3 -0
- package/lib/typescript/example/jest.config.d.ts.map +1 -0
- package/lib/typescript/example/metro.config.d.ts +3 -0
- package/lib/typescript/example/metro.config.d.ts.map +1 -0
- package/lib/typescript/example/react-native.config.d.ts +3 -0
- package/lib/typescript/example/react-native.config.d.ts.map +1 -0
- package/lib/typescript/example/scripts/create-build-profile.d.ts +2 -0
- package/lib/typescript/example/scripts/create-build-profile.d.ts.map +1 -0
- package/lib/typescript/example/src/index.d.ts +3 -0
- package/lib/typescript/example/src/index.d.ts.map +1 -0
- package/lib/typescript/src/css/index.d.ts +4 -0
- package/lib/typescript/src/css/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +54 -0
- package/src/css/index.tsx +20 -0
- package/src/index.tsx +3 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include <native_drawing/drawing_font_collection.h>
|
|
8
|
+
#include <native_drawing/drawing_matrix.h>
|
|
9
|
+
#include <native_drawing/drawing_text_blob.h>
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include "SvgTSpan.h"
|
|
12
|
+
#include "SvgFilter.h"
|
|
13
|
+
#include "drawing/TextStyle.h"
|
|
14
|
+
#include "drawing/Typography.h"
|
|
15
|
+
#include "drawing/Matrix.h"
|
|
16
|
+
#include "utils/TextPathHelper.h"
|
|
17
|
+
|
|
18
|
+
namespace rnoh {
|
|
19
|
+
namespace svg {
|
|
20
|
+
|
|
21
|
+
constexpr double MATHEMATICAL_BASELINE_SHIFT_FACTOR = 0.5;
|
|
22
|
+
constexpr double HANGING_BASELINE_SHIFT_FACTOR = 0.8;
|
|
23
|
+
constexpr double ALIGN_START = 0.0;
|
|
24
|
+
constexpr double ALIGN_MIDDLE = -0.5;
|
|
25
|
+
constexpr double ALIGN_END = -1.0;
|
|
26
|
+
|
|
27
|
+
void SvgTSpan::OnDraw(OH_Drawing_Canvas *canvas) {
|
|
28
|
+
if (!glyphCtx_) {
|
|
29
|
+
InitGlyph(canvas, scale_);
|
|
30
|
+
}
|
|
31
|
+
if (!font_) {
|
|
32
|
+
InitFont(scale_);
|
|
33
|
+
}
|
|
34
|
+
if (content_.empty()) {
|
|
35
|
+
for (const auto &child : children_) {
|
|
36
|
+
if (auto tSpan = std::dynamic_pointer_cast<SvgTSpan>(child); tSpan) {
|
|
37
|
+
tSpan->SetGlyphContext(glyphCtx_);
|
|
38
|
+
UpdateChildTextProps(tSpan);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
glyphCtx_->pushContext(false, shared_from_this(), x_, y_, dx_, dy_, rotate_);
|
|
45
|
+
if (!textPath_) {
|
|
46
|
+
DrawText(canvas);
|
|
47
|
+
} else {
|
|
48
|
+
DrawTextPath(canvas);
|
|
49
|
+
}
|
|
50
|
+
glyphCtx_->popContext();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void SvgTSpan::DrawText(OH_Drawing_Canvas *canvas) {
|
|
54
|
+
drawing::TextStyle textStyle;
|
|
55
|
+
textStyle.Update(font_);
|
|
56
|
+
drawing::TypographyStyle ts;
|
|
57
|
+
ts.Update(font_);
|
|
58
|
+
|
|
59
|
+
// create a typography to measure metrics for linear gradient
|
|
60
|
+
auto *fontCollection = OH_Drawing_CreateFontCollection();
|
|
61
|
+
auto *typographyHandler = OH_Drawing_CreateTypographyHandler(ts.typographyStyle_.get(), fontCollection);
|
|
62
|
+
OH_Drawing_TypographyHandlerPushTextStyle(typographyHandler, textStyle.textStyle_.get());
|
|
63
|
+
OH_Drawing_TypographyHandlerAddText(typographyHandler, content_.c_str());
|
|
64
|
+
auto *typographyForMetrics = OH_Drawing_CreateTypography(typographyHandler);
|
|
65
|
+
double maxWidth =
|
|
66
|
+
inlineSize_.value_or(Infinity<Dimension>()).RelativeConvertToPx(OH_Drawing_CanvasGetWidth(canvas), scale_);
|
|
67
|
+
OH_Drawing_TypographyLayout(typographyForMetrics, maxWidth);
|
|
68
|
+
double actualWidth = OH_Drawing_TypographyGetLongestLine(typographyForMetrics);
|
|
69
|
+
|
|
70
|
+
double scaleSpacingAndGlyphs = 1.0;
|
|
71
|
+
if (AdjustSpacing(canvas, actualWidth, scaleSpacingAndGlyphs)) {
|
|
72
|
+
OH_Drawing_SetTextStyleLetterSpacing(textStyle.textStyle_.get(), font_->letterSpacing);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
OH_Drawing_Font_Metrics fm;
|
|
76
|
+
OH_Drawing_TextStyleGetFontMetrics(typographyForMetrics, textStyle.textStyle_.get(), &fm);
|
|
77
|
+
// Ceil the actual width to avoid small floating-point errors and ensure proper alignment
|
|
78
|
+
// when calculating the position of the next glyph and adjusting for the text anchor.
|
|
79
|
+
double dx = glyphCtx_->nextX(actualWidth) - std::ceil(actualWidth) + glyphCtx_->nextDeltaX() +
|
|
80
|
+
getTextAnchorOffset(font_->textAnchor, actualWidth);
|
|
81
|
+
// the position of typography is on the left-top
|
|
82
|
+
double dy = glyphCtx_->nextY() + glyphCtx_->nextDeltaY() +
|
|
83
|
+
CalcBaselineShift(typographyHandler, ts.textStyle_.get(), fm) -
|
|
84
|
+
OH_Drawing_TypographyGetAlphabeticBaseline(typographyForMetrics);
|
|
85
|
+
DLOG(INFO) << "TEXT GLYPH next X = " << dx << " next dy = " << dy;
|
|
86
|
+
|
|
87
|
+
boundsWidth_ = actualWidth;
|
|
88
|
+
boundsHeight_ = fm.capHeight;
|
|
89
|
+
boundsX_ = dx;
|
|
90
|
+
boundsY_ = dy + (OH_Drawing_TypographyGetIdeographicBaseline(typographyForMetrics) - fm.descent - fm.capHeight);
|
|
91
|
+
|
|
92
|
+
// draw the border of the area for debug
|
|
93
|
+
bool drawBounds = false;
|
|
94
|
+
if (drawBounds) {
|
|
95
|
+
OH_Drawing_CanvasDrawLine(canvas, boundsX_, boundsY_, boundsX_ + boundsWidth_, boundsY_);
|
|
96
|
+
OH_Drawing_CanvasDrawLine(canvas, boundsX_ + boundsWidth_, boundsY_, boundsX_ + boundsWidth_,
|
|
97
|
+
boundsY_ + boundsHeight_);
|
|
98
|
+
OH_Drawing_CanvasDrawLine(canvas, boundsX_ + boundsWidth_, boundsY_ + boundsHeight_, boundsX_,
|
|
99
|
+
boundsY_ + boundsHeight_);
|
|
100
|
+
OH_Drawing_CanvasDrawLine(canvas, boundsX_, boundsY_ + boundsHeight_, boundsX_, boundsY_);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
UpdateGradient(attributes_.strokeState.GetGradient());
|
|
104
|
+
UpdateGradient(attributes_.fillState.GetGradient());
|
|
105
|
+
UpdateStrokeStyle();
|
|
106
|
+
auto fillOpaque = UpdateFillStyle();
|
|
107
|
+
if (!fillOpaque) {
|
|
108
|
+
fillBrush_.SetColor(Color::TRANSPARENT.GetValue());
|
|
109
|
+
}
|
|
110
|
+
textStyle.SetForegroundBrush(fillBrush_.get());
|
|
111
|
+
textStyle.SetForegroundPen(strokePen_.get());
|
|
112
|
+
ts.SetTextStyle(std::move(textStyle));
|
|
113
|
+
|
|
114
|
+
// create the typography for drawing
|
|
115
|
+
OH_Drawing_TypographyHandlerPopTextStyle(typographyHandler);
|
|
116
|
+
OH_Drawing_TypographyHandlerPushTextStyle(typographyHandler, ts.textStyle_.get());
|
|
117
|
+
OH_Drawing_TypographyHandlerAddText(typographyHandler, content_.c_str());
|
|
118
|
+
auto *typography = OH_Drawing_CreateTypography(typographyHandler);
|
|
119
|
+
OH_Drawing_TypographyLayout(typography, maxWidth);
|
|
120
|
+
|
|
121
|
+
double r = glyphCtx_->nextRotation();
|
|
122
|
+
drawing::Matrix mat;
|
|
123
|
+
mat.PreRotate(r, dx, dy);
|
|
124
|
+
|
|
125
|
+
// Apply filter if exists (similar to SvgGraphic::OnGraphicFill)
|
|
126
|
+
bool hasCustomFilter = !attributes_.filterId.empty();
|
|
127
|
+
if (hasCustomFilter) {
|
|
128
|
+
auto svgContext = GetContext();
|
|
129
|
+
if (svgContext) {
|
|
130
|
+
auto filterNode = svgContext->GetSvgNodeById(attributes_.filterId);
|
|
131
|
+
auto svgFilter = std::dynamic_pointer_cast<SvgFilter>(filterNode);
|
|
132
|
+
if (svgFilter) {
|
|
133
|
+
// Apply filter to the text style
|
|
134
|
+
auto tempFillBrush = fillBrush_;
|
|
135
|
+
svgFilter->ApplyToBrush(tempFillBrush);
|
|
136
|
+
|
|
137
|
+
// Update text style with filtered brush
|
|
138
|
+
drawing::TextStyle filteredTextStyle;
|
|
139
|
+
filteredTextStyle.SetForegroundBrush(tempFillBrush.get());
|
|
140
|
+
filteredTextStyle.SetForegroundPen(strokePen_.get());
|
|
141
|
+
filteredTextStyle.Update(font_);
|
|
142
|
+
|
|
143
|
+
// Create new typography with filtered style
|
|
144
|
+
drawing::TypographyStyle filteredTs;
|
|
145
|
+
filteredTs.SetTextStyle(std::move(filteredTextStyle));
|
|
146
|
+
filteredTs.Update(font_);
|
|
147
|
+
|
|
148
|
+
auto *filteredFontCollection = OH_Drawing_CreateFontCollection();
|
|
149
|
+
auto *filteredTypographyHandler = OH_Drawing_CreateTypographyHandler(filteredTs.typographyStyle_.get(), filteredFontCollection);
|
|
150
|
+
OH_Drawing_TypographyHandlerPushTextStyle(filteredTypographyHandler, filteredTs.textStyle_.get());
|
|
151
|
+
OH_Drawing_TypographyHandlerAddText(filteredTypographyHandler, content_.c_str());
|
|
152
|
+
auto *filteredTypography = OH_Drawing_CreateTypography(filteredTypographyHandler);
|
|
153
|
+
OH_Drawing_TypographyLayout(filteredTypography, maxWidth);
|
|
154
|
+
|
|
155
|
+
OH_Drawing_CanvasSave(canvas);
|
|
156
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mat.get());
|
|
157
|
+
OH_Drawing_TypographyPaint(filteredTypography, canvas, dx, dy);
|
|
158
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
159
|
+
|
|
160
|
+
OH_Drawing_DestroyTypography(filteredTypography);
|
|
161
|
+
OH_Drawing_DestroyTypographyHandler(filteredTypographyHandler);
|
|
162
|
+
OH_Drawing_DestroyFontCollection(filteredFontCollection);
|
|
163
|
+
} else {
|
|
164
|
+
// No filter found, draw normally
|
|
165
|
+
OH_Drawing_CanvasSave(canvas);
|
|
166
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mat.get());
|
|
167
|
+
OH_Drawing_TypographyPaint(typography, canvas, dx, dy);
|
|
168
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
// No SVG context, draw normally
|
|
172
|
+
OH_Drawing_CanvasSave(canvas);
|
|
173
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mat.get());
|
|
174
|
+
OH_Drawing_TypographyPaint(typography, canvas, dx, dy);
|
|
175
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
// No filter, draw normally
|
|
179
|
+
OH_Drawing_CanvasSave(canvas);
|
|
180
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mat.get());
|
|
181
|
+
OH_Drawing_TypographyPaint(typography, canvas, dx, dy);
|
|
182
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
OH_Drawing_DestroyTypography(typographyForMetrics);
|
|
186
|
+
OH_Drawing_DestroyTypography(typography);
|
|
187
|
+
OH_Drawing_DestroyTypographyHandler(typographyHandler);
|
|
188
|
+
OH_Drawing_DestroyFontCollection(fontCollection);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
double SvgTSpan::getTextAnchorOffset(TextAnchor textAnchor, const double &textMeasure) {
|
|
192
|
+
switch (textAnchor) {
|
|
193
|
+
default:
|
|
194
|
+
case TextAnchor::start:
|
|
195
|
+
return ALIGN_START;
|
|
196
|
+
|
|
197
|
+
case TextAnchor::middle:
|
|
198
|
+
return ALIGN_MIDDLE * textMeasure;
|
|
199
|
+
|
|
200
|
+
case TextAnchor::end:
|
|
201
|
+
return ALIGN_END * textMeasure;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
drawing::TypographyStyle SvgTSpan::PrepareTypoStyle() {
|
|
206
|
+
UpdateStrokeStyle();
|
|
207
|
+
auto fillOpaque = UpdateFillStyle();
|
|
208
|
+
if (!fillOpaque) {
|
|
209
|
+
fillBrush_.SetColor(Color::TRANSPARENT.GetValue());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
drawing::TextStyle textStyle;
|
|
213
|
+
textStyle.SetForegroundBrush(fillBrush_.get());
|
|
214
|
+
textStyle.SetForegroundPen(strokePen_.get());
|
|
215
|
+
textStyle.Update(font_);
|
|
216
|
+
drawing::TypographyStyle ts;
|
|
217
|
+
ts.SetTextStyle(std::move(textStyle));
|
|
218
|
+
ts.Update(font_);
|
|
219
|
+
return std::move(ts);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
bool SvgTSpan::AdjustSpacing(OH_Drawing_Canvas *canvas, double textMeasure, double &scaleSpacingAndGlyphs) {
|
|
223
|
+
if (textLength_) {
|
|
224
|
+
double author = textLength_->RelativeConvertToPx(OH_Drawing_CanvasGetWidth(canvas), scale_);
|
|
225
|
+
switch (lengthAdjust_) {
|
|
226
|
+
default:
|
|
227
|
+
case TextLengthAdjust::spacing:
|
|
228
|
+
font_->letterSpacing += (author - textMeasure) / (content_.size() - 1);
|
|
229
|
+
return true;
|
|
230
|
+
case TextLengthAdjust::spacingAndGlyphs:
|
|
231
|
+
scaleSpacingAndGlyphs = author / textMeasure;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
void SvgTSpan::DrawTextPath(OH_Drawing_Canvas *canvas) {
|
|
239
|
+
if (content_.empty()) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
TextPathHelper ph(textPath_, font_->textAnchor);
|
|
244
|
+
if (!ph.Valid()) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
drawing::TypographyStyle ts = PrepareTypoStyle();
|
|
249
|
+
auto *fontCollection = OH_Drawing_CreateFontCollection();
|
|
250
|
+
auto *typographyHandler = OH_Drawing_CreateTypographyHandler(ts.typographyStyle_.get(), fontCollection);
|
|
251
|
+
|
|
252
|
+
OH_Drawing_TypographyHandlerAddText(typographyHandler, content_.c_str());
|
|
253
|
+
auto *typography = OH_Drawing_CreateTypography(typographyHandler);
|
|
254
|
+
OH_Drawing_TypographyLayout(typography, 1e9);
|
|
255
|
+
double textMeasure = OH_Drawing_TypographyGetLineWidth(typography, 0);
|
|
256
|
+
double offset = getTextAnchorOffset(font_->textAnchor, textMeasure);
|
|
257
|
+
|
|
258
|
+
offset += ph.GetStartOffset();
|
|
259
|
+
|
|
260
|
+
double scaleSpacingAndGlyphs = 1.0;
|
|
261
|
+
if (AdjustSpacing(canvas, textMeasure, scaleSpacingAndGlyphs)) {
|
|
262
|
+
DLOG(INFO) << "adjust spacing to " << font_->letterSpacing;
|
|
263
|
+
OH_Drawing_SetTextStyleLetterSpacing(ts.textStyle_.get(), font_->letterSpacing);
|
|
264
|
+
}
|
|
265
|
+
ph.SetScaleSpacingAndGlyphs(scaleSpacingAndGlyphs);
|
|
266
|
+
|
|
267
|
+
std::vector<bool> ligature(content_.size(), false);
|
|
268
|
+
|
|
269
|
+
OH_Drawing_Font_Metrics fm;
|
|
270
|
+
OH_Drawing_TextStyleGetFontMetrics(typography, ts.textStyle_.get(), &fm);
|
|
271
|
+
double baselineShift = CalcBaselineShift(typographyHandler, ts.textStyle_.get(), fm);
|
|
272
|
+
|
|
273
|
+
for (int i = 0; i < content_.size(); i++) {
|
|
274
|
+
std::string current = content_.substr(i, 1);
|
|
275
|
+
|
|
276
|
+
auto *fontCollection = OH_Drawing_CreateFontCollection();
|
|
277
|
+
auto *typographyHandler = OH_Drawing_CreateTypographyHandler(ts.typographyStyle_.get(), fontCollection);
|
|
278
|
+
OH_Drawing_TypographyHandlerAddText(typographyHandler, current.c_str());
|
|
279
|
+
drawing::Typography typography(typographyHandler);
|
|
280
|
+
OH_Drawing_TypographyLayout(&typography, 1e9);
|
|
281
|
+
double charWidth = OH_Drawing_TypographyGetLineWidth(&typography, 0);
|
|
282
|
+
|
|
283
|
+
bool alreadyRenderedGraphemeCluster = false;
|
|
284
|
+
bool hasLigature = false;
|
|
285
|
+
|
|
286
|
+
if (alreadyRenderedGraphemeCluster) {
|
|
287
|
+
current = "";
|
|
288
|
+
} else {
|
|
289
|
+
int nextIndex = i;
|
|
290
|
+
while (++nextIndex < content_.size()) {
|
|
291
|
+
float nextWidth = charWidth;
|
|
292
|
+
if (nextWidth > 0) {
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
std::string nextLigature = current + current[nextIndex];
|
|
296
|
+
ligature[nextIndex] = true;
|
|
297
|
+
current = nextLigature;
|
|
298
|
+
hasLigature = true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
bool autoKerning = !font_->manualKerning;
|
|
302
|
+
double kerning = font_->kerning;
|
|
303
|
+
if (autoKerning) {
|
|
304
|
+
double kerned = charWidth * scaleSpacingAndGlyphs;
|
|
305
|
+
kerning = kerned - charWidth;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
bool isWordSeparator = current[0] == ' ';
|
|
309
|
+
double wordSpace = isWordSeparator ? font_->wordSpacing : 0;
|
|
310
|
+
double spacing = wordSpace + font_->letterSpacing;
|
|
311
|
+
double advance = charWidth + spacing;
|
|
312
|
+
|
|
313
|
+
double x = glyphCtx_->nextX(alreadyRenderedGraphemeCluster ? 0 : kerning + advance);
|
|
314
|
+
double y = glyphCtx_->nextY();
|
|
315
|
+
double dx = glyphCtx_->nextDeltaX();
|
|
316
|
+
double dy = glyphCtx_->nextDeltaY();
|
|
317
|
+
double r = glyphCtx_->nextRotation();
|
|
318
|
+
|
|
319
|
+
if (alreadyRenderedGraphemeCluster || isWordSeparator) {
|
|
320
|
+
// Skip rendering other grapheme clusters of ligatures (already rendered),
|
|
321
|
+
// But, make sure to increment index positions by making gc.next() calls.
|
|
322
|
+
OH_Drawing_DestroyFontCollection(fontCollection);
|
|
323
|
+
OH_Drawing_DestroyTypographyHandler(typographyHandler);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
int side = ph.GetSide();
|
|
327
|
+
advance *= side;
|
|
328
|
+
charWidth *= side;
|
|
329
|
+
double cursor = offset + (x + dx) * side;
|
|
330
|
+
double startPoint = cursor - advance;
|
|
331
|
+
|
|
332
|
+
drawing::Matrix mid;
|
|
333
|
+
if (!ph.GetMatrixOnPath({charWidth, startPoint, y, dy + baselineShift}, mid)) {
|
|
334
|
+
OH_Drawing_DestroyFontCollection(fontCollection);
|
|
335
|
+
OH_Drawing_DestroyTypographyHandler(typographyHandler);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
mid.PreRotate(r, 0, 0);
|
|
339
|
+
|
|
340
|
+
// Apply filter if exists (similar to SvgGraphic::OnGraphicFill)
|
|
341
|
+
bool hasCustomFilter = !attributes_.filterId.empty();
|
|
342
|
+
if (hasCustomFilter) {
|
|
343
|
+
auto svgContext = GetContext();
|
|
344
|
+
if (svgContext) {
|
|
345
|
+
auto filterNode = svgContext->GetSvgNodeById(attributes_.filterId);
|
|
346
|
+
auto svgFilter = std::dynamic_pointer_cast<SvgFilter>(filterNode);
|
|
347
|
+
if (svgFilter) {
|
|
348
|
+
// Apply filter to the text style
|
|
349
|
+
auto tempFillBrush = fillBrush_;
|
|
350
|
+
svgFilter->ApplyToBrush(tempFillBrush);
|
|
351
|
+
|
|
352
|
+
// Update text style with filtered brush
|
|
353
|
+
drawing::TextStyle filteredTextStyle;
|
|
354
|
+
filteredTextStyle.SetForegroundBrush(tempFillBrush.get());
|
|
355
|
+
filteredTextStyle.SetForegroundPen(strokePen_.get());
|
|
356
|
+
filteredTextStyle.Update(font_);
|
|
357
|
+
|
|
358
|
+
// Create new typography with filtered style
|
|
359
|
+
drawing::TypographyStyle filteredTs;
|
|
360
|
+
filteredTs.SetTextStyle(std::move(filteredTextStyle));
|
|
361
|
+
filteredTs.Update(font_);
|
|
362
|
+
|
|
363
|
+
auto *filteredFontCollection = OH_Drawing_CreateFontCollection();
|
|
364
|
+
auto *filteredTypographyHandler = OH_Drawing_CreateTypographyHandler(filteredTs.typographyStyle_.get(), filteredFontCollection);
|
|
365
|
+
OH_Drawing_TypographyHandlerPushTextStyle(filteredTypographyHandler, filteredTs.textStyle_.get());
|
|
366
|
+
OH_Drawing_TypographyHandlerAddText(filteredTypographyHandler, current.c_str());
|
|
367
|
+
drawing::Typography filteredTypography(filteredTypographyHandler);
|
|
368
|
+
OH_Drawing_TypographyLayout(&filteredTypography, 1e9);
|
|
369
|
+
|
|
370
|
+
OH_Drawing_CanvasSave(canvas);
|
|
371
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mid.get());
|
|
372
|
+
OH_Drawing_TypographyPaint(&filteredTypography, canvas, 0, 0);
|
|
373
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
374
|
+
|
|
375
|
+
OH_Drawing_DestroyTypographyHandler(filteredTypographyHandler);
|
|
376
|
+
OH_Drawing_DestroyFontCollection(filteredFontCollection);
|
|
377
|
+
} else {
|
|
378
|
+
// No filter found, draw normally
|
|
379
|
+
OH_Drawing_CanvasSave(canvas);
|
|
380
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mid.get());
|
|
381
|
+
OH_Drawing_TypographyPaint(&typography, canvas, 0, 0);
|
|
382
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
// No SVG context, draw normally
|
|
386
|
+
OH_Drawing_CanvasSave(canvas);
|
|
387
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mid.get());
|
|
388
|
+
OH_Drawing_TypographyPaint(&typography, canvas, 0, 0);
|
|
389
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
// No filter, draw normally
|
|
393
|
+
OH_Drawing_CanvasSave(canvas);
|
|
394
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mid.get());
|
|
395
|
+
OH_Drawing_TypographyPaint(&typography, canvas, 0, 0);
|
|
396
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
OH_Drawing_DestroyFontCollection(fontCollection);
|
|
400
|
+
OH_Drawing_DestroyTypographyHandler(typographyHandler);
|
|
401
|
+
}
|
|
402
|
+
OH_Drawing_DestroyFontCollection(fontCollection);
|
|
403
|
+
OH_Drawing_DestroyTypographyHandler(typographyHandler);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
double SvgTSpan::CalcBaselineShift(OH_Drawing_TypographyCreate *handler, OH_Drawing_TextStyle *style,
|
|
407
|
+
const OH_Drawing_Font_Metrics &fm) {
|
|
408
|
+
const double descenderDepth = fm.descent;
|
|
409
|
+
const double bottom = descenderDepth + fm.leading;
|
|
410
|
+
const double ascenderHeight = -fm.ascent + fm.leading;
|
|
411
|
+
const double top = -fm.top;
|
|
412
|
+
const double totalHeight = top + bottom;
|
|
413
|
+
double baselineShift = 0.0;
|
|
414
|
+
switch (align_) {
|
|
415
|
+
// https://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling
|
|
416
|
+
default:
|
|
417
|
+
case AlignmentBaseline::baseline:
|
|
418
|
+
// Use the dominant baseline choice of the parent.
|
|
419
|
+
// Match the box’s corresponding baseline to that of its parent.
|
|
420
|
+
baselineShift = 0;
|
|
421
|
+
break;
|
|
422
|
+
|
|
423
|
+
case AlignmentBaseline::textBottom:
|
|
424
|
+
case AlignmentBaseline::afterEdge:
|
|
425
|
+
case AlignmentBaseline::textAfterEdge:
|
|
426
|
+
// Match the bottom of the box to the bottom of the parent’s content area.
|
|
427
|
+
// text-after-edge = text-bottom
|
|
428
|
+
// text-after-edge = descender depth
|
|
429
|
+
baselineShift = -descenderDepth;
|
|
430
|
+
break;
|
|
431
|
+
|
|
432
|
+
case AlignmentBaseline::alphabetic:
|
|
433
|
+
// Match the box’s alphabetic baseline to that of its parent.
|
|
434
|
+
// alphabetic = 0
|
|
435
|
+
baselineShift = 0;
|
|
436
|
+
break;
|
|
437
|
+
|
|
438
|
+
case AlignmentBaseline::ideographic:
|
|
439
|
+
baselineShift = -descenderDepth;
|
|
440
|
+
break;
|
|
441
|
+
|
|
442
|
+
case AlignmentBaseline::middle: {
|
|
443
|
+
baselineShift = fm.xHeight / 2.0;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
case AlignmentBaseline::central:
|
|
447
|
+
baselineShift = (ascenderHeight - descenderDepth) / 2;
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case AlignmentBaseline::mathematical:
|
|
451
|
+
baselineShift = MATHEMATICAL_BASELINE_SHIFT_FACTOR * ascenderHeight;
|
|
452
|
+
break;
|
|
453
|
+
|
|
454
|
+
case AlignmentBaseline::hanging:
|
|
455
|
+
baselineShift = HANGING_BASELINE_SHIFT_FACTOR * ascenderHeight;
|
|
456
|
+
break;
|
|
457
|
+
|
|
458
|
+
case AlignmentBaseline::textTop:
|
|
459
|
+
case AlignmentBaseline::beforeEdge:
|
|
460
|
+
case AlignmentBaseline::textBeforeEdge:
|
|
461
|
+
baselineShift = ascenderHeight;
|
|
462
|
+
break;
|
|
463
|
+
|
|
464
|
+
case AlignmentBaseline::bottom:
|
|
465
|
+
baselineShift = bottom;
|
|
466
|
+
break;
|
|
467
|
+
|
|
468
|
+
case AlignmentBaseline::center:
|
|
469
|
+
baselineShift = totalHeight / 2;
|
|
470
|
+
break;
|
|
471
|
+
|
|
472
|
+
case AlignmentBaseline::top:
|
|
473
|
+
baselineShift = top;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (!baselineShift_.empty()) {
|
|
478
|
+
switch (align_) {
|
|
479
|
+
case AlignmentBaseline::top:
|
|
480
|
+
case AlignmentBaseline::bottom:
|
|
481
|
+
break;
|
|
482
|
+
|
|
483
|
+
default: {
|
|
484
|
+
if (baselineShift_ == "sub") {
|
|
485
|
+
} else if (baselineShift_ == "super") {
|
|
486
|
+
} else if (baselineShift_ == "baseline") {
|
|
487
|
+
} else {
|
|
488
|
+
baselineShift -=
|
|
489
|
+
StringUtils::FromString(baselineShift_).RelativeConvertToPx(scale_ * font_->fontSize, scale_);
|
|
490
|
+
}
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return baselineShift;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
Rect SvgTSpan::AsBounds() { return Rect(boundsX_, boundsY_, boundsWidth_, boundsHeight_); }
|
|
499
|
+
|
|
500
|
+
} // namespace svg
|
|
501
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <cmath>
|
|
10
|
+
#include "SvgGraphic.h"
|
|
11
|
+
#include "SvgText.h"
|
|
12
|
+
#include <native_drawing/drawing_text_typography.h>
|
|
13
|
+
#include "SvgTextPath.h"
|
|
14
|
+
#include "utils/GlyphContext.h"
|
|
15
|
+
#include "drawing/TypographyStyle.h"
|
|
16
|
+
#include "TextBase.h"
|
|
17
|
+
#include "FontHolderBase.h"
|
|
18
|
+
|
|
19
|
+
namespace rnoh {
|
|
20
|
+
namespace svg {
|
|
21
|
+
|
|
22
|
+
class SvgTSpan : public SvgGraphic, public TextBase, public FontHolderBase {
|
|
23
|
+
public:
|
|
24
|
+
SvgTSpan() {
|
|
25
|
+
hrefFill_ = true;
|
|
26
|
+
hrefRender_ = true;
|
|
27
|
+
passStyle_ = true;
|
|
28
|
+
inheritStyle_ = true;
|
|
29
|
+
drawTraversed_ = true;
|
|
30
|
+
}
|
|
31
|
+
~SvgTSpan() override = default;
|
|
32
|
+
|
|
33
|
+
void OnDraw(OH_Drawing_Canvas *canvas) override;
|
|
34
|
+
|
|
35
|
+
void SetTextPathRef(std::shared_ptr<SvgTextPath> textPath) { textPath_ = textPath; }
|
|
36
|
+
|
|
37
|
+
double getTextAnchorOffset(TextAnchor textAnchor, const double &textMeasure);
|
|
38
|
+
|
|
39
|
+
std::string content_;
|
|
40
|
+
|
|
41
|
+
Rect AsBounds() override;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @brief TSpan also supports the scenario with child nodes. Updates the font properties of the child node,
|
|
45
|
+
* inheriting from the parent node if the properties are empty.
|
|
46
|
+
*/
|
|
47
|
+
void OnInitStyle() override {
|
|
48
|
+
if (!font_) {
|
|
49
|
+
InitFont(GetScale());
|
|
50
|
+
}
|
|
51
|
+
for (auto &child : children_) {
|
|
52
|
+
if (auto childG = std::dynamic_pointer_cast<FontHolderBase>(child)) {
|
|
53
|
+
childG->InheritFont(font_, child->GetScale());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
/**
|
|
60
|
+
* @brief TSpan also supports the scenario with child nodes. Updates the text properties of the child node,
|
|
61
|
+
* inheriting from the parent node if the properties are empty.
|
|
62
|
+
* @param child Represents the child node object.
|
|
63
|
+
*/
|
|
64
|
+
void UpdateChildTextProps(std::shared_ptr<SvgTSpan> child) {
|
|
65
|
+
UpdateIfEmpty(child->y_, y_);
|
|
66
|
+
UpdateIfEmpty(child->x_, x_);
|
|
67
|
+
UpdateIfEmpty(child->dy_, dy_);
|
|
68
|
+
UpdateIfEmpty(child->dx_, dx_);
|
|
69
|
+
UpdateIfEmpty(child->rotate_, rotate_);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void UpdateIfEmpty(std::vector<Dimension> &childProp, const std::vector<Dimension> &parentProp) {
|
|
73
|
+
if (childProp.empty() && !parentProp.empty()) {
|
|
74
|
+
childProp = parentProp;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void DrawTextPath(OH_Drawing_Canvas *canvas);
|
|
79
|
+
|
|
80
|
+
void DrawText(OH_Drawing_Canvas *canvas);
|
|
81
|
+
|
|
82
|
+
drawing::TypographyStyle PrepareTypoStyle();
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @return true if spacing needs to be adjusted.
|
|
86
|
+
*/
|
|
87
|
+
bool AdjustSpacing(OH_Drawing_Canvas *canvas, double textMeasure, double &scaleSpacingAndGlyphs);
|
|
88
|
+
|
|
89
|
+
double CalcBaselineShift(OH_Drawing_TypographyCreate *handler, OH_Drawing_TextStyle *style,
|
|
90
|
+
const OH_Drawing_Font_Metrics &fm);
|
|
91
|
+
|
|
92
|
+
std::shared_ptr<SvgTextPath> textPath_;
|
|
93
|
+
|
|
94
|
+
double boundsWidth_ = 0;
|
|
95
|
+
double boundsHeight_ = 0;
|
|
96
|
+
double boundsX_ = 0;
|
|
97
|
+
double boundsY_ = 0;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace svg
|
|
101
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include "SvgText.h"
|
|
9
|
+
#include "drawing/TextStyle.h"
|
|
10
|
+
#include "drawing/TypographyStyle.h"
|
|
11
|
+
#include "SvgTSpan.h"
|
|
12
|
+
|
|
13
|
+
namespace rnoh {
|
|
14
|
+
namespace svg {
|
|
15
|
+
|
|
16
|
+
void SvgText::GlyphTraversal(OH_Drawing_Canvas *canvas) {
|
|
17
|
+
if (!glyphCtx_) {
|
|
18
|
+
InitGlyph(canvas, scale_);
|
|
19
|
+
}
|
|
20
|
+
for (auto const &child : children_) {
|
|
21
|
+
if (auto span = std::dynamic_pointer_cast<TextBase>(child)) {
|
|
22
|
+
span->SetGlyphContext(glyphCtx_);
|
|
23
|
+
if (!span->hasAlignmentBaseline()) {
|
|
24
|
+
span->setAlignmentBaseline(align_);
|
|
25
|
+
}
|
|
26
|
+
if (!span->hasBaselineShift()) {
|
|
27
|
+
span->setBaselineShift(baselineShift_);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void SvgText::OnDraw(OH_Drawing_Canvas *canvas) {
|
|
34
|
+
GlyphTraversal(canvas);
|
|
35
|
+
glyphCtx_->pushContext(true, shared_from_this(), x_, y_, dx_, dy_, rotate_);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
drawing::Path SvgText::AsPath() {
|
|
39
|
+
drawing::Path resultPath;
|
|
40
|
+
for (auto const &child : children_) {
|
|
41
|
+
if (auto span = std::dynamic_pointer_cast<SvgTSpan>(child)) {
|
|
42
|
+
std::string text = span->content_;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return resultPath;
|
|
46
|
+
}
|
|
47
|
+
} // namespace svg
|
|
48
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include "SvgGroup.h"
|
|
10
|
+
#include "TextBase.h"
|
|
11
|
+
|
|
12
|
+
namespace rnoh {
|
|
13
|
+
namespace svg {
|
|
14
|
+
|
|
15
|
+
class SvgText : public SvgGroup, public TextBase {
|
|
16
|
+
public:
|
|
17
|
+
SvgText() = default;
|
|
18
|
+
~SvgText() override = default;
|
|
19
|
+
|
|
20
|
+
void OnDraw(OH_Drawing_Canvas *canvas) override;
|
|
21
|
+
|
|
22
|
+
drawing::Path AsPath() override;
|
|
23
|
+
|
|
24
|
+
private:
|
|
25
|
+
void GlyphTraversal(OH_Drawing_Canvas *canvas);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
} // namespace svg
|
|
29
|
+
} // namespace rnoh
|