@regulaforensics/face-sdk 8.4.1466-rc → 8.4.1482-nightly

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/Package.swift CHANGED
@@ -10,7 +10,7 @@ let package = Package(
10
10
  .package(url: "https://github.com/apache/cordova-ios.git", branch: "master"),
11
11
  .package(
12
12
  url: "https://github.com/regulaforensics/FaceSDK-Swift-Package",
13
- exact: "8.5.5078-rc"
13
+ exact: "8.5.5098-nightly"
14
14
  )
15
15
  ],
16
16
  targets: [
@@ -31,7 +31,7 @@ dependencies {
31
31
  //noinspection GradleDynamicVersion
32
32
  implementation("com.facebook.react:react-native:+")
33
33
  //noinspection GradleDependency
34
- implementation("com.regula.face:api:8.4.5498") {
34
+ implementation("com.regula.face:api:8.4.5510") {
35
35
  isTransitive = true
36
36
  }
37
37
  }
@@ -11,7 +11,7 @@ repositories {
11
11
 
12
12
  dependencies {
13
13
  //noinspection GradleDependency
14
- add("implementation", "com.regula.face:api:8.4.5498") {
14
+ add("implementation", "com.regula.face:api:8.4.5510") {
15
15
  isTransitive = true
16
16
  }
17
17
  }
@@ -7,6 +7,7 @@ import android.graphics.Bitmap
7
7
  import android.graphics.Point
8
8
  import android.graphics.Rect
9
9
  import android.graphics.Typeface
10
+ import android.os.Build
10
11
  import android.util.Pair
11
12
  import android.util.Size
12
13
  import com.regula.facesdk.configuration.EnrollmentConfiguration
@@ -85,13 +86,19 @@ import java.lang.Float
85
86
 
86
87
  // Config ------------------------------
87
88
 
88
- fun typefaceFromJSON(it: JSONObject) = Pair(
89
- Typeface.create(
90
- it.getString("name"),
91
- it.optInt("style", Typeface.NORMAL)
92
- ),
93
- it.getIntOrNull("size")
94
- )
89
+ @SuppressLint("DiscouragedApi")
90
+ fun typefaceFromJSON(it: JSONObject): Pair<Typeface?, Int?> {
91
+ val name = it.getString("name")
92
+ val font = try {
93
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
94
+ context.resources.getFont(context.resources.getIdentifier(name, "font", context.packageName))
95
+ else null
96
+ } catch (_: Exception) { null }
97
+ return Pair(
98
+ font ?: Typeface.create(name, it.optInt("style", Typeface.NORMAL)),
99
+ it.getIntOrNull("size")
100
+ )
101
+ }
95
102
 
96
103
  fun faceCaptureConfigFromJSON(input: JSONObject) = input.let {
97
104
  val result = FaceCaptureConfiguration.Builder()
@@ -158,7 +158,7 @@ fun Any.setFont(customization: Customization, value: Any) {
158
158
  val uiConfig = customization.uiConfigurationLive.value!!
159
159
  val privateFonts = uiConfig.javaClass.getDeclaredField("f")
160
160
  privateFonts.isAccessible = true
161
- val fonts = privateFonts.get(uiConfig) as HashMap<CustomizationFont, Typeface>
161
+ val fonts = privateFonts.get(uiConfig) as HashMap<CustomizationFont, Typeface?>
162
162
  val privateSizes = uiConfig.javaClass.getDeclaredField("g")
163
163
  privateSizes.isAccessible = true
164
164
  val fontsSizes = privateSizes.get(uiConfig) as HashMap<CustomizationFont, Int>