@react-native-vector-icons/common 0.0.1-alpha.8 → 11.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +49 -91
- package/android/build.gradle +37 -3
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeVectorIconsSpec.java +42 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +49 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/RNVectorIconsSpec-generated.cpp +38 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/RNVectorIconsSpec.h +31 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI-generated.cpp +40 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI.h +76 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
- package/android/src/main/AndroidManifestNew.xml +1 -1
- package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.kt +90 -0
- package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.kt +35 -0
- package/android/src/newarch/VectorIconsSpec.kt +7 -0
- package/android/src/oldarch/VectorIconsSpec.kt +38 -0
- package/ios/VectorIcons.h +13 -17
- package/ios/VectorIcons.mm +76 -92
- package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm +1881 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h +2321 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpecJSI-generated.cpp +2785 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpecJSI.h +7511 -0
- package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpec/RNVectorIconsSpec-generated.mm +36 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpec/RNVectorIconsSpec.h +58 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpecJSI-generated.cpp +40 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpecJSI.h +76 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
- package/lib/commonjs/NativeVectorIcons.js.map +1 -1
- package/lib/commonjs/create-icon-set.js +49 -36
- package/lib/commonjs/create-icon-set.js.map +1 -1
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +92 -0
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -0
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js +20 -0
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +50 -0
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -0
- package/lib/commonjs/dynamicLoading/types.js +2 -0
- package/lib/commonjs/dynamicLoading/types.js.map +1 -0
- package/lib/commonjs/ensure-native-module-available.js +1 -1
- package/lib/commonjs/ensure-native-module-available.js.map +1 -1
- package/lib/commonjs/index.js +57 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/scripts/common.js +49 -0
- package/lib/commonjs/scripts/common.js.map +1 -0
- package/lib/commonjs/scripts/getFonts.js +6 -40
- package/lib/commonjs/scripts/getFonts.js.map +1 -1
- package/lib/commonjs/scripts/updatePlist.js +54 -0
- package/lib/commonjs/scripts/updatePlist.js.map +1 -0
- package/lib/module/NativeVectorIcons.js +2 -0
- package/lib/module/NativeVectorIcons.js.map +1 -1
- package/lib/module/NativeVectorIcons.web.js +2 -0
- package/lib/module/NativeVectorIcons.web.js.map +1 -1
- package/lib/module/create-icon-set.js +49 -34
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/create-icon-source-cache.js +2 -0
- package/lib/module/create-icon-source-cache.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-font-loading.js +85 -0
- package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -0
- package/lib/module/dynamicLoading/dynamic-font-loading.web.js +16 -0
- package/lib/module/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
- package/lib/module/dynamicLoading/dynamic-loading-setting.js +41 -0
- package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -0
- package/lib/module/dynamicLoading/types.js +2 -0
- package/lib/module/dynamicLoading/types.js.map +1 -0
- package/lib/module/ensure-native-module-available.js +2 -0
- package/lib/module/ensure-native-module-available.js.map +1 -1
- package/lib/module/index.js +33 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/scripts/common.js +43 -0
- package/lib/module/scripts/common.js.map +1 -0
- package/lib/module/scripts/getFonts.js +8 -39
- package/lib/module/scripts/getFonts.js.map +1 -1
- package/lib/module/scripts/updatePlist.js +51 -0
- package/lib/module/scripts/updatePlist.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/create-icon-set.d.ts +36 -0
- package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts +9 -0
- package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/scripts/common.d.ts +2 -0
- package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/scripts/getFonts.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts +3 -0
- package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeVectorIcons.d.ts +8 -0
- package/lib/typescript/module/src/NativeVectorIcons.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeVectorIcons.web.d.ts +3 -0
- package/lib/typescript/module/src/NativeVectorIcons.web.d.ts.map +1 -0
- package/lib/typescript/module/src/create-icon-set.d.ts +36 -0
- package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -0
- package/lib/typescript/module/src/create-icon-source-cache.d.ts +21 -0
- package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
- package/lib/typescript/module/src/dynamicLoading/types.d.ts +9 -0
- package/lib/typescript/module/src/dynamicLoading/types.d.ts.map +1 -0
- package/lib/typescript/module/src/ensure-native-module-available.d.ts +2 -0
- package/lib/typescript/module/src/ensure-native-module-available.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +6 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/scripts/common.d.ts +2 -0
- package/lib/typescript/module/src/scripts/common.d.ts.map +1 -0
- package/lib/typescript/module/src/scripts/getFonts.d.ts +3 -0
- package/lib/typescript/module/src/scripts/getFonts.d.ts.map +1 -0
- package/lib/typescript/module/src/scripts/updatePlist.d.ts +3 -0
- package/lib/typescript/module/src/scripts/updatePlist.d.ts.map +1 -0
- package/package.json +72 -44
- package/react-native-vector-icons.podspec +67 -42
- package/react-native.config.js +13 -0
- package/src/NativeVectorIcons.ts +2 -4
- package/src/create-icon-set.tsx +79 -32
- package/src/dynamicLoading/dynamic-font-loading.ts +97 -0
- package/src/dynamicLoading/dynamic-font-loading.web.ts +15 -0
- package/src/dynamicLoading/dynamic-loading-setting.ts +77 -0
- package/src/dynamicLoading/types.ts +10 -0
- package/src/index.ts +48 -1
- package/src/scripts/common.ts +52 -0
- package/src/scripts/getFonts.ts +6 -47
- package/src/scripts/updatePlist.ts +58 -0
- package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.java +0 -121
- package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.java +0 -45
- package/android/src/newarch/VectorIconsSpec.java +0 -9
- package/android/src/oldarch/VectorIconsSpec.java +0 -18
- package/lib/typescript/src/NativeVectorIcons.d.ts +0 -9
- package/lib/typescript/src/NativeVectorIcons.d.ts.map +0 -1
- package/lib/typescript/src/NativeVectorIcons.web.d.ts.map +0 -1
- package/lib/typescript/src/create-icon-set.d.ts +0 -26
- package/lib/typescript/src/create-icon-set.d.ts.map +0 -1
- package/lib/typescript/src/create-icon-source-cache.d.ts.map +0 -1
- package/lib/typescript/src/ensure-native-module-available.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -3
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/scripts/getFonts.d.ts.map +0 -1
- /package/lib/typescript/{src → commonjs/src}/NativeVectorIcons.web.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/create-icon-source-cache.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/ensure-native-module-available.d.ts +0 -0
- /package/lib/typescript/{src → commonjs/src}/scripts/getFonts.d.ts +0 -0
package/src/scripts/getFonts.ts
CHANGED
|
@@ -1,52 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { resolveNodeModuleDir } from '@react-native-community/cli-tools';
|
|
3
|
+
import { getFontPaths } from './common';
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
-
throw new Error('Need
|
|
5
|
+
const packageJsonFilename = process.argv[2];
|
|
6
|
+
if (!packageJsonFilename) {
|
|
7
|
+
throw new Error('Need the path to the roo package.json as the first argument');
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const packageJson = JSON.parse(packageData);
|
|
15
|
-
|
|
16
|
-
return packageJson;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const getPackages = () => {
|
|
20
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
21
|
-
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
22
|
-
|
|
23
|
-
const packageDirs: string[] = [];
|
|
24
|
-
dependencies.forEach((dependency) => {
|
|
25
|
-
const dir = resolveNodeModuleDir(rootDir, dependency);
|
|
26
|
-
const packageJson = getPackageJson(dir);
|
|
27
|
-
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
28
|
-
packageDirs.push(dir);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return packageDirs;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const getFonts = (dir: string) => {
|
|
35
|
-
const fontDirs = [`${dir}/fonts`];
|
|
36
|
-
|
|
37
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
38
|
-
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
39
|
-
fontDirs.push(`${rootDir}/${config.fontDir || 'rnvi-fonts'}`);
|
|
40
|
-
|
|
41
|
-
fontDirs.forEach((fontDir) => {
|
|
42
|
-
if (!fs.existsSync(fontDir)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const fonts = fs.readdirSync(fontDir);
|
|
47
|
-
fonts.forEach((font) => console.log(`${fontDir}/${font}`)); // eslint-disable-line no-console
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const packageDirs = getPackages();
|
|
52
|
-
packageDirs.forEach((dir) => getFonts(dir));
|
|
10
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
11
|
+
fonts.map((font) => console.log(font)); // eslint-disable-line no-console
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import pc from 'picocolors';
|
|
7
|
+
import * as plist from 'plist';
|
|
8
|
+
|
|
9
|
+
import { getFontPaths } from './common';
|
|
10
|
+
|
|
11
|
+
const getFontName = (fontPath: string) => path.basename(fontPath);
|
|
12
|
+
|
|
13
|
+
const packageJsonFilename = process.argv[2];
|
|
14
|
+
if (!packageJsonFilename) {
|
|
15
|
+
throw new Error('Need the path to the root package.json as the first argument');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const infoPlistFilename = process.argv[3];
|
|
19
|
+
if (!infoPlistFilename) {
|
|
20
|
+
throw new Error('Need the path to the Info.plist as the second argument');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
24
|
+
console.log(`Found ${fonts.length} fonts`);
|
|
25
|
+
|
|
26
|
+
const infoPlistContent = fs.readFileSync(infoPlistFilename, 'utf8');
|
|
27
|
+
const infoPlist = plist.parse(infoPlistContent) as Record<string, string[]>;
|
|
28
|
+
|
|
29
|
+
const plistFonts = new Set(infoPlist.UIAppFonts || []);
|
|
30
|
+
const providedFonts = new Set(fonts.map(getFontName));
|
|
31
|
+
|
|
32
|
+
let hasChanges = false;
|
|
33
|
+
|
|
34
|
+
// Check for missing fonts and add them
|
|
35
|
+
providedFonts.forEach((font) => {
|
|
36
|
+
if (!plistFonts.has(font)) {
|
|
37
|
+
plistFonts.add(font);
|
|
38
|
+
console.log(pc.green(`Added ${font}`));
|
|
39
|
+
hasChanges = true;
|
|
40
|
+
} else {
|
|
41
|
+
console.log(`Existing ${font}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Check for extra fonts in Info.plist
|
|
46
|
+
plistFonts.forEach((font) => {
|
|
47
|
+
if (!providedFonts.has(font)) {
|
|
48
|
+
console.log(pc.red(`Extra ${font} (Please remove manually if not needed)`));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Update Info.plist if there were changes
|
|
53
|
+
if (hasChanges) {
|
|
54
|
+
infoPlist.UIAppFonts = Array.from(plistFonts);
|
|
55
|
+
const updatedInfoPlistContent = plist.build(infoPlist).replace(/^ {2}/gm, '').replace(/ {2}/gm, '\t');
|
|
56
|
+
|
|
57
|
+
fs.writeFileSync(infoPlistFilename, updatedInfoPlistContent, 'utf8');
|
|
58
|
+
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
package com.reactnativevectoricons.common;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.Promise;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
8
|
-
|
|
9
|
-
import com.facebook.react.views.text.ReactFontManager;
|
|
10
|
-
|
|
11
|
-
import android.content.Context;
|
|
12
|
-
import android.graphics.Paint;
|
|
13
|
-
import android.graphics.Canvas;
|
|
14
|
-
import android.graphics.Typeface;
|
|
15
|
-
import android.graphics.Rect;
|
|
16
|
-
import android.graphics.Bitmap;
|
|
17
|
-
import android.graphics.Bitmap.CompressFormat;
|
|
18
|
-
|
|
19
|
-
import java.io.File;
|
|
20
|
-
import java.io.FileOutputStream;
|
|
21
|
-
import java.io.IOException;
|
|
22
|
-
import java.io.FileNotFoundException;
|
|
23
|
-
import java.util.HashMap;
|
|
24
|
-
import java.util.Map;
|
|
25
|
-
|
|
26
|
-
public class VectorIconsModule extends VectorIconsSpec {
|
|
27
|
-
public static final String NAME = "VectorIcons";
|
|
28
|
-
|
|
29
|
-
@interface Errors {
|
|
30
|
-
String E_UNKNOWN_ERROR = "E_UNKNOWN_ERROR";
|
|
31
|
-
String E_NOT_IMPLEMENTED = "E_NOT_IMPLEMENTED";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private static final Map<String, Typeface> sTypefaceCache = new HashMap<String, Typeface>();
|
|
35
|
-
|
|
36
|
-
VectorIconsModule(ReactApplicationContext context) {
|
|
37
|
-
super(context);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Override
|
|
41
|
-
@NonNull
|
|
42
|
-
public String getName() {
|
|
43
|
-
return NAME;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@ReactMethod
|
|
47
|
-
public void loadFontWithFileName(String fontFileName, String extension, Promise promise) {
|
|
48
|
-
promise.reject(Errors.E_NOT_IMPLEMENTED);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ReactMethod
|
|
52
|
-
public void getImageForFont(String fontFamily, String glyph, double fontSize, double color, final Promise promise) {
|
|
53
|
-
try {
|
|
54
|
-
String imagePath = getImageForFontSync(fontFamily, glyph, fontSize, color);
|
|
55
|
-
promise.resolve(imagePath);
|
|
56
|
-
} catch (Throwable fail) {
|
|
57
|
-
promise.reject(Errors.E_UNKNOWN_ERROR, fail);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
62
|
-
public String getImageForFontSync(String fontFamily, String glyph, double fontSizeD, double colorD) throws IOException, FileNotFoundException {
|
|
63
|
-
Context context = getReactApplicationContext();
|
|
64
|
-
File cacheFolder = context.getCacheDir();
|
|
65
|
-
String cacheFolderPath = cacheFolder.getAbsolutePath() + "/";
|
|
66
|
-
|
|
67
|
-
int fontSize = (int)fontSizeD;
|
|
68
|
-
int color = (int)colorD;
|
|
69
|
-
|
|
70
|
-
float scale = context.getResources().getDisplayMetrics().density;
|
|
71
|
-
String scaleSuffix = "@" + (scale == (int) scale ? Integer.toString((int) scale) : Float.toString(scale)) + "x";
|
|
72
|
-
int size = Math.round(fontSize*scale);
|
|
73
|
-
String cacheKey = fontFamily + ":" + glyph + ":" + color;
|
|
74
|
-
String hash = Integer.toString(cacheKey.hashCode(), 32);
|
|
75
|
-
String cacheFilePath = cacheFolderPath + hash + "_" + Integer.toString(fontSize) + scaleSuffix + ".png";
|
|
76
|
-
String cacheFileUrl = "file://" + cacheFilePath;
|
|
77
|
-
File cacheFile = new File(cacheFilePath);
|
|
78
|
-
|
|
79
|
-
if(cacheFile.exists()) {
|
|
80
|
-
return cacheFileUrl;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
FileOutputStream fos = null;
|
|
84
|
-
Typeface typeface = ReactFontManager.getInstance().getTypeface(fontFamily, 0, context.getAssets());
|
|
85
|
-
Paint paint = new Paint();
|
|
86
|
-
paint.setTypeface(typeface);
|
|
87
|
-
paint.setColor(color);
|
|
88
|
-
paint.setTextSize(size);
|
|
89
|
-
paint.setAntiAlias(true);
|
|
90
|
-
Rect textBounds = new Rect();
|
|
91
|
-
paint.getTextBounds(glyph, 0, glyph.length(), textBounds);
|
|
92
|
-
|
|
93
|
-
int offsetX = 0;
|
|
94
|
-
int offsetY = size - (int) paint.getFontMetrics().bottom;
|
|
95
|
-
|
|
96
|
-
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
|
97
|
-
Canvas canvas = new Canvas(bitmap);
|
|
98
|
-
canvas.drawText(glyph, offsetX, offsetY, paint);
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
fos = new FileOutputStream(cacheFile);
|
|
102
|
-
bitmap.compress(CompressFormat.PNG, 100, fos);
|
|
103
|
-
fos.flush();
|
|
104
|
-
fos.close();
|
|
105
|
-
fos = null;
|
|
106
|
-
|
|
107
|
-
return cacheFileUrl;
|
|
108
|
-
}
|
|
109
|
-
finally {
|
|
110
|
-
if (fos != null) {
|
|
111
|
-
try {
|
|
112
|
-
fos.close();
|
|
113
|
-
fos = null;
|
|
114
|
-
}
|
|
115
|
-
catch (IOException e) {
|
|
116
|
-
e.printStackTrace();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
package com.reactnativevectoricons.common;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.NativeModule;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.module.model.ReactModuleInfo;
|
|
8
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
9
|
-
import com.facebook.react.TurboReactPackage;
|
|
10
|
-
|
|
11
|
-
import java.util.HashMap;
|
|
12
|
-
import java.util.Map;
|
|
13
|
-
|
|
14
|
-
public class VectorIconsPackage extends TurboReactPackage {
|
|
15
|
-
|
|
16
|
-
@Nullable
|
|
17
|
-
@Override
|
|
18
|
-
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
19
|
-
if (name.equals(VectorIconsModule.NAME)) {
|
|
20
|
-
return new VectorIconsModule(reactContext);
|
|
21
|
-
} else {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Override
|
|
27
|
-
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
28
|
-
return () -> {
|
|
29
|
-
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
30
|
-
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
31
|
-
moduleInfos.put(
|
|
32
|
-
VectorIconsModule.NAME,
|
|
33
|
-
new ReactModuleInfo(
|
|
34
|
-
VectorIconsModule.NAME,
|
|
35
|
-
VectorIconsModule.NAME,
|
|
36
|
-
false, // canOverrideExistingModule
|
|
37
|
-
false, // needsEagerInit
|
|
38
|
-
true, // hasConstants
|
|
39
|
-
false, // isCxxModule
|
|
40
|
-
isTurboModule // isTurboModule
|
|
41
|
-
));
|
|
42
|
-
return moduleInfos;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
package com.reactnativevectoricons.common;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
5
|
-
import com.facebook.react.bridge.Promise;
|
|
6
|
-
|
|
7
|
-
import java.io.IOException;
|
|
8
|
-
import java.io.FileNotFoundException;
|
|
9
|
-
|
|
10
|
-
abstract class VectorIconsSpec extends ReactContextBaseJavaModule {
|
|
11
|
-
VectorIconsSpec(ReactApplicationContext context) {
|
|
12
|
-
super(context);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public abstract void getImageForFont(String fontFamily, String glyph, double fontSize, double color, final Promise promise);
|
|
16
|
-
public abstract String getImageForFontSync(String fontFamily, String glyph, double fontSize, double color) throws IOException, FileNotFoundException;
|
|
17
|
-
public abstract void loadFontWithFileName(String fontFileName, String extension, Promise promise);
|
|
18
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
export interface Spec extends TurboModule {
|
|
3
|
-
getImageForFont(fontName: string, glyph: string, fontSize: number, color: number): Promise<string>;
|
|
4
|
-
getImageForFontSync(fontName: string, glyph: string, fontSize: number, color: number): string;
|
|
5
|
-
loadFontWithFileName(fontFileName: string, extension: string, subdirectory?: string): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: Spec;
|
|
8
|
-
export default _default;
|
|
9
|
-
//# sourceMappingURL=NativeVectorIcons.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeVectorIcons.d.ts","sourceRoot":"","sources":["../../../src/NativeVectorIcons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE9F,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrG;;AAED,wBAAqE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeVectorIcons.web.d.ts","sourceRoot":"","sources":["../../../src/NativeVectorIcons.web.ts"],"names":[],"mappings":";AAAA,wBAAkB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { type Ref } from 'react';
|
|
2
|
-
import { Text, type TextProps, type TextStyle } from 'react-native';
|
|
3
|
-
export declare const DEFAULT_ICON_SIZE = 12;
|
|
4
|
-
export declare const DEFAULT_ICON_COLOR = "black";
|
|
5
|
-
export type IconProps<T> = TextProps & {
|
|
6
|
-
name: T;
|
|
7
|
-
size?: number;
|
|
8
|
-
color?: TextStyle['color'];
|
|
9
|
-
innerRef?: Ref<Text>;
|
|
10
|
-
};
|
|
11
|
-
export declare const createIconSet: <GM extends Record<string, number>>(glyphMap: GM, fontFamily: string, fontFile: string, fontStyle?: TextProps['style']) => React.ForwardRefExoticComponent<TextProps & {
|
|
12
|
-
name: keyof GM;
|
|
13
|
-
size?: number | undefined;
|
|
14
|
-
color?: TextStyle['color'];
|
|
15
|
-
innerRef?: React.Ref<Text> | undefined;
|
|
16
|
-
} & React.RefAttributes<Text>> & {
|
|
17
|
-
getImageSource: (name: keyof GM, size?: number, color?: TextStyle['color']) => Promise<{
|
|
18
|
-
uri: string;
|
|
19
|
-
scale: number;
|
|
20
|
-
} | undefined>;
|
|
21
|
-
getImageSourceSync: (name: keyof GM, size?: number, color?: TextStyle['color']) => {
|
|
22
|
-
uri: string;
|
|
23
|
-
scale: number;
|
|
24
|
-
} | undefined;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=create-icon-set.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon-set.d.ts","sourceRoot":"","sources":["../../../src/create-icon-set.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAwB,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAgB,MAAM,cAAc,CAAC;AAMxG,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,SAAS,GAAG;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,gDACd,EAAE,cACA,MAAM,YACR,MAAM,cACJ,SAAS,CAAC,OAAO,CAAC;;;YARtB,SAAS,CAAC,OAAO,CAAC;;;2BA2GlB,MAAM,EAAE,yBAEP,SAAS,CAAC,OAAO,CAAC;;;;+BAlCnB,MAAM,EAAE,yBAEP,SAAS,CAAC,OAAO,CAAC;;;;CAuF5B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon-source-cache.d.ts","sourceRoot":"","sources":["../../../src/create-icon-source-cache.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,UAAU,CAAC;AAC3B,QAAA,MAAM,UAAU,UAAU,CAAC;AAE3B,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAErG,MAAM,CAAC,OAAO,UAAU,qBAAqB;oBAGpB,MAAM,SAAS,SAAS;oBAExB,MAAM,SAAS,KAAK;eAEzB,MAAM;eAEN,MAAM;EAczB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-native-module-available.d.ts","sourceRoot":"","sources":["../../../src/ensure-native-module-available.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,2BAA2B,SAMlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFonts.d.ts","sourceRoot":"","sources":["../../../../src/scripts/getFonts.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|