react-native-nano-icons 0.2.1 → 1.0.0-beta.2
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/LICENSES.md +40 -0
- package/README.md +165 -12
- package/android/build.gradle +8 -1
- package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
- package/android/src/main/java/com/nanoicons/NanoIconView.kt +103 -19
- package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +42 -18
- package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +72 -11
- package/android/src/main/jni/CMakeLists.txt +38 -0
- package/android/src/main/jni/RNNanoIconsSpec.h +19 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h +11 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +46 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +41 -0
- package/ios/NanoIconFontResolver.h +5 -0
- package/ios/NanoIconFontResolver.mm +32 -0
- package/ios/NanoIconInlineBaseline.h +4 -0
- package/ios/NanoIconInlineBaseline.mm +190 -0
- package/ios/NanoIconView.h +1 -4
- package/ios/NanoIconView.mm +178 -162
- package/ios/NanoIconsFontLoader.mm +10 -32
- package/lib/commonjs/cli/build.d.ts +16 -3
- package/lib/commonjs/cli/build.js +108 -25
- package/lib/commonjs/cli/buildSymbols.d.ts +26 -0
- package/lib/commonjs/cli/buildSymbols.js +134 -0
- package/lib/commonjs/cli/config.d.ts +4 -2
- package/lib/commonjs/cli/config.js +4 -4
- package/lib/commonjs/cli/expoConfig.d.ts +6 -2
- package/lib/commonjs/cli/expoConfig.js +37 -13
- package/lib/commonjs/cli/index.d.ts +7 -5
- package/lib/commonjs/cli/index.js +27 -14
- package/lib/commonjs/cli/link.d.ts +19 -3
- package/lib/commonjs/cli/link.js +311 -45
- package/lib/commonjs/cli/logger.js +9 -7
- package/lib/commonjs/metro/fontRebuildWatcher.d.ts +62 -0
- package/lib/commonjs/metro/fontRebuildWatcher.js +174 -0
- package/lib/commonjs/metro/index.d.ts +35 -0
- package/lib/commonjs/metro/index.js +92 -0
- package/lib/commonjs/metro/symbolRebuildWatcher.d.ts +19 -0
- package/lib/commonjs/metro/symbolRebuildWatcher.js +76 -0
- package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
- package/lib/commonjs/plugin/src/buildFonts.js +5 -15
- package/lib/commonjs/plugin/src/buildSymbols.d.ts +3 -0
- package/lib/commonjs/plugin/src/buildSymbols.js +18 -0
- package/lib/commonjs/plugin/src/index.d.ts +2 -2
- package/lib/commonjs/plugin/src/index.js +10 -4
- package/lib/commonjs/plugin/src/types.d.ts +44 -3
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +8 -0
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +29 -0
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +8 -0
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +37 -0
- package/lib/commonjs/scripts/cli.js +64 -23
- package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/arcs.js +136 -0
- package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
- package/lib/commonjs/src/core/flatten/document.js +164 -0
- package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
- package/lib/commonjs/src/core/flatten/dom.js +221 -0
- package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
- package/lib/commonjs/src/core/flatten/element.js +97 -0
- package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
- package/lib/commonjs/src/core/flatten/geometry.js +85 -0
- package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/index.js +11 -0
- package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
- package/lib/commonjs/src/core/flatten/inherit.js +249 -0
- package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
- package/lib/commonjs/src/core/flatten/path.js +439 -0
- package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
- package/lib/commonjs/src/core/flatten/pathops.js +236 -0
- package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
- package/lib/commonjs/src/core/flatten/shape.js +415 -0
- package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
- package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
- package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
- package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
- package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
- package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
- package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
- package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
- package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
- package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
- package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
- package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
- package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
- package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
- package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages.js +40 -0
- package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
- package/lib/commonjs/src/core/flatten/transform.js +221 -0
- package/lib/commonjs/src/core/font/compile.d.ts +2 -1
- package/lib/commonjs/src/core/font/compile.js +19 -7
- package/lib/commonjs/src/core/font/metrics.js +7 -0
- package/lib/commonjs/src/core/font/quadratic.d.ts +2 -0
- package/lib/commonjs/src/core/font/quadratic.js +33 -0
- package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
- package/lib/commonjs/src/core/glyph/merge.js +59 -0
- package/lib/commonjs/src/core/glyph/parse.d.ts +27 -0
- package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
- package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
- package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
- package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
- package/lib/commonjs/src/core/glyph/validate.js +33 -0
- package/lib/commonjs/src/core/pathkit/contours.d.ts +75 -0
- package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +79 -301
- package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
- package/lib/commonjs/src/core/pathkit/evenodd.js +37 -0
- package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
- package/lib/commonjs/src/core/pathkit/load.js +26 -0
- package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
- package/lib/commonjs/src/core/pathkit/types.js +2 -0
- package/lib/commonjs/src/core/pathkit/winding.d.ts +4 -0
- package/lib/commonjs/src/core/pathkit/winding.js +59 -0
- package/lib/commonjs/src/core/pipeline/config.d.ts +2 -0
- package/lib/commonjs/src/core/pipeline/config.js +6 -0
- package/lib/commonjs/src/core/pipeline/iconPool.d.ts +14 -0
- package/lib/commonjs/src/core/pipeline/iconPool.js +109 -0
- package/lib/commonjs/src/core/pipeline/index.d.ts +5 -3
- package/lib/commonjs/src/core/pipeline/index.js +8 -5
- package/lib/commonjs/src/core/pipeline/prepare.d.ts +20 -0
- package/lib/commonjs/src/core/pipeline/prepare.js +74 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +25 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.js +81 -0
- package/lib/commonjs/src/core/pipeline/prepareSvg.d.ts +6 -0
- package/lib/commonjs/src/core/pipeline/prepareSvg.js +11 -0
- package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +26 -0
- package/lib/commonjs/src/core/pipeline/prepareSymbol.js +79 -0
- package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
- package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
- package/lib/commonjs/src/core/pipeline/preparedSvgCache.d.ts +6 -0
- package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +44 -0
- package/lib/commonjs/src/core/pipeline/runFontPipeline.d.ts +22 -0
- package/lib/commonjs/src/core/pipeline/runFontPipeline.js +111 -0
- package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +54 -0
- package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +161 -0
- package/lib/commonjs/src/core/symbols/contents.d.ts +2 -0
- package/lib/commonjs/src/core/symbols/contents.js +15 -0
- package/lib/commonjs/src/core/symbols/knockout.d.ts +3 -0
- package/lib/commonjs/src/core/symbols/knockout.js +51 -0
- package/lib/commonjs/src/core/symbols/layers.d.ts +36 -0
- package/lib/commonjs/src/core/symbols/layers.js +182 -0
- package/lib/commonjs/src/core/symbols/template.d.ts +22 -0
- package/lib/commonjs/src/core/symbols/template.js +140 -0
- package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +11 -0
- package/lib/commonjs/src/core/symbols/vectorDrawable.js +66 -0
- package/lib/commonjs/src/core/types.d.ts +3 -92
- package/lib/commonjs/src/utils/fingerPrint.d.ts +19 -1
- package/lib/commonjs/src/utils/fingerPrint.js +29 -3
- package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
- package/lib/commonjs/src/utils/fontIdentity.js +24 -0
- package/lib/commonjs/src/utils/naming.d.ts +10 -0
- package/lib/commonjs/src/utils/naming.js +49 -0
- package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
- package/lib/commonjs/src/utils/packageVersion.js +37 -0
- package/lib/commonjs/src/utils/parse.d.ts +0 -1
- package/lib/commonjs/src/utils/parse.js +0 -8
- package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
- package/lib/commonjs/src/utils/svgPatterns.js +46 -0
- package/lib/module/const/codegenPrimitives.js +1 -2
- package/lib/module/const/colors.js +1 -2
- package/lib/module/createNanoIconsSet.js +1 -2
- package/lib/module/createNanoIconsSet.native.js +38 -28
- package/lib/module/createNanoIconsSet.shared.js +15 -9
- package/lib/module/createNanoIconsSet.web.js +22 -8
- package/lib/module/devServerFont.js +30 -0
- package/lib/module/devServerFont.web.js +25 -0
- package/lib/module/fontIntegrity.js +99 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.node.js +1 -2
- package/lib/module/loadDynamicFont.js +20 -10
- package/lib/module/nativeFontLoader.js +3 -0
- package/lib/module/nativeFontLoader.web.js +3 -0
- package/lib/module/specs/NanoIconViewNativeComponent.ts +9 -6
- package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
- package/lib/module/symbols/index.android.js +42 -0
- package/lib/module/symbols/index.ios.js +35 -0
- package/lib/module/symbols/index.js +35 -0
- package/lib/module/symbols/index.native.js +12 -0
- package/lib/module/symbols/types.js +1 -0
- package/lib/module/types.js +1 -2
- package/lib/module/utils/fingerPrint.js +20 -5
- package/lib/module/utils/fontIdentity.js +20 -0
- package/lib/module/utils/glyphRuntime.js +36 -3
- package/lib/module/utils/naming.js +46 -0
- package/lib/module/utils/packageVersion.js +29 -0
- package/lib/module/utils/parse.js +1 -9
- package/lib/module/utils/runtimeLog.js +12 -0
- package/lib/module/utils/shallowEqualColor.js +1 -2
- package/lib/module/utils/svgPatterns.js +49 -0
- package/lib/module/utils/validateLayerColor.js +24 -0
- package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
- package/lib/typescript/src/core/flatten/document.d.ts +36 -0
- package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
- package/lib/typescript/src/core/flatten/element.d.ts +13 -0
- package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
- package/lib/typescript/src/core/flatten/index.d.ts +3 -0
- package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
- package/lib/typescript/src/core/flatten/path.d.ts +20 -0
- package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
- package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
- package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
- package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
- package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
- package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
- package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
- package/lib/typescript/src/core/glyph/parse.d.ts +28 -0
- package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
- package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
- package/lib/typescript/src/core/pathkit/contours.d.ts +76 -0
- package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
- package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
- package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
- package/lib/typescript/src/core/pathkit/winding.d.ts +5 -0
- package/lib/typescript/src/core/symbols/contents.d.ts +3 -0
- package/lib/typescript/src/core/symbols/knockout.d.ts +4 -0
- package/lib/typescript/src/core/symbols/layers.d.ts +37 -0
- package/lib/typescript/src/core/symbols/template.d.ts +23 -0
- package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +12 -0
- package/lib/typescript/src/core/types.d.ts +3 -92
- package/lib/typescript/src/devServerFont.d.ts +4 -0
- package/lib/typescript/src/devServerFont.web.d.ts +4 -0
- package/lib/typescript/src/fontIntegrity.d.ts +24 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/loadDynamicFont.d.ts +1 -0
- package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
- package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
- package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +6 -5
- package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
- package/lib/typescript/src/symbols/index.android.d.ts +33 -0
- package/lib/typescript/src/symbols/index.d.ts +31 -0
- package/lib/typescript/src/symbols/index.ios.d.ts +31 -0
- package/lib/typescript/src/symbols/index.native.d.ts +8 -0
- package/lib/typescript/src/symbols/types.d.ts +24 -0
- package/lib/typescript/src/types.d.ts +7 -0
- package/lib/typescript/src/utils/fingerPrint.d.ts +19 -1
- package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
- package/lib/typescript/src/utils/glyphRuntime.d.ts +3 -1
- package/lib/typescript/src/utils/naming.d.ts +11 -0
- package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
- package/lib/typescript/src/utils/parse.d.ts +0 -1
- package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
- package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
- package/lib/typescript/src/utils/validateLayerColor.d.ts +3 -0
- package/metro.js +1 -0
- package/package.json +37 -11
- package/react-native-nano-icons.podspec +4 -1
- package/react-native.config.js +10 -0
- package/src/specs/NanoIconViewNativeComponent.ts +9 -6
- package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
- package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
- package/lib/commonjs/src/core/pipeline/managers.js +0 -104
- package/lib/commonjs/src/core/pipeline/run.d.ts +0 -14
- package/lib/commonjs/src/core/pipeline/run.js +0 -189
- package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
- package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
- package/lib/module/const/codegenPrimitives.js.map +0 -1
- package/lib/module/const/colors.js.map +0 -1
- package/lib/module/core/font/compile.js +0 -81
- package/lib/module/core/font/compile.js.map +0 -1
- package/lib/module/core/font/metrics.js +0 -37
- package/lib/module/core/font/metrics.js.map +0 -1
- package/lib/module/core/pipeline/config.js +0 -20
- package/lib/module/core/pipeline/config.js.map +0 -1
- package/lib/module/core/pipeline/index.js +0 -5
- package/lib/module/core/pipeline/index.js.map +0 -1
- package/lib/module/core/pipeline/managers.js +0 -94
- package/lib/module/core/pipeline/managers.js.map +0 -1
- package/lib/module/core/pipeline/run.js +0 -204
- package/lib/module/core/pipeline/run.js.map +0 -1
- package/lib/module/core/shims/pathops.py +0 -181
- package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
- package/lib/module/core/svg/layers.js +0 -85
- package/lib/module/core/svg/layers.js.map +0 -1
- package/lib/module/core/svg/svg_dom.js +0 -170
- package/lib/module/core/svg/svg_dom.js.map +0 -1
- package/lib/module/core/svg/svg_pathops.js +0 -750
- package/lib/module/core/svg/svg_pathops.js.map +0 -1
- package/lib/module/core/tsconfig.json +0 -32
- package/lib/module/core/types.js +0 -2
- package/lib/module/core/types.js.map +0 -1
- package/lib/module/createNanoIconsSet.js.map +0 -1
- package/lib/module/createNanoIconsSet.native.js.map +0 -1
- package/lib/module/createNanoIconsSet.shared.js.map +0 -1
- package/lib/module/createNanoIconsSet.web.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.node.js.map +0 -1
- package/lib/module/loadDynamicFont.js.map +0 -1
- package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/fingerPrint.js.map +0 -1
- package/lib/module/utils/glyphRuntime.js.map +0 -1
- package/lib/module/utils/parse.js.map +0 -1
- package/lib/module/utils/shallowEqualColor.js.map +0 -1
- package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
- package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
- package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
- package/lib/typescript/cli/build.d.ts +0 -32
- package/lib/typescript/cli/build.d.ts.map +0 -1
- package/lib/typescript/cli/link.d.ts +0 -12
- package/lib/typescript/cli/link.d.ts.map +0 -1
- package/lib/typescript/cli/logger.d.ts +0 -28
- package/lib/typescript/cli/logger.d.ts.map +0 -1
- package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
- package/lib/typescript/src/const/colors.d.ts.map +0 -1
- package/lib/typescript/src/core/font/compile.d.ts +0 -21
- package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
- package/lib/typescript/src/core/font/metrics.d.ts +0 -2
- package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
- package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
- package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
- package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
- package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
- package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
- package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
- package/lib/typescript/src/core/types.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/index.node.d.ts.map +0 -1
- package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
- package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
- package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
- package/lib/typescript/src/utils/parse.d.ts.map +0 -1
- package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
- package/plugin/src/buildFonts.ts +0 -42
- package/plugin/src/index.ts +0 -21
- package/plugin/src/types.ts +0 -42
- package/plugin/src/withNanoIconsFontLinking.ts +0 -136
- package/plugin/tsconfig.json +0 -9
- package/scripts/cli.ts +0 -63
- package/scripts/tsconfig.json +0 -25
- package/src/const/colors.ts +0 -150
- package/src/core/font/compile.ts +0 -99
- package/src/core/font/metrics.ts +0 -44
- package/src/core/pipeline/config.ts +0 -25
- package/src/core/pipeline/index.ts +0 -3
- package/src/core/pipeline/managers.ts +0 -132
- package/src/core/pipeline/run.ts +0 -274
- package/src/core/shims/pathops.py +0 -181
- package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
- package/src/core/svg/layers.ts +0 -110
- package/src/core/svg/svg_dom.ts +0 -194
- package/src/core/svg/svg_pathops.ts +0 -1040
- package/src/core/tsconfig.json +0 -32
- package/src/core/types.ts +0 -157
- package/src/createNanoIconsSet.native.tsx +0 -192
- package/src/createNanoIconsSet.shared.tsx +0 -174
- package/src/createNanoIconsSet.tsx +0 -20
- package/src/createNanoIconsSet.web.tsx +0 -109
- package/src/index.node.ts +0 -14
- package/src/index.ts +0 -6
- package/src/loadDynamicFont.ts +0 -162
- package/src/types.ts +0 -31
- package/src/utils/fingerPrint.ts +0 -20
- package/src/utils/glyphRuntime.ts +0 -46
- package/src/utils/parse.ts +0 -67
- package/src/utils/shallowEqualColor.ts +0 -17
package/LICENSES.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This project bundles or depends on the following third-party software:
|
|
4
|
+
|
|
5
|
+
1. @react-native-vector-icons/common
|
|
6
|
+
License: MIT
|
|
7
|
+
Source: https://github.com/oblador/react-native-vector-icons
|
|
8
|
+
|
|
9
|
+
2. fonteditor-core
|
|
10
|
+
License: MIT
|
|
11
|
+
Source: https://www.npmjs.com/package/fonteditor-core
|
|
12
|
+
|
|
13
|
+
3. @xmldom/xmldom
|
|
14
|
+
License: MIT
|
|
15
|
+
Source: https://github.com/xmldom/xmldom
|
|
16
|
+
|
|
17
|
+
4. minimist
|
|
18
|
+
License: MIT
|
|
19
|
+
Source: https://github.com/minimistjs/minimist
|
|
20
|
+
|
|
21
|
+
5. svg2ttf
|
|
22
|
+
License: MIT
|
|
23
|
+
Source: https://www.npmjs.com/package/svg2ttf
|
|
24
|
+
|
|
25
|
+
6. pathkit-wasm
|
|
26
|
+
License: BSD-3-Clause
|
|
27
|
+
Source: https://www.npmjs.com/package/pathkit-wasm
|
|
28
|
+
|
|
29
|
+
7. picosvg
|
|
30
|
+
License: Apache-2.0
|
|
31
|
+
Source: https://github.com/googlefonts/picosvg
|
|
32
|
+
Note: `src/core/flatten/` is a TypeScript port of picosvg
|
|
33
|
+
(Copyright 2020 Google LLC), redistributed under the Apache License,
|
|
34
|
+
Version 2.0. This entry is the attribution notice for that port.
|
|
35
|
+
|
|
36
|
+
Full license texts:
|
|
37
|
+
|
|
38
|
+
- MIT License: https://opensource.org/licenses/MIT
|
|
39
|
+
- BSD 3-Clause License: https://opensource.org/licenses/BSD-3-Clause
|
|
40
|
+
- Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ That’s it 🔬⚡️
|
|
|
40
40
|
- [🧩 Platforms Supported](#-platforms-supported)
|
|
41
41
|
- [🚀 Quick Start](#-quick-start)
|
|
42
42
|
- [🎨 Multicolor Icons](#-multicolor-icons)
|
|
43
|
+
- [🧭 Native Symbol Support](#-native-symbol-support)
|
|
43
44
|
- [📊 Performance](#-performance)
|
|
44
45
|
- [⚠️ Known Limitations](#%EF%B8%8F-known-limitations)
|
|
45
46
|
- [🔧 Font Generation Pipeline](#-font-generation-pipeline)
|
|
@@ -116,11 +117,12 @@ The plugin accepts an object with an `iconSets` array, allowing you to generate
|
|
|
116
117
|
| Property | Type | Required | Default | Description |
|
|
117
118
|
| :------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------- |
|
|
118
119
|
| `inputDir` | `string` | **Yes** | — | Path to the directory containing your `.svg` files (e.g., `./assets/icons/ui`). |
|
|
119
|
-
| `fontFamily` | `string` | No | Folder Name | The name of the generated
|
|
120
|
+
| `fontFamily` | `string` | No | Folder Name | The name of the generated `.ttf` and `.glyphmap.json` files. If omitted, the name of the `inputDir` folder is used (e.g., `ui`). The font family registered at runtime is `glyphMap.m.f`, which appends a short build hash (e.g. `ui-1a2b3c4d`) so every build of the set is distinct. |
|
|
120
121
|
| `outputDir` | `string` | No | `../nanoicons` | Path where the `.ttf` and `.json` artifacts will be saved. Defaults to a sibling `nanoicons` folder relative to the input. |
|
|
121
122
|
| `upm` | `number` | No | `1024` | Units Per Em. Defines the resolution of the font grid. |
|
|
122
123
|
| `startUnicode` | `string` | No | `0xe900` | The starting Hex Unicode point for the first icon glyph. |
|
|
123
124
|
| `linking` | `'static' \| 'dynamic'` | No | `'static'` | Delivery mode for the generated TTF. `'static'` bundles it into the native app. `'dynamic'` excludes it from native linking so the host app can deliver it at runtime (i.e. via OTA update). See [Dynamic linking](#dynamic-linking-expo-ota-updates-support). |
|
|
125
|
+
| `web` | `boolean` | No | `false` | Also emit `<fontFamily>.woff2` into `outputDir`, rebuilt together with the `.ttf` on every change. It is never linked natively; link it on web like any other web font. |
|
|
124
126
|
|
|
125
127
|
<details>
|
|
126
128
|
<summary>Default Dir Path Behavior</summary>
|
|
@@ -135,7 +137,7 @@ The plugin accepts an object with an `iconSets` array, allowing you to generate
|
|
|
135
137
|
|
|
136
138
|
Bare apps don't have a prebuild step, so you run the same pipeline via the CLI:
|
|
137
139
|
|
|
138
|
-
1. **Config** – Add a `.nanoicons.json` with the same `iconSets` shape as the Expo plugin (see options above).
|
|
140
|
+
1. **Config** – Add a `.nanoicons.json` with the same `iconSets` shape as the Expo plugin (see options above). Paths in it are relative to the app root.
|
|
139
141
|
<details>
|
|
140
142
|
<summary>.nanoicons.json example</summary>
|
|
141
143
|
|
|
@@ -154,20 +156,48 @@ Bare apps don't have a prebuild step, so you run the same pipeline via the CLI:
|
|
|
154
156
|
2. **Build and link** – From the app root run:
|
|
155
157
|
|
|
156
158
|
```sh
|
|
157
|
-
npx react-native-nano-icons
|
|
159
|
+
npx react-native-nano-icons
|
|
158
160
|
```
|
|
159
161
|
|
|
162
|
+
If the config lives elsewhere in the app, pass it: `--path path/to/.nanoicons.json`. From outside the app (for example a monorepo root), pass the app folder: `--path apps/mobile`. A folder with a `package.json` counts as the app, so the CLI reads the config, builds and links there.
|
|
163
|
+
|
|
160
164
|
This works exactly like the config plugin, removing any necessity for manual Xcode/Android Studio font linking steps.
|
|
161
165
|
|
|
162
166
|
> [!TIP]
|
|
163
167
|
> Run `EXPO_DEBUG=1 npx expo prebuild` or `npx react-native-nano-icons --verbose` to get font build-time logs.
|
|
164
168
|
|
|
169
|
+
### 4. Add the Metro plugin (recommended)
|
|
170
|
+
|
|
171
|
+
Add the plugin to your Metro config to get hot reload for your icons: edit an SVG and the running dev app picks up the new glyph, with no native rebuild or CLI run.
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
// metro.config.js
|
|
175
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
176
|
+
// or require('@react-native/metro-config') by React Native Community
|
|
177
|
+
const { withNanoIcons } = require('react-native-nano-icons/metro');
|
|
178
|
+
|
|
179
|
+
const config = getDefaultConfig(__dirname);
|
|
180
|
+
|
|
181
|
+
// Your modifications to the config
|
|
182
|
+
|
|
183
|
+
module.exports = withNanoIcons(config);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Production builds are not affected — the fonts are linked exactly as configured, static or dynamic. The plugin uses the config from the steps above to speed up development process and experience.
|
|
187
|
+
|
|
188
|
+
> [!NOTE]
|
|
189
|
+
> Hot reload needs a development build; Expo Go cannot register fonts at runtime. Before a web export, run the font step as usual (CLI or `expo prebuild`).
|
|
190
|
+
|
|
165
191
|
> [!NOTE]
|
|
166
|
-
>
|
|
167
|
-
>
|
|
168
|
-
> In [Expo Go](https://expo.dev/go), icons are rendered using a regular `<Text>` fallback so you can iterate quickly. You will need to link the font manually via the already included [`expo-font` library](https://docs.expo.dev/versions/latest/sdk/font/). [Once you move to a development build](https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/), the library automatically switches to the native component implementation. Remember to remove any `expo-font`-related icon font setup after the switch.
|
|
192
|
+
> In [Expo Go](https://expo.dev/go), icons are rendered using a regular `<Text>` fallback so you can iterate quickly. You will need to link the font manually via the already included [`expo-font` library](https://docs.expo.dev/versions/latest/sdk/font/), keyed by `glyphMap.m.f`. [Once you move to a development build](https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/), the library automatically switches to the native component implementation. Remember to remove any `expo-font`-related icon font setup after the switch.
|
|
169
193
|
|
|
170
|
-
|
|
194
|
+
> [!NOTE]
|
|
195
|
+
> With `web: true`, the `my-icons` set also gets `assets/icons/nanoicons/my-icons.woff2` next to its `.ttf`. Link it on web like any regular font, named `my-icons`. If you want to `require()` it through Metro (e.g. with `expo-font`), add this to `metro.config.js`:
|
|
196
|
+
> ```js
|
|
197
|
+
> config.resolver.assetExts.push("woff2");
|
|
198
|
+
> ```
|
|
199
|
+
|
|
200
|
+
### 5. Use
|
|
171
201
|
|
|
172
202
|
```TypeScript
|
|
173
203
|
import { View, Text } from 'react-native'
|
|
@@ -198,6 +228,7 @@ export default function App() {
|
|
|
198
228
|
| `name` | `string` | **(required)** | Icon name — corresponds to the original SVG filename. Fully typed from the glyphmap. |
|
|
199
229
|
| `size` | `number` | `12` | Icon size in points. |
|
|
200
230
|
| `color` | `ColorValue \| ColorValue[]` | Glyphmap defaults | Single color applied to all layers, or per-layer color array. If the array is shorter than the number of layers, the last color is repeated. |
|
|
231
|
+
| `tintMode` | `'all' \| 'currentColor'` | `'all'` | Which layers `color` applies to: every layer, or only those annotated with `currentColor` (an icon without any keeps its original colors). |
|
|
201
232
|
| `allowFontScaling` | `boolean` | `true` | Whether the icon size respects the system accessibility font scale. |
|
|
202
233
|
| `style` | `ViewStyle` | — | Style applied to the icon container. |
|
|
203
234
|
| `accessible` | `boolean` | — | Override the default accessibility behavior. |
|
|
@@ -242,11 +273,11 @@ export const Icon = createNanoIconSet(glyphMap, require("./dynamic-ota-icons.ttf
|
|
|
242
273
|
> [!NOTE]
|
|
243
274
|
> In [Expo Go](https://expo.dev/go), the native font loader is unavailable, but you can still see real icons by loading the font manually via [`expo-font`](https://docs.expo.dev/versions/latest/sdk/font/) — use the value of `glyphMap.m.f` as the family name key. [Once you move to a development build](https://docs.expo.dev/develop/development-builds/expo-go-to-dev-build/), the library registers the font automatically and you can remove the `expo-font` setup.
|
|
244
275
|
|
|
245
|
-
> If a dynamic glyphmap gets no font, icons render
|
|
276
|
+
> If a dynamic glyphmap gets no font, its icons render blank until one is registered under `glyphMap.m.f` (with a dev warning).
|
|
246
277
|
|
|
247
|
-
###
|
|
278
|
+
### 6. Font Regeneration
|
|
248
279
|
|
|
249
|
-
**The build script detects changes in path and contents of the SVGs** in your input directory based on a fingerprint hash. If anything changes (file names, SVG attributes/nodes) or the output font/glyphmap files are deleted, the icon set is regenerated during `prebuild` or manual script run.
|
|
280
|
+
**The build script detects changes in path and contents of the SVGs** in your input directory, in the set's config (`upm`, `safeZone`, `startUnicode`) and in the library version or the versions of the packages it builds fonts with, based on a fingerprint hash. If anything changes (file names, SVG attributes/nodes, config, an upgrade of `react-native-nano-icons` or of a font-building dependency) or the output font/glyphmap files are deleted, the icon set is regenerated during `prebuild` or manual script run. The first 8 characters of the fingerprint become part of the runtime font family (`glyphMap.m.f`), so a rebuilt set never clashes with a previous build that is still bundled in the app.
|
|
250
281
|
|
|
251
282
|
### Regenerating dynamic fonts only (useful for an OTA update) ☁️
|
|
252
283
|
|
|
@@ -254,7 +285,7 @@ When your `dynamic` icons change and you want to ship them via OTA update, you d
|
|
|
254
285
|
|
|
255
286
|
```sh
|
|
256
287
|
# run from your app root
|
|
257
|
-
npx react-native-nano-icons --
|
|
288
|
+
npx react-native-nano-icons --dynamic
|
|
258
289
|
```
|
|
259
290
|
|
|
260
291
|
|
|
@@ -264,10 +295,34 @@ npx react-native-nano-icons --path path/to/.nanoicons.json --dynamic
|
|
|
264
295
|
> # run from your app root
|
|
265
296
|
> npx react-native-nano-icons --dynamic --app-config
|
|
266
297
|
> ```
|
|
267
|
-
> This reads your config directly from `app.json` / `app.config.js` / `app.config.ts` (no separate `.nanoicons.json` needed).
|
|
298
|
+
> This reads your config directly from `app.json` / `app.config.js` / `app.config.ts` (no separate `.nanoicons.json` needed). In a monorepo, run it from the app's folder or point it there with `--path <app root>`.
|
|
268
299
|
|
|
269
300
|
The CLI rebuilds only the sets defined with `linking: "dynamic"`, and skips all native linking. Commit the updated `.ttf` and `.glyphmap.json` and push your OTA update as usual ☁️ 🚀
|
|
270
301
|
|
|
302
|
+
> [!NOTE]
|
|
303
|
+
> A full (non `--dynamic`) run keeps the native projects in sync with the config: the fonts linked natively are exactly the products of the current static sets. Copies of sets that were switched to dynamic, removed from the config, or rebuilt under a new fingerprint are deleted from `ios/nanoicons-fonts`, `UIAppFonts`, and `android/app/src/main/assets/fonts`. Fonts you added yourself are left alone.
|
|
304
|
+
|
|
305
|
+
### Font integrity check
|
|
306
|
+
|
|
307
|
+
Every icon build is deterministic: the same SVGs, config and toolchain produce the same font identity, and the glyphmap refers to that exact font. At startup the library checks, once per icon set, that this font is available to the renderer, so the app always renders the font its glyphmap refers to. The check fails when the glyphmap in the JS bundle and the font in the app come from different builds, for example after an OTA update that changed icons without a new binary. In development a warning is printed. In every build the issue is recorded:
|
|
308
|
+
|
|
309
|
+
```TypeScript
|
|
310
|
+
import { addFontIntegrityListener, getFontIntegrityIssues } from "react-native-nano-icons";
|
|
311
|
+
|
|
312
|
+
addFontIntegrityListener((issue, status) => {
|
|
313
|
+
// status: "found" | "resolved"
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
getFontIntegrityIssues(); // current issues
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
- `"found"`: the set's font is missing or out of date, so its icons render blank. A listener added later receives the current issues immediately.
|
|
320
|
+
- `"resolved"`: a font for that set loaded later (for example through `loadFont`), and the issue was dropped.
|
|
321
|
+
|
|
322
|
+
Forward `"found"` issues to your error monitoring (e.g. Sentry) to catch a bad OTA update.
|
|
323
|
+
|
|
324
|
+
For every scenario and its message, see [FONT_INTEGRITY.md](https://github.com/software-mansion-labs/react-native-nano-icons/blob/main/packages/react-native-nano-icons/docs/FONT_INTEGRITY.md).
|
|
325
|
+
|
|
271
326
|
---
|
|
272
327
|
|
|
273
328
|
## 🎨 Multicolor Icons
|
|
@@ -297,7 +352,10 @@ This makes the library well-suited for multicolor icons like country flags, bran
|
|
|
297
352
|
|
|
298
353
|
- **Single string** — applies to all layers.
|
|
299
354
|
- **Array** — each element maps to a layer. If the array is shorter than the number of layers, the last color is repeated.
|
|
355
|
+
- **`tintMode="currentColor"`** — `color` applies only to layers annotated with `currentColor` in the SVG, so hardcoded colors (flags, logos) are kept. An array maps onto those layers in order, with the last color repeated. An icon with no `currentColor` layers renders in its original colors.
|
|
300
356
|
- **Omitted** — uses the original SVG colors stored in the glyphmap.
|
|
357
|
+
- **Platform colors** — `PlatformColor(...)` and `DynamicColorIOS(...)` work in both forms and follow system appearance changes natively, without a re-render.
|
|
358
|
+
- **Invalid colors** — an unparseable color string falls back to black. In development an error names the icon and layer.
|
|
301
359
|
|
|
302
360
|
An SVG with many distinct colors (e.g., a detailed vector image with 50 colors) produces at least 50 glyph layers. Each layer is a lightweight text glyph, so this is fine for typical icons (3–10 colors). For highly complex illustrations with dozens of colors, consider using `expo-image` instead.
|
|
303
361
|
|
|
@@ -308,6 +366,101 @@ Since all of that is actually simple text, you can use your beautiful multicolor
|
|
|
308
366
|
|
|
309
367
|
---
|
|
310
368
|
|
|
369
|
+
## 🧭 Native Symbol Support
|
|
370
|
+
|
|
371
|
+
Native tab bars draw their icons themselves, so they can't host a React component like `<Icon>`. For them, the same SVGs are forged into native assets loaded by name: custom symbols in your iOS `Images.xcassets` and Android `VectorDrawable`s. `nativeNanoSymbol('home')` then returns an icon react-navigation accepts wherever it takes an `Icon`.
|
|
372
|
+
|
|
373
|
+
> [!NOTE]
|
|
374
|
+
> Native symbols are **iOS and Android only** and need `react-native-screens` 4.29+ with react-navigation 8. They are always bundled natively, so [dynamic linking](#dynamic-linking-expo-ota-updates-support) is not available for them.
|
|
375
|
+
|
|
376
|
+
### 1. Configure
|
|
377
|
+
|
|
378
|
+
Add a `symbolSets` array next to `iconSets` in your `.nanoicons.json` (or the Expo plugin options):
|
|
379
|
+
|
|
380
|
+
```JSON
|
|
381
|
+
{
|
|
382
|
+
"symbolSets": [{ "inputDir": "./assets/tabicons" }]
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
<details>
|
|
387
|
+
<summary><u>All symbolSets Entry Options</u></summary>
|
|
388
|
+
|
|
389
|
+
| Property | Type | Required | Default | Description |
|
|
390
|
+
| :----------- | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------- |
|
|
391
|
+
| `inputDir` | `string` | **Yes** | — | Path to the directory containing your `.svg` files. |
|
|
392
|
+
| `name` | `string` | No | Folder name | Set name, used for output filenames and the generated typed manifest. |
|
|
393
|
+
| `prefix` | `string` | No | `nano` | Symbol-name prefix: `home.svg` → `nano.home` (iOS) / `nano_home` (Android). |
|
|
394
|
+
| `outputDir` | `string` | No | `../nanoicons` | Path where the generated artifacts are written. Defaults to a sibling `nanoicons` folder. |
|
|
395
|
+
|
|
396
|
+
</details>
|
|
397
|
+
|
|
398
|
+
### 2. Build and link
|
|
399
|
+
|
|
400
|
+
The same [build / prebuild step](#3-configure) that generates your fonts forges and links the symbols. Then rebuild the native app: symbols are compiled into the binary, so new or changed SVGs show up only after a native rebuild.
|
|
401
|
+
|
|
402
|
+
<details>
|
|
403
|
+
<summary><u>What gets generated</u></summary>
|
|
404
|
+
|
|
405
|
+
- **iOS** – one `<prefix>.<name>.symbolset` per SVG in your app's `Images.xcassets`.
|
|
406
|
+
- **Android** – two drawables per SVG in `res/drawable/`: `<prefix>_<name>` (monochrome) and `<prefix>_<name>_original`.
|
|
407
|
+
- **`outputDir`** – `<set>.symbols.d.ts`, a typed manifest that makes `nativeNanoSymbol` names (and react-navigation's `SFSymbolNames`) type-check from your filenames. Make sure your `tsconfig` includes it.
|
|
408
|
+
|
|
409
|
+
</details>
|
|
410
|
+
|
|
411
|
+
### 3. Use
|
|
412
|
+
|
|
413
|
+
Return `nativeNanoSymbol(filename)` from any react-navigation icon option. Every symbol has two looks: `monochrome` (a silhouette in the bar's tint, the default) and `original` (the SVG's own colors).
|
|
414
|
+
|
|
415
|
+
```TypeScript
|
|
416
|
+
import { nativeNanoSymbol } from 'react-native-nano-icons/symbols';
|
|
417
|
+
|
|
418
|
+
// monochrome — painted in the bar's tint
|
|
419
|
+
tabBarIcon: () => nativeNanoSymbol('message'),
|
|
420
|
+
|
|
421
|
+
// original — the icon's own colors while focused, the bar's tint while not
|
|
422
|
+
tabBarIcon: ({ focused }) =>
|
|
423
|
+
nativeNanoSymbol('flag-us', focused ? 'original' : 'monochrome'),
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
<details>
|
|
427
|
+
<summary><u><code>nativeNanoSymbol(name, renderingMode?, prefix?)</code> Arguments</u></summary>
|
|
428
|
+
|
|
429
|
+
- `name` — the SVG filename.
|
|
430
|
+
- `renderingMode` — `'monochrome'` (default) or `'original'`. Returned as the symbol's `renderingMode` on iOS and as `tinted` on the Android image icon.
|
|
431
|
+
- `prefix` — matches the set's `prefix` (defaults to `nano`).
|
|
432
|
+
|
|
433
|
+
</details>
|
|
434
|
+
|
|
435
|
+
<details>
|
|
436
|
+
<summary><u>Icon turns into a solid block when tinted? (knockouts)</u></summary>
|
|
437
|
+
|
|
438
|
+
Tinting paints every shape in one color, so "white on color" art (lettering on a plate, stripes on a flag) would collapse into a solid block. Such details become **knockouts**: in `monochrome` they are holes that show the bar through the plate; in `original` they are painted in their own fill. By default every white (or near-white) shape over other shapes is a knockout. To choose them yourself, add `data-nano-knockout="true"` to the shapes or groups in the SVG; once an icon has an annotation, only annotated shapes are knockouts. A knockout floating over nothing is drawn in both modes.
|
|
439
|
+
|
|
440
|
+
```xml
|
|
441
|
+
<svg viewBox="0 0 24 24">
|
|
442
|
+
<rect width="24" height="24" fill="#B22234"/>
|
|
443
|
+
<path data-nano-knockout="true" fill="#FFD700" d="…"/> <!-- hole when tinted, gold in color -->
|
|
444
|
+
</svg>
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
</details>
|
|
448
|
+
|
|
449
|
+
<details>
|
|
450
|
+
<summary><u>Using symbols with <code><SFSymbol></code> (iOS)</u></summary>
|
|
451
|
+
|
|
452
|
+
Forged symbols also work in react-navigation's `<SFSymbol>` component and in `{ type: 'sfSymbol', name: 'nano.home' }`, including symbol effects. Palette and hierarchical rendering show a single color, because forged symbols only define monochrome and multicolor layers.
|
|
453
|
+
|
|
454
|
+
```TypeScript
|
|
455
|
+
import { SFSymbol } from '@react-navigation/native';
|
|
456
|
+
|
|
457
|
+
<SFSymbol name="nano.folder" size={32} color="#001A72" effect={{ type: 'bounce', repeat: 'continuous' }} />
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
</details>
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
311
464
|
## 📊 Performance
|
|
312
465
|
|
|
313
466
|
Native text engines are among the most optimized rendering pipelines in any OS. Rendering a glyph from a `.ttf` is synchronous and memory-efficient — unlike SVG, which requires XML parsing, native view tree creation, and Yoga layout calculation per icon instance.
|
package/android/build.gradle
CHANGED
|
@@ -5,7 +5,14 @@ buildscript {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
apply plugin: 'com.android.library'
|
|
8
|
-
|
|
8
|
+
// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
|
|
9
|
+
// itself. Applying the Kotlin plugin on top of it fails configuration with
|
|
10
|
+
// "Cannot add extension with name 'kotlin'". Only apply it when nothing has
|
|
11
|
+
// registered that extension yet.
|
|
12
|
+
if (project.extensions.findByName('kotlin') == null) {
|
|
13
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
apply plugin: 'com.facebook.react'
|
|
10
17
|
|
|
11
18
|
android {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.nanoicons
|
|
2
|
+
|
|
3
|
+
import android.content.res.AssetManager
|
|
4
|
+
import android.graphics.Typeface
|
|
5
|
+
import com.facebook.react.bridge.UiThreadUtil
|
|
6
|
+
import com.facebook.react.common.assets.ReactFontManager
|
|
7
|
+
import java.util.Collections
|
|
8
|
+
import java.util.WeakHashMap
|
|
9
|
+
|
|
10
|
+
object NanoIconFonts {
|
|
11
|
+
private val liveViews: MutableSet<NanoIconView> =
|
|
12
|
+
Collections.newSetFromMap(WeakHashMap())
|
|
13
|
+
|
|
14
|
+
fun resolve(family: String, assets: AssetManager): Typeface? {
|
|
15
|
+
val typeface =
|
|
16
|
+
ReactFontManager.getInstance().getTypeface(family, Typeface.NORMAL, assets)
|
|
17
|
+
val systemFallback = Typeface.create(family, Typeface.NORMAL)
|
|
18
|
+
return if (typeface == null || typeface == systemFallback) null else typeface
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun track(view: NanoIconView) {
|
|
22
|
+
liveViews.add(view)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun register(family: String, typeface: Typeface) {
|
|
26
|
+
ReactFontManager.getInstance().setTypeface(family, Typeface.NORMAL, typeface)
|
|
27
|
+
UiThreadUtil.runOnUiThread {
|
|
28
|
+
for (view in liveViews.toList()) view.resolveFontIfMissing()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,47 +1,71 @@
|
|
|
1
1
|
package com.nanoicons
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.content.res.Configuration
|
|
4
5
|
import android.graphics.Canvas
|
|
6
|
+
import android.graphics.Color
|
|
5
7
|
import android.graphics.Paint
|
|
6
8
|
import android.graphics.Typeface
|
|
7
9
|
import android.view.View
|
|
8
|
-
import com.facebook.react.
|
|
10
|
+
import com.facebook.react.bridge.ColorPropConverter
|
|
9
11
|
|
|
10
12
|
class NanoIconView(context: Context) : View(context) {
|
|
11
13
|
|
|
12
14
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
|
15
|
+
private val fontMetrics = Paint.FontMetrics()
|
|
13
16
|
private var codepoints: IntArray = intArrayOf()
|
|
14
17
|
private var colors: IntArray = intArrayOf()
|
|
18
|
+
// Unresolved layer colors: literal ARGB, plus resource paths for the entries that
|
|
19
|
+
// depend on the theme (PlatformColor). Kept so they can be re-resolved on a
|
|
20
|
+
// configuration change — the props are not re-sent for that.
|
|
21
|
+
private var literalColors: IntArray = intArrayOf()
|
|
22
|
+
private var colorPaths: Array<Array<String>?>? = null
|
|
23
|
+
private var tintColor: Int? = null
|
|
24
|
+
private var tintLayers: IntArray = intArrayOf()
|
|
15
25
|
private var cachedFontFamily: String? = null
|
|
16
26
|
private var cachedTypeface: Typeface? = null
|
|
17
27
|
// Cached String objects — rebuilt only when codepoints change
|
|
18
28
|
private var cachedTexts: Array<String> = emptyArray()
|
|
19
|
-
// Cached baseline — rebuilt
|
|
29
|
+
// Cached baseline — rebuilt when font, size, or bounds change
|
|
20
30
|
private var cachedBaseline: Float = 0f
|
|
31
|
+
// Derived from the loaded font's metrics; recomputed on typeface change.
|
|
32
|
+
private var textSizeFactor = 0f
|
|
33
|
+
private var baselineFactor = 0f
|
|
21
34
|
|
|
22
35
|
init {
|
|
23
36
|
// Transparent background, no default drawing
|
|
24
37
|
setBackgroundColor(0x00000000)
|
|
38
|
+
NanoIconFonts.track(this)
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
fun setFontFamily(fontFamily: String) {
|
|
28
42
|
if (fontFamily != cachedFontFamily) {
|
|
29
43
|
cachedFontFamily = fontFamily
|
|
30
|
-
|
|
31
|
-
.getTypeface(fontFamily, Typeface.NORMAL, context.assets)
|
|
32
|
-
paint.typeface = cachedTypeface
|
|
33
|
-
updateBaseline()
|
|
34
|
-
invalidate()
|
|
44
|
+
applyTypeface(NanoIconFonts.resolve(fontFamily, context.assets))
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
|
|
48
|
+
fun resolveFontIfMissing() {
|
|
49
|
+
val family = cachedFontFamily ?: return
|
|
50
|
+
if (cachedTypeface != null) return
|
|
51
|
+
val typeface = NanoIconFonts.resolve(family, context.assets) ?: return
|
|
52
|
+
applyTypeface(typeface)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private fun applyTypeface(typeface: Typeface?) {
|
|
56
|
+
cachedTypeface = typeface
|
|
57
|
+
paint.typeface = typeface
|
|
58
|
+
updateFontFactors()
|
|
59
|
+
fitToBounds()
|
|
60
|
+
invalidate()
|
|
61
|
+
}
|
|
62
|
+
|
|
38
63
|
fun setFontSize(size: Float) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
64
|
+
// Only seeds a size for use before the first layout; bounds win after that.
|
|
65
|
+
paint.textSize = size * resources.displayMetrics.density
|
|
66
|
+
if (textSizeFactor <= 0f) updateFontFactors()
|
|
67
|
+
fitToBounds()
|
|
68
|
+
invalidate()
|
|
45
69
|
}
|
|
46
70
|
|
|
47
71
|
fun setCodepoints(values: IntArray) {
|
|
@@ -50,13 +74,74 @@ class NanoIconView(context: Context) : View(context) {
|
|
|
50
74
|
invalidate()
|
|
51
75
|
}
|
|
52
76
|
|
|
53
|
-
fun setColors(
|
|
54
|
-
|
|
77
|
+
fun setColors(literals: IntArray, paths: Array<Array<String>?>?) {
|
|
78
|
+
literalColors = literals
|
|
79
|
+
colorPaths = paths
|
|
80
|
+
resolveColors()
|
|
55
81
|
invalidate()
|
|
56
82
|
}
|
|
57
83
|
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
fun setTintColor(color: Int?) {
|
|
85
|
+
tintColor = color
|
|
86
|
+
invalidate()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fun setTintLayers(layers: IntArray) {
|
|
90
|
+
tintLayers = layers
|
|
91
|
+
invalidate()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private fun layerColor(index: Int): Int {
|
|
95
|
+
val tint = tintColor
|
|
96
|
+
if (tint != null && tintLayers.contains(index)) return tint
|
|
97
|
+
return if (index < colors.size) colors[index] else 0xFF000000.toInt()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Resolve theme-dependent entries against this view's current context; literal
|
|
101
|
+
// entries pass through untouched.
|
|
102
|
+
private fun resolveColors() {
|
|
103
|
+
val paths = colorPaths
|
|
104
|
+
if (paths == null) {
|
|
105
|
+
colors = literalColors
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
colors = IntArray(literalColors.size) { i ->
|
|
109
|
+
val entry = paths[i] ?: return@IntArray literalColors[i]
|
|
110
|
+
entry.firstNotNullOfOrNull { ColorPropConverter.resolveResourcePath(context, it) }
|
|
111
|
+
?: Color.BLACK
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
override fun onConfigurationChanged(newConfig: Configuration) {
|
|
116
|
+
super.onConfigurationChanged(newConfig)
|
|
117
|
+
if (colorPaths == null) return
|
|
118
|
+
resolveColors()
|
|
119
|
+
invalidate()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
123
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
124
|
+
fitToBounds()
|
|
125
|
+
invalidate()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private fun updateFontFactors() {
|
|
129
|
+
val ts = paint.textSize
|
|
130
|
+
if (cachedTypeface == null || ts <= 0f) return
|
|
131
|
+
paint.getFontMetrics(fontMetrics)
|
|
132
|
+
val band = fontMetrics.descent - fontMetrics.ascent
|
|
133
|
+
if (band <= 0f) return
|
|
134
|
+
textSizeFactor = ts / band
|
|
135
|
+
baselineFactor = 1f - fontMetrics.descent / band
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Font scale is derived from the bounds, not from the fontSize prop.
|
|
139
|
+
private fun fitToBounds() {
|
|
140
|
+
val h = height.toFloat()
|
|
141
|
+
if (h <= 0f || textSizeFactor <= 0f) return
|
|
142
|
+
cachedBaseline = h * baselineFactor
|
|
143
|
+
val size = h * textSizeFactor
|
|
144
|
+
if (paint.textSize != size) paint.textSize = size
|
|
60
145
|
}
|
|
61
146
|
|
|
62
147
|
override fun onDraw(canvas: Canvas) {
|
|
@@ -68,8 +153,7 @@ class NanoIconView(context: Context) : View(context) {
|
|
|
68
153
|
|
|
69
154
|
// All layers drawn at the same position (stacked on each other)
|
|
70
155
|
for (i in cachedTexts.indices) {
|
|
71
|
-
|
|
72
|
-
paint.color = color
|
|
156
|
+
paint.color = layerColor(i)
|
|
73
157
|
canvas.drawText(cachedTexts[i], 0f, cachedBaseline, paint)
|
|
74
158
|
}
|
|
75
159
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
package com.nanoicons
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import com.facebook.react.bridge.ColorPropConverter
|
|
3
5
|
import com.facebook.react.bridge.ReadableArray
|
|
6
|
+
import com.facebook.react.bridge.ReadableType
|
|
4
7
|
import com.facebook.react.module.annotations.ReactModule
|
|
5
8
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
9
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
@@ -46,39 +49,60 @@ class NanoIconViewManager :
|
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
// Plain colors arrive pre-processed as ints; PlatformColor as a map. Resource-path
|
|
53
|
+
// maps are forwarded unresolved so the view can re-resolve them when the theme
|
|
54
|
+
// changes — resolving here would discard what that needs.
|
|
49
55
|
@ReactProp(name = "colors")
|
|
50
56
|
override fun setColors(view: NanoIconView, value: ReadableArray?) {
|
|
51
57
|
if (value != null) {
|
|
52
|
-
val
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
val size = value.size()
|
|
59
|
+
val literals = IntArray(size)
|
|
60
|
+
var paths: Array<Array<String>?>? = null
|
|
61
|
+
for (i in 0 until size) {
|
|
62
|
+
if (value.getType(i) == ReadableType.Map) {
|
|
63
|
+
val map = value.getMap(i)
|
|
64
|
+
val resourcePaths = map?.getArray("resource_paths")
|
|
65
|
+
if (resourcePaths != null) {
|
|
66
|
+
if (paths == null) paths = arrayOfNulls(size)
|
|
67
|
+
paths[i] =
|
|
68
|
+
Array(resourcePaths.size()) { resourcePaths.getString(it).orEmpty() }
|
|
69
|
+
} else {
|
|
70
|
+
// {space,r,g,b,a} wide-gamut form — theme-invariant, resolve once.
|
|
71
|
+
literals[i] = ColorPropConverter.getColor(map, view.context, Color.BLACK)
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
literals[i] = value.getInt(i)
|
|
75
|
+
}
|
|
55
76
|
}
|
|
56
|
-
view.setColors(
|
|
77
|
+
view.setColors(literals, paths)
|
|
57
78
|
}
|
|
58
79
|
}
|
|
59
80
|
|
|
60
|
-
@ReactProp(name = "
|
|
61
|
-
override fun
|
|
81
|
+
@ReactProp(name = "color", customType = "Color")
|
|
82
|
+
override fun setColor(view: NanoIconView, value: Int?) {
|
|
83
|
+
view.setTintColor(value)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@ReactProp(name = "tintLayers")
|
|
87
|
+
override fun setTintLayers(view: NanoIconView, value: ReadableArray?) {
|
|
88
|
+
val arr = if (value == null) intArrayOf() else IntArray(value.size()) { value.getInt(it) }
|
|
89
|
+
view.setTintLayers(arr)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@ReactProp(name = "size", defaultFloat = 12f)
|
|
93
|
+
override fun setSize(view: NanoIconView, value: Float) {
|
|
62
94
|
view.setFontSize(value)
|
|
63
95
|
}
|
|
64
96
|
|
|
97
|
+
@ReactProp(name = "allowFontScaling", defaultBoolean = true)
|
|
98
|
+
override fun setAllowFontScaling(view: NanoIconView, value: Boolean) {
|
|
99
|
+
}
|
|
100
|
+
|
|
65
101
|
@ReactProp(name = "advanceWidth", defaultInt = 0)
|
|
66
102
|
override fun setAdvanceWidth(view: NanoIconView, value: Int) {
|
|
67
|
-
// Used for sizing on JS side; native view uses Canvas layout
|
|
68
103
|
}
|
|
69
104
|
|
|
70
105
|
@ReactProp(name = "unitsPerEm", defaultInt = 0)
|
|
71
106
|
override fun setUnitsPerEm(view: NanoIconView, value: Int) {
|
|
72
|
-
// Used for sizing on JS side; native view uses Canvas layout
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@ReactProp(name = "iconWidth", defaultFloat = 0f)
|
|
76
|
-
override fun setIconWidth(view: NanoIconView, value: Float) {
|
|
77
|
-
// Width set via style from JS
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@ReactProp(name = "iconHeight", defaultFloat = 0f)
|
|
81
|
-
override fun setIconHeight(view: NanoIconView, value: Float) {
|
|
82
|
-
// Height set via style from JS
|
|
83
107
|
}
|
|
84
108
|
}
|