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/ios/NanoIconView.mm
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
#import "NanoIconView.h"
|
|
2
|
+
#import "NanoIconFontResolver.h"
|
|
2
3
|
#import <CoreText/CoreText.h>
|
|
3
4
|
#import <React/RCTConversions.h>
|
|
4
5
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
5
|
-
#import <react/renderer/components/RNNanoIconsSpec/
|
|
6
|
+
#import <react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h>
|
|
6
7
|
#import <react/renderer/components/RNNanoIconsSpec/Props.h>
|
|
8
|
+
#import "NanoIconInlineBaseline.h"
|
|
7
9
|
|
|
8
10
|
using namespace facebook::react;
|
|
9
11
|
|
|
10
12
|
// Forward-declare so the layer subclass can call the drawing method.
|
|
11
13
|
@interface NanoIconView ()
|
|
14
|
+
- (void)_resolveFontIfMissing;
|
|
12
15
|
- (void)_drawIconInContext:(CGContextRef)context bounds:(CGRect)bounds;
|
|
13
16
|
@end
|
|
14
17
|
|
|
@@ -24,55 +27,46 @@ using namespace facebook::react;
|
|
|
24
27
|
}
|
|
25
28
|
@end
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
static
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (font) sNanoIconFontCache[key] = (__bridge id)font;
|
|
43
|
-
return font;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Clears cached entries for `family` after OTA font re-registration.
|
|
47
|
-
void NanoIconInvalidateFontCache(NSString *family) {
|
|
48
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
49
|
-
if (!sNanoIconFontCache) return;
|
|
50
|
-
NSString *prefix = [family stringByAppendingString:@":"];
|
|
51
|
-
NSArray<NSString *> *keys = [sNanoIconFontCache.allKeys
|
|
52
|
-
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *k, id _) {
|
|
53
|
-
return [k hasPrefix:prefix];
|
|
54
|
-
}]];
|
|
55
|
-
[sNanoIconFontCache removeObjectsForKeys:keys];
|
|
30
|
+
static NSHashTable<NanoIconView *> *sNanoIconLiveViews;
|
|
31
|
+
static dispatch_once_t sNanoIconLiveViewsOnce;
|
|
32
|
+
|
|
33
|
+
static void NanoIconTrackLiveView(NanoIconView *view) {
|
|
34
|
+
dispatch_once(&sNanoIconLiveViewsOnce, ^{
|
|
35
|
+
sNanoIconLiveViews = [NSHashTable weakObjectsHashTable];
|
|
36
|
+
[[NSNotificationCenter defaultCenter]
|
|
37
|
+
addObserverForName:(__bridge NSString *)kCTFontManagerRegisteredFontsChangedNotification
|
|
38
|
+
object:nil
|
|
39
|
+
queue:[NSOperationQueue mainQueue]
|
|
40
|
+
usingBlock:^(__unused NSNotification *note) {
|
|
41
|
+
for (NanoIconView *live in [sNanoIconLiveViews allObjects]) {
|
|
42
|
+
[live _resolveFontIfMissing];
|
|
43
|
+
}
|
|
44
|
+
}];
|
|
56
45
|
});
|
|
46
|
+
[sNanoIconLiveViews addObject:view];
|
|
57
47
|
}
|
|
58
48
|
|
|
59
49
|
@implementation NanoIconView {
|
|
60
|
-
CTFontRef _font; // borrowed from
|
|
50
|
+
CTFontRef _font; // borrowed from the shared resolver cache — do NOT CFRelease
|
|
61
51
|
NSString *_fontFamily;
|
|
62
52
|
CGFloat _fontSize;
|
|
63
53
|
std::vector<CGGlyph> _glyphs;
|
|
64
|
-
|
|
54
|
+
// Unresolved layer colors — may be trait-dependent (DynamicColorIOS, PlatformColor).
|
|
55
|
+
NSArray<UIColor *> *_layerColors;
|
|
56
|
+
// _layerColors resolved against the current trait collection.
|
|
65
57
|
std::vector<CGColorRef> _cachedCGColors;
|
|
58
|
+
UIColor *_tintColor;
|
|
59
|
+
CGColorRef _cachedTintCGColor;
|
|
60
|
+
std::vector<bool> _tintable;
|
|
66
61
|
CGFloat _fitScale;
|
|
67
62
|
CGPoint _baselinePosition;
|
|
68
63
|
BOOL _metricsValid;
|
|
69
64
|
|
|
70
65
|
// Inline-in-Text detection — resolved once on first layout, cached until reparenting.
|
|
71
66
|
// Standalone icons (vast majority) skip the superview walk entirely after detection.
|
|
72
|
-
BOOL
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
CGFloat _cachedBaselineOffset;
|
|
67
|
+
BOOL _paragraphResolved;
|
|
68
|
+
UIView * __weak _paragraph;
|
|
69
|
+
CGFloat _baselineOffset;
|
|
76
70
|
BOOL _baselineOffsetValid;
|
|
77
71
|
|
|
78
72
|
// Drawing sublayer for inline icons — provides a shifted pixel buffer so the
|
|
@@ -92,6 +86,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
92
86
|
|
|
93
87
|
_fitScale = 1.0;
|
|
94
88
|
_baselinePosition = CGPointZero;
|
|
89
|
+
NanoIconTrackLiveView(self);
|
|
95
90
|
|
|
96
91
|
// _drawingLayer is created lazily only when inline in Text
|
|
97
92
|
}
|
|
@@ -122,61 +117,19 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
122
117
|
_metricsValid = YES;
|
|
123
118
|
}
|
|
124
119
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// ObjC runtime method resolution or attributed string reads.
|
|
130
|
-
- (void)_detectAndCacheInlineState {
|
|
131
|
-
_inlineDetected = YES;
|
|
132
|
-
_isInlineInText = NO;
|
|
133
|
-
_paragraphView = nil;
|
|
134
|
-
_cachedBaselineOffset = 0;
|
|
135
|
-
_baselineOffsetValid = YES;
|
|
136
|
-
|
|
137
|
-
// RCTParagraphComponentView is the immediate or near-immediate parent
|
|
138
|
-
// when the icon is inside <Text>. Three levels covers all known layouts.
|
|
139
|
-
UIView *current = self.superview;
|
|
140
|
-
UIView *target = nil;
|
|
141
|
-
for (int i = 0; i < 3 && current; i++) {
|
|
142
|
-
if ([NSStringFromClass([current class]) isEqualToString:@"RCTParagraphComponentView"]) {
|
|
143
|
-
target = current;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
current = current.superview;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (!target) return;
|
|
120
|
+
- (void)invalidateInlineBaseline {
|
|
121
|
+
_baselineOffsetValid = NO;
|
|
122
|
+
[self setNeedsLayout];
|
|
123
|
+
}
|
|
150
124
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
125
|
+
// The baseline offset depends on where RN placed the view, so a new frame
|
|
126
|
+
// invalidates it.
|
|
127
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
128
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
129
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
130
|
+
if (layoutMetrics.frame != oldLayoutMetrics.frame) {
|
|
131
|
+
_baselineOffsetValid = NO;
|
|
154
132
|
}
|
|
155
|
-
if (!attrStr || attrStr.length == 0) return;
|
|
156
|
-
|
|
157
|
-
UIFont *f = [attrStr attribute:NSFontAttributeName atIndex:0 effectiveRange:nil];
|
|
158
|
-
if (!f) return;
|
|
159
|
-
|
|
160
|
-
_isInlineInText = YES;
|
|
161
|
-
_paragraphView = target;
|
|
162
|
-
|
|
163
|
-
// Derive the distance from this view's bottom edge to the text baseline.
|
|
164
|
-
// Respects custom RN lineHeight (mapped to NSParagraphStyle.maximumLineHeight)
|
|
165
|
-
// and any baseline offset applied by Fabric's text layout.
|
|
166
|
-
NSParagraphStyle *style = [attrStr attribute:NSParagraphStyleAttributeName
|
|
167
|
-
atIndex:0 effectiveRange:nil];
|
|
168
|
-
CGFloat lineHeight = (style && style.maximumLineHeight > 0)
|
|
169
|
-
? style.maximumLineHeight : f.lineHeight;
|
|
170
|
-
|
|
171
|
-
NSNumber *bOff = [attrStr attribute:NSBaselineOffsetAttributeName
|
|
172
|
-
atIndex:0 effectiveRange:nil];
|
|
173
|
-
CGFloat baselineFromLineTop = f.ascender - (bOff ? bOff.doubleValue : 0);
|
|
174
|
-
|
|
175
|
-
CGFloat frameBottom = self.frame.origin.y + self.frame.size.height;
|
|
176
|
-
CGFloat posInLine = fmod(frameBottom, lineHeight);
|
|
177
|
-
if (posInLine < 0.01) posInLine = lineHeight;
|
|
178
|
-
|
|
179
|
-
_cachedBaselineOffset = MAX(0, posInLine - baselineFromLineTop);
|
|
180
133
|
}
|
|
181
134
|
|
|
182
135
|
// Lazily create the drawing sublayer for inline-in-Text icons.
|
|
@@ -186,6 +139,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
186
139
|
NanoIconDrawingLayer *layer = [NanoIconDrawingLayer layer];
|
|
187
140
|
layer.owner = self;
|
|
188
141
|
layer.opaque = NO;
|
|
142
|
+
layer.needsDisplayOnBoundsChange = YES;
|
|
189
143
|
layer.contentsScale = [UIScreen mainScreen].scale;
|
|
190
144
|
[self.layer addSublayer:layer];
|
|
191
145
|
_drawingLayer = layer;
|
|
@@ -194,63 +148,65 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
194
148
|
// Reset inline state when the view moves to a new parent.
|
|
195
149
|
- (void)didMoveToSuperview {
|
|
196
150
|
[super didMoveToSuperview];
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
_paragraphView = nil;
|
|
151
|
+
_paragraphResolved = NO;
|
|
152
|
+
_paragraph = nil;
|
|
200
153
|
_baselineOffsetValid = NO;
|
|
201
|
-
if (_drawingLayer) {
|
|
202
|
-
[_drawingLayer removeFromSuperlayer];
|
|
203
|
-
_drawingLayer = nil;
|
|
204
|
-
}
|
|
205
154
|
}
|
|
206
155
|
|
|
207
|
-
//
|
|
156
|
+
// _baselineOffset and _fitScale are both derived from bounds.
|
|
208
157
|
- (void)setBounds:(CGRect)bounds {
|
|
209
158
|
if (!CGSizeEqualToSize(self.bounds.size, bounds.size)) {
|
|
210
159
|
_baselineOffsetValid = NO;
|
|
160
|
+
_metricsValid = NO;
|
|
211
161
|
}
|
|
212
162
|
[super setBounds:bounds];
|
|
213
163
|
}
|
|
214
164
|
|
|
215
165
|
#pragma mark - Layout
|
|
216
166
|
|
|
217
|
-
// Standalone: no work beyond metrics validation (drawing via drawRect: on self).
|
|
218
|
-
// Inline: position the drawing sublayer with the cached baseline offset,
|
|
219
|
-
// recomputing only when bounds change or the view is reparented.
|
|
220
167
|
- (void)layoutSubviews {
|
|
221
168
|
[super layoutSubviews];
|
|
222
169
|
if (!_metricsValid) [self _updateMetrics];
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
170
|
+
if (!_paragraphResolved) {
|
|
171
|
+
_paragraph = NanoIconParagraphNeedingBaselineCorrection(self);
|
|
172
|
+
_paragraphResolved = YES;
|
|
173
|
+
}
|
|
174
|
+
if (!_baselineOffsetValid) {
|
|
175
|
+
_baselineOffset = _paragraph ? NanoIconInlineBaselineOffset(self, _paragraph) : 0;
|
|
176
|
+
_baselineOffsetValid = YES;
|
|
226
177
|
}
|
|
178
|
+
[self _layoutDrawingLayer];
|
|
179
|
+
}
|
|
227
180
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
[CATransaction begin];
|
|
238
|
-
[CATransaction setDisableActions:YES];
|
|
239
|
-
_drawingLayer.frame = newFrame;
|
|
240
|
-
[CATransaction commit];
|
|
181
|
+
// Standalone icons draw in drawRect:. An icon that needs a baseline correction
|
|
182
|
+
// draws in a sublayer shifted by the offset instead, so it can overflow the
|
|
183
|
+
// Yoga frame without moving the view itself.
|
|
184
|
+
- (void)_layoutDrawingLayer {
|
|
185
|
+
if (_baselineOffset == 0) {
|
|
186
|
+
if (_drawingLayer) {
|
|
187
|
+
[_drawingLayer removeFromSuperlayer];
|
|
188
|
+
_drawingLayer = nil;
|
|
189
|
+
[self setNeedsDisplay];
|
|
241
190
|
}
|
|
242
|
-
|
|
243
|
-
// setNeedsDisplay from updateProps (which targeted self before detection).
|
|
244
|
-
if (created) [_drawingLayer setNeedsDisplay];
|
|
191
|
+
return;
|
|
245
192
|
}
|
|
246
|
-
|
|
193
|
+
BOOL created = !_drawingLayer;
|
|
194
|
+
[self _ensureDrawingLayer];
|
|
195
|
+
CGRect frame = CGRectMake(0, -_baselineOffset, self.bounds.size.width, self.bounds.size.height);
|
|
196
|
+
if (!CGRectEqualToRect(_drawingLayer.frame, frame)) {
|
|
197
|
+
[CATransaction begin];
|
|
198
|
+
[CATransaction setDisableActions:YES];
|
|
199
|
+
_drawingLayer.frame = frame;
|
|
200
|
+
[CATransaction commit];
|
|
201
|
+
}
|
|
202
|
+
if (created) [_drawingLayer setNeedsDisplay];
|
|
247
203
|
}
|
|
248
204
|
|
|
249
205
|
#pragma mark - Drawing
|
|
250
206
|
|
|
251
207
|
// Standalone icons draw directly in this view's drawRect:.
|
|
252
208
|
- (void)drawRect:(CGRect)rect {
|
|
253
|
-
if (
|
|
209
|
+
if (_drawingLayer) return;
|
|
254
210
|
CGContextRef ctx = UIGraphicsGetCurrentContext();
|
|
255
211
|
if (ctx) [self _drawIconInContext:ctx bounds:self.bounds];
|
|
256
212
|
}
|
|
@@ -271,7 +227,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
271
227
|
while (i < _glyphs.size()) {
|
|
272
228
|
if (_glyphs[i] == 0) { i++; continue; }
|
|
273
229
|
|
|
274
|
-
CGColorRef color =
|
|
230
|
+
CGColorRef color = [self _colorForLayer:i];
|
|
275
231
|
if (!color) {
|
|
276
232
|
static CGColorRef sBlack = CGColorCreateSRGB(0, 0, 0, 1);
|
|
277
233
|
color = sBlack;
|
|
@@ -286,7 +242,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
286
242
|
|
|
287
243
|
while (i < _glyphs.size()) {
|
|
288
244
|
if (_glyphs[i] == 0) { i++; continue; }
|
|
289
|
-
CGColorRef next =
|
|
245
|
+
CGColorRef next = [self _colorForLayer:i];
|
|
290
246
|
if (i > batchStart && next != color) break;
|
|
291
247
|
if (batchCount < 16) {
|
|
292
248
|
posBuf[batchCount] = _baselinePosition;
|
|
@@ -326,19 +282,34 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
326
282
|
- (void)_releaseCachedColors {
|
|
327
283
|
for (CGColorRef c : _cachedCGColors) CGColorRelease(c);
|
|
328
284
|
_cachedCGColors.clear();
|
|
285
|
+
if (_cachedTintCGColor) {
|
|
286
|
+
CGColorRelease(_cachedTintCGColor);
|
|
287
|
+
_cachedTintCGColor = NULL;
|
|
288
|
+
}
|
|
329
289
|
}
|
|
330
290
|
|
|
331
|
-
|
|
291
|
+
- (CGColorRef)_colorForLayer:(size_t)index {
|
|
292
|
+
if (_cachedTintCGColor && index < _tintable.size() && _tintable[index]) {
|
|
293
|
+
return _cachedTintCGColor;
|
|
294
|
+
}
|
|
295
|
+
return index < _cachedCGColors.size() ? _cachedCGColors[index] : NULL;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Resolve the layer colors against the current traits into cached CGColorRefs.
|
|
299
|
+
// Resolving up front (rather than relying on UIKit's current trait collection at
|
|
300
|
+
// draw time) keeps the CALayer inline-in-Text path correct — CoreAnimation does
|
|
301
|
+
// not install a trait collection around -drawInContext:.
|
|
332
302
|
- (void)_rebuildCachedColors {
|
|
333
303
|
[self _releaseCachedColors];
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
304
|
+
UITraitCollection *traits = self.traitCollection;
|
|
305
|
+
_cachedCGColors.resize(_layerColors.count);
|
|
306
|
+
for (NSUInteger i = 0; i < _layerColors.count; i++) {
|
|
307
|
+
UIColor *resolved = [_layerColors[i] resolvedColorWithTraitCollection:traits];
|
|
308
|
+
_cachedCGColors[i] = CGColorRetain(resolved.CGColor);
|
|
309
|
+
}
|
|
310
|
+
if (_tintColor) {
|
|
311
|
+
UIColor *resolved = [_tintColor resolvedColorWithTraitCollection:traits];
|
|
312
|
+
_cachedTintCGColor = CGColorRetain(resolved.CGColor);
|
|
342
313
|
}
|
|
343
314
|
}
|
|
344
315
|
|
|
@@ -350,10 +321,10 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
350
321
|
BOOL needsRedraw = NO;
|
|
351
322
|
|
|
352
323
|
if (oldViewProps.fontFamily != newViewProps.fontFamily ||
|
|
353
|
-
oldViewProps.
|
|
324
|
+
oldViewProps.size != newViewProps.size) {
|
|
354
325
|
_fontFamily = [NSString stringWithUTF8String:newViewProps.fontFamily.c_str()];
|
|
355
|
-
_fontSize = newViewProps.
|
|
356
|
-
_font =
|
|
326
|
+
_fontSize = newViewProps.size;
|
|
327
|
+
_font = NanoIconResolveFont(_fontFamily, _fontSize);
|
|
357
328
|
_metricsValid = NO;
|
|
358
329
|
fontChanged = YES;
|
|
359
330
|
needsRedraw = YES;
|
|
@@ -361,52 +332,97 @@ void NanoIconInvalidateFontCache(NSString *family) {
|
|
|
361
332
|
|
|
362
333
|
// Map Unicode codepoints to font glyph IDs, handling surrogate pairs for codepoints > 0xFFFF.
|
|
363
334
|
if (fontChanged || oldViewProps.codepoints != newViewProps.codepoints) {
|
|
364
|
-
|
|
365
|
-
if (!fontChanged && _fontFamily) {
|
|
366
|
-
_font = NanoIconGetCachedFont(_fontFamily, _fontSize);
|
|
367
|
-
}
|
|
368
|
-
const auto &codepoints = newViewProps.codepoints;
|
|
369
|
-
_glyphs.resize(codepoints.size());
|
|
370
|
-
for (size_t i = 0; i < codepoints.size(); i++) {
|
|
371
|
-
int32_t cp = codepoints[i];
|
|
372
|
-
if (cp <= 0xFFFF) {
|
|
373
|
-
UniChar ch = (UniChar)cp;
|
|
374
|
-
CTFontGetGlyphsForCharacters(_font, &ch, &_glyphs[i], 1);
|
|
375
|
-
} else {
|
|
376
|
-
UniChar surr[2] = {
|
|
377
|
-
(UniChar)(0xD800 + ((cp - 0x10000) >> 10)),
|
|
378
|
-
(UniChar)(0xDC00 + ((cp - 0x10000) & 0x3FF))
|
|
379
|
-
};
|
|
380
|
-
CGGlyph pair[2] = {0, 0};
|
|
381
|
-
CTFontGetGlyphsForCharacters(_font, surr, pair, 2);
|
|
382
|
-
_glyphs[i] = pair[0];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
335
|
+
[self _mapGlyphs:newViewProps.codepoints];
|
|
385
336
|
needsRedraw = YES;
|
|
386
337
|
}
|
|
387
338
|
|
|
388
339
|
if (oldViewProps.colors != newViewProps.colors) {
|
|
389
340
|
const auto &colors = newViewProps.colors;
|
|
390
|
-
|
|
341
|
+
NSMutableArray<UIColor *> *layerColors = [NSMutableArray arrayWithCapacity:colors.size()];
|
|
391
342
|
for (size_t i = 0; i < colors.size(); i++) {
|
|
392
|
-
|
|
343
|
+
UIColor *color = RCTUIColorFromSharedColor(colors[i]);
|
|
344
|
+
[layerColors addObject:color ?: [UIColor blackColor]];
|
|
393
345
|
}
|
|
346
|
+
_layerColors = layerColors;
|
|
394
347
|
[self _rebuildCachedColors];
|
|
395
348
|
needsRedraw = YES;
|
|
396
349
|
}
|
|
397
350
|
|
|
351
|
+
if (oldViewProps.color != newViewProps.color) {
|
|
352
|
+
_tintColor = newViewProps.color ? RCTUIColorFromSharedColor(newViewProps.color) : nil;
|
|
353
|
+
[self _rebuildCachedColors];
|
|
354
|
+
needsRedraw = YES;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (oldViewProps.tintLayers != newViewProps.tintLayers ||
|
|
358
|
+
oldViewProps.codepoints != newViewProps.codepoints) {
|
|
359
|
+
_tintable.assign(newViewProps.codepoints.size(), false);
|
|
360
|
+
for (int layer : newViewProps.tintLayers) {
|
|
361
|
+
if (layer >= 0 && (size_t)layer < _tintable.size()) _tintable[layer] = true;
|
|
362
|
+
}
|
|
363
|
+
needsRedraw = YES;
|
|
364
|
+
}
|
|
365
|
+
|
|
398
366
|
[super updateProps:props oldProps:oldProps];
|
|
399
|
-
if (needsRedraw)
|
|
400
|
-
|
|
401
|
-
|
|
367
|
+
if (needsRedraw) [self _setNeedsRedraw];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
- (void)_mapGlyphs:(const std::vector<int32_t> &)codepoints {
|
|
371
|
+
_glyphs.assign(codepoints.size(), 0);
|
|
372
|
+
if (!_font) return;
|
|
373
|
+
for (size_t i = 0; i < codepoints.size(); i++) {
|
|
374
|
+
int32_t cp = codepoints[i];
|
|
375
|
+
if (cp <= 0xFFFF) {
|
|
376
|
+
UniChar ch = (UniChar)cp;
|
|
377
|
+
CTFontGetGlyphsForCharacters(_font, &ch, &_glyphs[i], 1);
|
|
402
378
|
} else {
|
|
403
|
-
[
|
|
379
|
+
UniChar surr[2] = {
|
|
380
|
+
(UniChar)(0xD800 + ((cp - 0x10000) >> 10)),
|
|
381
|
+
(UniChar)(0xDC00 + ((cp - 0x10000) & 0x3FF))
|
|
382
|
+
};
|
|
383
|
+
CGGlyph pair[2] = {0, 0};
|
|
384
|
+
CTFontGetGlyphsForCharacters(_font, surr, pair, 2);
|
|
385
|
+
_glyphs[i] = pair[0];
|
|
404
386
|
}
|
|
405
387
|
}
|
|
406
388
|
}
|
|
407
389
|
|
|
390
|
+
// Trait-dependent colors (DynamicColorIOS, PlatformColor) resolve to a different
|
|
391
|
+
// CGColor when the interface style or contrast changes. Fabric does not re-send
|
|
392
|
+
// props for that, so re-resolve and redraw here.
|
|
393
|
+
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
|
394
|
+
[super traitCollectionDidChange:previousTraitCollection];
|
|
395
|
+
|
|
396
|
+
if (_layerColors.count == 0 && !_tintColor) return;
|
|
397
|
+
if (![self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
[self _rebuildCachedColors];
|
|
402
|
+
[self _setNeedsRedraw];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
- (void)_resolveFontIfMissing {
|
|
406
|
+
if (_font || _fontFamily.length == 0) return;
|
|
407
|
+
_font = NanoIconResolveFont(_fontFamily, _fontSize);
|
|
408
|
+
if (!_font) return;
|
|
409
|
+
const auto &viewProps = static_cast<const NanoIconViewProps &>(*_props);
|
|
410
|
+
[self _mapGlyphs:viewProps.codepoints];
|
|
411
|
+
_metricsValid = NO;
|
|
412
|
+
[self _setNeedsRedraw];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
- (void)_setNeedsRedraw {
|
|
416
|
+
if (_drawingLayer) {
|
|
417
|
+
[_drawingLayer setNeedsDisplay];
|
|
418
|
+
} else {
|
|
419
|
+
[self setNeedsDisplay];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
408
423
|
- (void)dealloc {
|
|
409
424
|
// _font is borrowed from static cache — do not release
|
|
425
|
+
[sNanoIconLiveViews removeObject:self];
|
|
410
426
|
[self _releaseCachedColors];
|
|
411
427
|
}
|
|
412
428
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
#import "NanoIconFontResolver.h"
|
|
1
2
|
#import "NanoIconsFontLoader.h"
|
|
2
|
-
#import "NanoIconView.h"
|
|
3
3
|
#import <CoreText/CoreText.h>
|
|
4
4
|
|
|
5
5
|
@implementation NanoIconsFontLoader
|
|
@@ -43,7 +43,7 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
|
|
|
43
43
|
if (!nameMatches) {
|
|
44
44
|
CGFontRelease(cgFont);
|
|
45
45
|
reject(
|
|
46
|
-
@"
|
|
46
|
+
@"E_NANOICONS_FONT_MISMATCH",
|
|
47
47
|
[NSString stringWithFormat:
|
|
48
48
|
@"Font name \"%@\" does not match family \"%@\". "
|
|
49
49
|
@"On iOS the TTF PostScript/full name must equal glyphMap.m.f.",
|
|
@@ -54,51 +54,29 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
|
|
|
54
54
|
|
|
55
55
|
CFErrorRef error = NULL;
|
|
56
56
|
bool ok = CTFontManagerRegisterGraphicsFont(cgFont, &error);
|
|
57
|
-
|
|
57
|
+
CGFontRelease(cgFont);
|
|
58
58
|
|
|
59
59
|
if (!ok && error) {
|
|
60
60
|
NSError *err = (__bridge_transfer NSError *)error;
|
|
61
|
-
|
|
62
61
|
if (err.code == kCTFontManagerErrorAlreadyRegistered ||
|
|
63
62
|
err.code == kCTFontManagerErrorDuplicatedName) {
|
|
64
|
-
// OTA reload: process still holds the old font. Swap it out.
|
|
65
|
-
CTFontRef existingCT = CTFontCreateWithName((__bridge CFStringRef)postScriptName, 10.0, NULL);
|
|
66
|
-
if (existingCT) {
|
|
67
|
-
CGFontRef existingCG = CTFontCopyGraphicsFont(existingCT, NULL);
|
|
68
|
-
CFRelease(existingCT);
|
|
69
|
-
if (existingCG) {
|
|
70
|
-
CFErrorRef unregErr = NULL;
|
|
71
|
-
CTFontManagerUnregisterGraphicsFont(existingCG, &unregErr);
|
|
72
|
-
CFRelease(existingCG);
|
|
73
|
-
if (unregErr) CFRelease(unregErr);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
CFErrorRef regErr = NULL;
|
|
78
|
-
bool reok = CTFontManagerRegisterGraphicsFont(cgFont, ®Err);
|
|
79
|
-
CGFontRelease(cgFont);
|
|
80
|
-
|
|
81
|
-
if (!reok && regErr) {
|
|
82
|
-
NSError *reErr = (__bridge_transfer NSError *)regErr;
|
|
83
|
-
reject(@"E_NANOICONS_FONT_REGISTER", reErr.localizedDescription, reErr);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (regErr) CFRelease(regErr);
|
|
87
|
-
|
|
88
|
-
NanoIconInvalidateFontCache(postScriptName);
|
|
89
63
|
resolve(@(YES));
|
|
90
64
|
return;
|
|
91
65
|
}
|
|
92
|
-
|
|
93
|
-
CGFontRelease(cgFont);
|
|
94
66
|
reject(@"E_NANOICONS_FONT_REGISTER", err.localizedDescription, err);
|
|
95
67
|
return;
|
|
96
68
|
}
|
|
97
69
|
|
|
98
|
-
CGFontRelease(cgFont);
|
|
99
70
|
resolve(@(YES));
|
|
100
71
|
}
|
|
101
72
|
|
|
73
|
+
RCT_EXPORT_METHOD(isFontRegistered:(NSString *)family
|
|
74
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
75
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
76
|
+
{
|
|
77
|
+
resolve(@(NanoIconIsFontResolvable(family)));
|
|
78
|
+
}
|
|
79
|
+
|
|
102
80
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
103
81
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
104
82
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PreparedSvgCache, type SvgWorkerPool } from '../src/core/pipeline/index';
|
|
2
|
+
import type { NanoLogger } from './logger';
|
|
2
3
|
export type IconSetConfig = {
|
|
3
4
|
/** Path to folder of SVG files (relative to project root). */
|
|
4
5
|
inputDir: string;
|
|
@@ -8,24 +9,36 @@ export type IconSetConfig = {
|
|
|
8
9
|
outputDir?: string;
|
|
9
10
|
/** Units per em (default 1024). */
|
|
10
11
|
upm?: number;
|
|
11
|
-
/** Safe zone inside UPM for glyphs (default 1020). */
|
|
12
|
+
/** Safe zone inside UPM for glyphs (default upm * 1020 / 1024, i.e. 1020 at the default upm). Must not exceed upm. */
|
|
12
13
|
safeZone?: number;
|
|
13
14
|
/** First Unicode codepoint for glyphs (default 0xe900). Hex string or number. */
|
|
14
15
|
startUnicode?: number | string;
|
|
15
16
|
/** Linking type for the font (default 'static'). Static bundles the TTF, dynamic delivers it via OTA*/
|
|
16
17
|
linking?: 'static' | 'dynamic';
|
|
18
|
+
/** Also emit <fontFamily>.woff2 into outputDir for web (default false). Rebuilt with the TTF, never linked natively. */
|
|
19
|
+
web?: boolean;
|
|
17
20
|
};
|
|
18
21
|
export type BuiltFont = {
|
|
19
22
|
fontFamily: string;
|
|
23
|
+
family: string;
|
|
20
24
|
ttfPath: string;
|
|
21
25
|
glyphmapPath: string;
|
|
22
26
|
linking: 'static' | 'dynamic';
|
|
27
|
+
woff2Path?: string;
|
|
23
28
|
};
|
|
29
|
+
export declare class IconSetBuildError extends Error {
|
|
30
|
+
built: BuiltFont[];
|
|
31
|
+
constructor(message: string, built: BuiltFont[]);
|
|
32
|
+
}
|
|
24
33
|
/**
|
|
25
|
-
* Build TTF + glyphmap for all icon sets using a single
|
|
34
|
+
* Build TTF + glyphmap for all icon sets using a single PathKit instance.
|
|
26
35
|
* Output is placed in a "nanoicons" folder next to each input dir (sibling to inputDir).
|
|
27
36
|
* Skips generation for a set if that output folder already contains the expected .ttf and .glyphmap.json.
|
|
28
37
|
*/
|
|
29
38
|
export declare function buildAllFonts(iconSets: IconSetConfig[], projectRoot: string, options?: {
|
|
30
39
|
logger?: NanoLogger;
|
|
40
|
+
keepOutputsOnFailure?: boolean;
|
|
41
|
+
preparedSvgCache?: PreparedSvgCache;
|
|
42
|
+
svgWorkerPool?: SvgWorkerPool;
|
|
43
|
+
withWeb?: boolean;
|
|
31
44
|
}): Promise<BuiltFont[]>;
|