expo-font 13.1.1 → 13.2.0

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/font/FontUtilsModule.kt +71 -0
  4. package/android/src/main/java/expo/modules/font/FontUtilsRecords.kt +16 -0
  5. package/build/ExpoFontLoader.web.d.ts.map +1 -1
  6. package/build/ExpoFontLoader.web.js +4 -1
  7. package/build/ExpoFontLoader.web.js.map +1 -1
  8. package/build/ExpoFontUtils.d.ts +3 -0
  9. package/build/ExpoFontUtils.d.ts.map +1 -0
  10. package/build/ExpoFontUtils.js +3 -0
  11. package/build/ExpoFontUtils.js.map +1 -0
  12. package/build/ExpoFontUtils.web.d.ts +8 -0
  13. package/build/ExpoFontUtils.web.d.ts.map +1 -0
  14. package/build/ExpoFontUtils.web.js +8 -0
  15. package/build/ExpoFontUtils.web.js.map +1 -0
  16. package/build/FontUtils.d.ts +11 -0
  17. package/build/FontUtils.d.ts.map +1 -0
  18. package/build/FontUtils.js +17 -0
  19. package/build/FontUtils.js.map +1 -0
  20. package/build/FontUtils.types.d.ts +18 -0
  21. package/build/FontUtils.types.d.ts.map +1 -0
  22. package/build/FontUtils.types.js +2 -0
  23. package/build/FontUtils.types.js.map +1 -0
  24. package/build/index.d.ts +1 -0
  25. package/build/index.d.ts.map +1 -1
  26. package/build/index.js +1 -0
  27. package/build/index.js.map +1 -1
  28. package/expo-module.config.json +3 -3
  29. package/ios/FontExceptions.swift +12 -0
  30. package/ios/FontUtilsModule.swift +48 -0
  31. package/ios/FontUtilsRecords.swift +10 -0
  32. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0-sources.jar +0 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0-sources.jar.md5 +1 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0-sources.jar.sha1 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0-sources.jar.sha256 +1 -0
  36. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0-sources.jar.sha512 +1 -0
  37. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.aar +0 -0
  38. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.aar.md5 +1 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.aar.sha1 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.aar.sha256 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.aar.sha512 +1 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.font/{13.1.1/expo.modules.font-13.1.1.module → 13.2.0/expo.modules.font-13.2.0.module} +22 -22
  43. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.module.md5 +1 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.module.sha1 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.module.sha256 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.module.sha512 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.font/{13.1.1/expo.modules.font-13.1.1.pom → 13.2.0/expo.modules.font-13.2.0.pom} +1 -1
  48. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.pom.md5 +1 -0
  49. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.pom.sha1 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.pom.sha256 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.2.0/expo.modules.font-13.2.0.pom.sha512 +1 -0
  52. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml +4 -4
  53. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.md5 +1 -1
  54. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha1 +1 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha256 +1 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha512 +1 -1
  57. package/package.json +4 -3
  58. package/src/ExpoFontLoader.web.ts +4 -1
  59. package/src/ExpoFontUtils.ts +3 -0
  60. package/src/ExpoFontUtils.web.ts +11 -0
  61. package/src/FontUtils.ts +22 -0
  62. package/src/FontUtils.types.ts +17 -0
  63. package/src/index.ts +1 -0
  64. package/src/ts-declarations/react-native-assets.d.ts +1 -0
  65. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1-sources.jar +0 -0
  66. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1-sources.jar.md5 +0 -1
  67. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1-sources.jar.sha1 +0 -1
  68. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1-sources.jar.sha256 +0 -1
  69. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1-sources.jar.sha512 +0 -1
  70. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.aar +0 -0
  71. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.aar.md5 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.aar.sha1 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.aar.sha256 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.aar.sha512 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.module.md5 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.module.sha1 +0 -1
  77. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.module.sha256 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.module.sha512 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.pom.md5 +0 -1
  80. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.pom.sha1 +0 -1
  81. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.pom.sha256 +0 -1
  82. package/local-maven-repo/host/exp/exponent/expo.modules.font/13.1.1/expo.modules.font-13.1.1.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.2.0 — 2025-04-21
14
+
15
+ ### 🎉 New features
16
+
17
+ - Render to image ([#36185](https://github.com/expo/expo/pull/36185) by [@jakex7](https://github.com/jakex7))
18
+
19
+ ## 13.1.2 — 2025-04-14
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 13.1.1 — 2025-04-09
14
24
 
15
25
  _This version does not introduce any user-facing changes._
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '13.1.1'
7
+ version = '13.2.0'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.font"
11
11
  defaultConfig {
12
12
  versionCode 29
13
- versionName "13.1.1"
13
+ versionName "13.2.0"
14
14
  }
15
15
  }
16
16
 
@@ -0,0 +1,71 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ package expo.modules.font
4
+
5
+ import android.content.Context
6
+ import android.graphics.Bitmap
7
+ import android.graphics.Canvas
8
+ import android.graphics.Paint
9
+ import android.graphics.Rect
10
+ import android.graphics.Typeface
11
+ import android.net.Uri
12
+ import com.facebook.react.common.assets.ReactFontManager
13
+ import expo.modules.kotlin.Promise
14
+ import expo.modules.kotlin.exception.CodedException
15
+ import expo.modules.kotlin.exception.Exceptions
16
+ import expo.modules.kotlin.modules.Module
17
+ import expo.modules.kotlin.modules.ModuleDefinition
18
+ import java.io.File
19
+ import java.io.FileOutputStream
20
+ import java.io.IOException
21
+ import java.util.UUID
22
+ import kotlin.math.abs
23
+
24
+ private class SaveImageException(uri: String, cause: Throwable? = null) :
25
+ CodedException("Could not save image to '$uri'", cause)
26
+
27
+ open class FontUtilsModule : Module() {
28
+ private val context: Context
29
+ get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
30
+
31
+ override fun definition() = ModuleDefinition {
32
+ Name("ExpoFontUtils")
33
+
34
+ AsyncFunction("renderToImageAsync") { glyphs: String, options: RenderToImageOptions, promise: Promise ->
35
+ val typeface = ReactFontManager.getInstance().getTypeface(options.fontFamily, Typeface.NORMAL, context.assets)
36
+
37
+ val paint = Paint().apply {
38
+ this.typeface = typeface
39
+ this.color = options.color
40
+ this.textSize = options.size
41
+ this.isAntiAlias = true
42
+ }
43
+
44
+ val bounds = Rect().also {
45
+ paint.getTextBounds(glyphs, 0, glyphs.length, it)
46
+ }
47
+
48
+ val bitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888)
49
+ val canvas = Canvas(bitmap)
50
+
51
+ val x = abs(bounds.left).toFloat()
52
+ val y = bounds.height().toFloat() / 2 - ((paint.fontMetrics.ascent + paint.fontMetrics.descent) / 2)
53
+
54
+ canvas.drawText(glyphs, x, y, paint)
55
+
56
+ val output = File(context.cacheDir, "${UUID.randomUUID()}.png")
57
+ if (!output.exists()) {
58
+ output.createNewFile()
59
+ }
60
+
61
+ try {
62
+ FileOutputStream(output).use { out ->
63
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
64
+ promise.resolve(Uri.fromFile(output))
65
+ }
66
+ } catch (e: IOException) {
67
+ promise.reject(SaveImageException(output.absolutePath, e))
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,16 @@
1
+ package expo.modules.font
2
+
3
+ import android.graphics.Color
4
+ import expo.modules.kotlin.records.Field
5
+ import expo.modules.kotlin.records.Record
6
+
7
+ data class RenderToImageOptions(
8
+ @Field
9
+ val fontFamily: String = "",
10
+
11
+ @Field
12
+ val size: Float = 24f,
13
+
14
+ @Field
15
+ val color: Int = Color.BLACK
16
+ ) : Record
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFontLoader.web.d.ts","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;;sBAiF/B,OAAO,CAAC,IAAI,CAAC;gCASH,MAAM,YAAY,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;0BAS/D,MAAM,EAAE;;sBAqBZ,MAAM,EAAE;6BAQD,MAAM,aAAY,iBAAiB,GAAQ,OAAO;8BAUjD,MAAM,YAAY,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;;AA1D1E,wBA2FE;AAeF,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAIzF"}
1
+ {"version":3,"file":"ExpoFontLoader.web.d.ts","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;;sBAiF/B,OAAO,CAAC,IAAI,CAAC;gCASH,MAAM,YAAY,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;0BAS/D,MAAM,EAAE;;sBAqBZ,MAAM,EAAE;6BAQD,MAAM,aAAY,iBAAiB,GAAQ,OAAO;8BAUjD,MAAM,YAAY,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;;AA1D1E,wBA8FE;AAeF,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAIzF"}
@@ -131,7 +131,10 @@ export default {
131
131
  if (!isFontLoadingListenerSupported()) {
132
132
  return Promise.resolve();
133
133
  }
134
- return new FontObserver(fontFamilyName, { display: resource.display }).load(null, 6000);
134
+ return new FontObserver(fontFamilyName, {
135
+ // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?
136
+ display: resource.display,
137
+ }).load(null, 6000);
135
138
  },
136
139
  };
137
140
  const ID = 'expo-generated-fonts';
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAEzD,SAAS,qBAAqB;IAC5B,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,UAAU,CAAC,KAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC;AAID,SA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,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;IACvC,2EAA2E;IAC3E,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,gCAAgC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5E,iGAAiG;IACjG,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,oBAAoB;IACpB,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3C,UAAU;IACV,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC;AAC/D,CAAC","sourcesContent":["import { CodedError, Platform } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport { UnloadFontOptions } from './Font';\nimport { FontDisplay, FontResource } from './Font.types';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const styleSheet = getStyleElement();\n return styleSheet.sheet ? (styleSheet.sheet as CSSStyleSheet) : null;\n}\n\ntype RuleItem = { rule: CSSFontFaceRule; index: number };\n\nfunction getFontFaceRules(): RuleItem[] {\n const sheet = getFontFaceStyleSheet();\n if (sheet) {\n // @ts-ignore: rule iterator\n const rules = [...sheet.cssRules];\n\n const items: RuleItem[] = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule instanceof CSSFontFaceRule) {\n items.push({ rule, index: i });\n }\n }\n return items;\n }\n return [];\n}\n\nfunction getFontFaceRulesMatchingResource(\n fontFamilyName: string,\n options?: UnloadFontOptions\n): RuleItem[] {\n const rules = getFontFaceRules();\n return rules.filter(({ rule }) => {\n return (\n rule.style.fontFamily === fontFamilyName &&\n (options && options.display ? options.display === (rule.style as any).fontDisplay : true)\n );\n });\n}\n\nconst serverContext: Set<{ name: string; css: string; resourceId: string }> = new Set();\n\nfunction getHeadElements(): {\n $$type: string;\n rel?: string;\n href?: string;\n as?: string;\n crossorigin?: string;\n children?: string;\n id?: string;\n type?: string;\n}[] {\n const entries = [...serverContext.entries()];\n if (!entries.length) {\n return [];\n }\n const css = entries.map(([{ css }]) => css).join('\\n');\n const links = entries.map(([{ resourceId }]) => resourceId);\n // TODO: Maybe return nothing if no fonts were loaded.\n return [\n {\n $$type: 'style',\n children: css,\n id: ID,\n type: 'text/css',\n },\n ...links.map((resourceId) => ({\n $$type: 'link',\n rel: 'preload',\n href: resourceId,\n as: 'font',\n crossorigin: '',\n })),\n ];\n}\n\nexport default {\n async unloadAllAsync(): Promise<void> {\n if (!Platform.isDOMAvailable) return;\n\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n document.removeChild(element);\n }\n },\n\n async unloadAsync(fontFamilyName: string, options?: UnloadFontOptions): Promise<void> {\n const sheet = getFontFaceStyleSheet();\n if (!sheet) return;\n const items = getFontFaceRulesMatchingResource(fontFamilyName, options);\n for (const item of items) {\n sheet.deleteRule(item.index);\n }\n },\n\n getServerResources(): string[] {\n const elements = getHeadElements();\n\n return elements\n .map((element) => {\n switch (element.$$type) {\n case 'style':\n return `<style id=\"${element.id}\" type=\"${element.type}\">${element.children}</style>`;\n case 'link':\n return `<link rel=\"${element.rel}\" href=\"${element.href}\" as=\"${element.as}\" crossorigin=\"${element.crossorigin}\" />`;\n default:\n return '';\n }\n })\n .filter(Boolean);\n },\n\n resetServerContext() {\n serverContext.clear();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return [...serverContext.values()].map(({ name }) => name);\n }\n const rules = getFontFaceRules();\n return rules.map(({ rule }) => rule.style.fontFamily);\n },\n\n isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {\n if (typeof window === 'undefined') {\n return !![...serverContext.values()].find((asset) => {\n return asset.name === fontFamilyName;\n });\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (typeof window === 'undefined') {\n serverContext.add({\n name: fontFamilyName,\n css: _createWebFontTemplate(fontFamilyName, resource),\n // @ts-expect-error: typeof string\n resourceId: resource.uri!,\n });\n return Promise.resolve();\n }\n\n const canInjectStyle = document.head && typeof document.head.appendChild === 'function';\n if (!canInjectStyle) {\n throw new CodedError(\n 'ERR_WEB_ENVIRONMENT',\n `The browser's \\`document.head\\` element doesn't support injecting fonts.`\n );\n }\n\n const style = getStyleElement();\n document.head!.appendChild(style);\n\n const res = getFontFaceRulesMatchingResource(fontFamilyName, resource);\n if (!res.length) {\n _createWebStyle(fontFamilyName, resource);\n }\n\n if (!isFontLoadingListenerSupported()) {\n return Promise.resolve();\n }\n\n return new FontObserver(fontFamilyName, { display: resource.display }).load(null, 6000);\n },\n};\n\nconst ID = 'expo-generated-fonts';\n\nfunction getStyleElement(): HTMLStyleElement {\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n return element;\n }\n const styleElement = document.createElement('style');\n styleElement.id = ID;\n styleElement.type = 'text/css';\n return styleElement;\n}\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n return `@font-face{font-family:${fontFamily};src:url(${resource.uri});font-display:${\n resource.display || FontDisplay.AUTO\n }}`;\n}\n\nfunction _createWebStyle(fontFamily: string, resource: FontResource): HTMLStyleElement {\n const fontStyle = _createWebFontTemplate(fontFamily, resource);\n\n const styleElement = getStyleElement();\n // @ts-ignore: TypeScript does not define HTMLStyleElement::styleSheet. This is just for IE and\n // possibly can be removed if it's unnecessary on IE 11.\n if (styleElement.styleSheet) {\n const styleElementIE = styleElement as any;\n styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText\n ? styleElementIE.styleSheet.cssText + fontStyle\n : fontStyle;\n } else {\n const textNode = document.createTextNode(fontStyle);\n styleElement.appendChild(textNode);\n }\n return styleElement;\n}\n\nfunction isFontLoadingListenerSupported(): boolean {\n const { userAgent } = window.navigator;\n // WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95\n const isIOS = !!userAgent.match(/iPad|iPhone/i);\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n // Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795\n const isEdge = userAgent.includes('Edge');\n // Internet Explorer\n const isIE = userAgent.includes('Trident');\n // Firefox\n const isFirefox = userAgent.includes('Firefox');\n return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;\n}\n"]}
1
+ {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAEzD,SAAS,qBAAqB;IAC5B,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,UAAU,CAAC,KAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC;AAID,SAAS,gBAAgB;IACvB,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;IACtC,IAAI,KAAK,EAAE,CAAC;QACV,4BAA4B;QAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,KAAK,GAAe,EAAE,CAAC;QAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAA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AAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,oBAAoB;IACpB,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3C,UAAU;IACV,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC;AAC/D,CAAC","sourcesContent":["import { CodedError, Platform } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport { UnloadFontOptions } from './Font';\nimport { FontDisplay, FontResource } from './Font.types';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const styleSheet = getStyleElement();\n return styleSheet.sheet ? (styleSheet.sheet as CSSStyleSheet) : null;\n}\n\ntype RuleItem = { rule: CSSFontFaceRule; index: number };\n\nfunction getFontFaceRules(): RuleItem[] {\n const sheet = getFontFaceStyleSheet();\n if (sheet) {\n // @ts-ignore: rule iterator\n const rules = [...sheet.cssRules];\n\n const items: RuleItem[] = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule instanceof CSSFontFaceRule) {\n items.push({ rule, index: i });\n }\n }\n return items;\n }\n return [];\n}\n\nfunction getFontFaceRulesMatchingResource(\n fontFamilyName: string,\n options?: UnloadFontOptions\n): RuleItem[] {\n const rules = getFontFaceRules();\n return rules.filter(({ rule }) => {\n return (\n rule.style.fontFamily === fontFamilyName &&\n (options && options.display ? options.display === (rule.style as any).fontDisplay : true)\n );\n });\n}\n\nconst serverContext: Set<{ name: string; css: string; resourceId: string }> = new Set();\n\nfunction getHeadElements(): {\n $$type: string;\n rel?: string;\n href?: string;\n as?: string;\n crossorigin?: string;\n children?: string;\n id?: string;\n type?: string;\n}[] {\n const entries = [...serverContext.entries()];\n if (!entries.length) {\n return [];\n }\n const css = entries.map(([{ css }]) => css).join('\\n');\n const links = entries.map(([{ resourceId }]) => resourceId);\n // TODO: Maybe return nothing if no fonts were loaded.\n return [\n {\n $$type: 'style',\n children: css,\n id: ID,\n type: 'text/css',\n },\n ...links.map((resourceId) => ({\n $$type: 'link',\n rel: 'preload',\n href: resourceId,\n as: 'font',\n crossorigin: '',\n })),\n ];\n}\n\nexport default {\n async unloadAllAsync(): Promise<void> {\n if (!Platform.isDOMAvailable) return;\n\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n document.removeChild(element);\n }\n },\n\n async unloadAsync(fontFamilyName: string, options?: UnloadFontOptions): Promise<void> {\n const sheet = getFontFaceStyleSheet();\n if (!sheet) return;\n const items = getFontFaceRulesMatchingResource(fontFamilyName, options);\n for (const item of items) {\n sheet.deleteRule(item.index);\n }\n },\n\n getServerResources(): string[] {\n const elements = getHeadElements();\n\n return elements\n .map((element) => {\n switch (element.$$type) {\n case 'style':\n return `<style id=\"${element.id}\" type=\"${element.type}\">${element.children}</style>`;\n case 'link':\n return `<link rel=\"${element.rel}\" href=\"${element.href}\" as=\"${element.as}\" crossorigin=\"${element.crossorigin}\" />`;\n default:\n return '';\n }\n })\n .filter(Boolean);\n },\n\n resetServerContext() {\n serverContext.clear();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return [...serverContext.values()].map(({ name }) => name);\n }\n const rules = getFontFaceRules();\n return rules.map(({ rule }) => rule.style.fontFamily);\n },\n\n isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {\n if (typeof window === 'undefined') {\n return !![...serverContext.values()].find((asset) => {\n return asset.name === fontFamilyName;\n });\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (typeof window === 'undefined') {\n serverContext.add({\n name: fontFamilyName,\n css: _createWebFontTemplate(fontFamilyName, resource),\n // @ts-expect-error: typeof string\n resourceId: resource.uri!,\n });\n return Promise.resolve();\n }\n\n const canInjectStyle = document.head && typeof document.head.appendChild === 'function';\n if (!canInjectStyle) {\n throw new CodedError(\n 'ERR_WEB_ENVIRONMENT',\n `The browser's \\`document.head\\` element doesn't support injecting fonts.`\n );\n }\n\n const style = getStyleElement();\n document.head!.appendChild(style);\n\n const res = getFontFaceRulesMatchingResource(fontFamilyName, resource);\n if (!res.length) {\n _createWebStyle(fontFamilyName, resource);\n }\n\n if (!isFontLoadingListenerSupported()) {\n return Promise.resolve();\n }\n\n return new FontObserver(fontFamilyName, {\n // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?\n display: resource.display,\n }).load(null, 6000);\n },\n};\n\nconst ID = 'expo-generated-fonts';\n\nfunction getStyleElement(): HTMLStyleElement {\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n return element;\n }\n const styleElement = document.createElement('style');\n styleElement.id = ID;\n styleElement.type = 'text/css';\n return styleElement;\n}\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n return `@font-face{font-family:${fontFamily};src:url(${resource.uri});font-display:${\n resource.display || FontDisplay.AUTO\n }}`;\n}\n\nfunction _createWebStyle(fontFamily: string, resource: FontResource): HTMLStyleElement {\n const fontStyle = _createWebFontTemplate(fontFamily, resource);\n\n const styleElement = getStyleElement();\n // @ts-ignore: TypeScript does not define HTMLStyleElement::styleSheet. This is just for IE and\n // possibly can be removed if it's unnecessary on IE 11.\n if (styleElement.styleSheet) {\n const styleElementIE = styleElement as any;\n styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText\n ? styleElementIE.styleSheet.cssText + fontStyle\n : fontStyle;\n } else {\n const textNode = document.createTextNode(fontStyle);\n styleElement.appendChild(textNode);\n }\n return styleElement;\n}\n\nfunction isFontLoadingListenerSupported(): boolean {\n const { userAgent } = window.navigator;\n // WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95\n const isIOS = !!userAgent.match(/iPad|iPhone/i);\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n // Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795\n const isEdge = userAgent.includes('Edge');\n // Internet Explorer\n const isIE = userAgent.includes('Trident');\n // Firefox\n const isFirefox = userAgent.includes('Firefox');\n return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=ExpoFontUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoFontUtils.d.ts","sourceRoot":"","sources":["../src/ExpoFontUtils.ts"],"names":[],"mappings":";AAEA,wBAAoD"}
@@ -0,0 +1,3 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ export default requireNativeModule('ExpoFontUtils');
3
+ //# sourceMappingURL=ExpoFontUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoFontUtils.js","sourceRoot":"","sources":["../src/ExpoFontUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAe,mBAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\nexport default requireNativeModule('ExpoFontUtils');\n"]}
@@ -0,0 +1,8 @@
1
+ import { NativeModule } from 'expo-modules-core';
2
+ import { RenderToImageOptions } from './FontUtils.types';
3
+ declare class ExpoFontUtils extends NativeModule {
4
+ renderToImageAsync(glyphs: string, options?: RenderToImageOptions): Promise<string>;
5
+ }
6
+ declare const _default: typeof ExpoFontUtils;
7
+ export default _default;
8
+ //# sourceMappingURL=ExpoFontUtils.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoFontUtils.web.d.ts","sourceRoot":"","sources":["../src/ExpoFontUtils.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0C,MAAM,mBAAmB,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,cAAM,aAAc,SAAQ,YAAY;IAChC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;CAG1F;;AAED,wBAAiE"}
@@ -0,0 +1,8 @@
1
+ import { NativeModule, registerWebModule, UnavailabilityError } from 'expo-modules-core';
2
+ class ExpoFontUtils extends NativeModule {
3
+ async renderToImageAsync(glyphs, options) {
4
+ throw new UnavailabilityError('expo-font', 'renderToImageAsync');
5
+ }
6
+ }
7
+ export default registerWebModule(ExpoFontUtils, 'ExpoFontUtils');
8
+ //# sourceMappingURL=ExpoFontUtils.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoFontUtils.web.js","sourceRoot":"","sources":["../src/ExpoFontUtils.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIzF,MAAM,aAAc,SAAQ,YAAY;IACtC,KAAK,CAAC,kBAAkB,CAAC,MAAc,EAAE,OAA8B;QACrE,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IACnE,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { NativeModule, registerWebModule, UnavailabilityError } from 'expo-modules-core';\n\nimport { RenderToImageOptions } from './FontUtils.types';\n\nclass ExpoFontUtils extends NativeModule {\n async renderToImageAsync(glyphs: string, options?: RenderToImageOptions): Promise<string> {\n throw new UnavailabilityError('expo-font', 'renderToImageAsync');\n }\n}\n\nexport default registerWebModule(ExpoFontUtils, 'ExpoFontUtils');\n"]}
@@ -0,0 +1,11 @@
1
+ import { RenderToImageOptions } from './FontUtils.types';
2
+ /**
3
+ * Creates an image with provided text.
4
+ * @param glyphs Text to be exported.
5
+ * @param options RenderToImageOptions.
6
+ * @return Promise which fulfils with uri to image.
7
+ * @platform android
8
+ * @platform ios
9
+ */
10
+ export declare function renderToImageAsync(glyphs: string, options?: RenderToImageOptions): Promise<string>;
11
+ //# sourceMappingURL=FontUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontUtils.d.ts","sourceRoot":"","sources":["../src/FontUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAKjB"}
@@ -0,0 +1,17 @@
1
+ import { processColor } from 'react-native';
2
+ import ExpoFontUtils from './ExpoFontUtils';
3
+ /**
4
+ * Creates an image with provided text.
5
+ * @param glyphs Text to be exported.
6
+ * @param options RenderToImageOptions.
7
+ * @return Promise which fulfils with uri to image.
8
+ * @platform android
9
+ * @platform ios
10
+ */
11
+ export async function renderToImageAsync(glyphs, options) {
12
+ return await ExpoFontUtils.renderToImageAsync(glyphs, {
13
+ ...options,
14
+ color: options?.color ? processColor(options.color) : undefined,
15
+ });
16
+ }
17
+ //# sourceMappingURL=FontUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontUtils.js","sourceRoot":"","sources":["../src/FontUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,OAA8B;IAE9B,OAAO,MAAM,aAAa,CAAC,kBAAkB,CAAC,MAAM,EAAE;QACpD,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;KAChE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { processColor } from 'react-native';\n\nimport ExpoFontUtils from './ExpoFontUtils';\nimport { RenderToImageOptions } from './FontUtils.types';\n\n/**\n * Creates an image with provided text.\n * @param glyphs Text to be exported.\n * @param options RenderToImageOptions.\n * @return Promise which fulfils with uri to image.\n * @platform android\n * @platform ios\n */\nexport async function renderToImageAsync(\n glyphs: string,\n options?: RenderToImageOptions\n): Promise<string> {\n return await ExpoFontUtils.renderToImageAsync(glyphs, {\n ...options,\n color: options?.color ? processColor(options.color) : undefined,\n });\n}\n"]}
@@ -0,0 +1,18 @@
1
+ export interface RenderToImageOptions {
2
+ /**
3
+ * Font family name.
4
+ * @default system default
5
+ */
6
+ fontFamily?: string;
7
+ /**
8
+ * Size of the font.
9
+ * @default 24
10
+ */
11
+ size?: number;
12
+ /**
13
+ * Font color
14
+ * @default 'black'
15
+ */
16
+ color?: string;
17
+ }
18
+ //# sourceMappingURL=FontUtils.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontUtils.types.d.ts","sourceRoot":"","sources":["../src/FontUtils.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FontUtils.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontUtils.types.js","sourceRoot":"","sources":["../src/FontUtils.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface RenderToImageOptions {\n /**\n * Font family name.\n * @default system default\n */\n fontFamily?: string;\n /**\n * Size of the font.\n * @default 24\n */\n size?: number;\n /**\n * Font color\n * @default 'black'\n */\n color?: string;\n}\n"]}
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './Font';
2
+ export * from './FontUtils';
2
3
  export { useFonts } from './FontHooks';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
package/build/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './Font';
2
+ export * from './FontUtils';
2
3
  export { useFonts } from './FontHooks';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export * from './Font';\nexport { useFonts } from './FontHooks';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export * from './Font';\nexport * from './FontUtils';\nexport { useFonts } from './FontHooks';\n"]}
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "platforms": ["apple", "android", "web"],
3
3
  "apple": {
4
- "modules": ["FontLoaderModule"]
4
+ "modules": ["FontLoaderModule", "FontUtilsModule"]
5
5
  },
6
6
  "android": {
7
- "modules": ["expo.modules.font.FontLoaderModule"],
7
+ "modules": ["expo.modules.font.FontLoaderModule", "expo.modules.font.FontUtilsModule"],
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.font",
11
- "version": "13.1.1",
11
+ "version": "13.2.0",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -36,3 +36,15 @@ internal final class UnregisteringFontFailedException: GenericException<CFError>
36
36
  "Unregistering font failed with message: '\(param.localizedDescription)'"
37
37
  }
38
38
  }
39
+
40
+ internal final class CreateImageException: Exception {
41
+ override var reason: String {
42
+ "Could not create image"
43
+ }
44
+ }
45
+
46
+ internal final class SaveImageException: GenericException<String> {
47
+ override var reason: String {
48
+ "Could not save image to '\(param)'"
49
+ }
50
+ }
@@ -0,0 +1,48 @@
1
+ // Copyright 2025-present 650 Industries. All rights reserved.
2
+
3
+ import ExpoModulesCore
4
+
5
+ public final class FontUtilsModule: Module {
6
+ public func definition() -> ModuleDefinition {
7
+ Name("ExpoFontUtils")
8
+
9
+ #if !os(macOS)
10
+ AsyncFunction("renderToImageAsync") { (glyphs: String, options: RenderToImageOptions, promise: Promise) throws in
11
+ let font: UIFont
12
+ if let fontName = UIFont.fontNames(forFamilyName: options.fontFamily).first,
13
+ let uiFont = UIFont(name: fontName, size: options.size) {
14
+ font = uiFont
15
+ } else {
16
+ font = UIFont.systemFont(ofSize: options.size)
17
+ }
18
+
19
+ let attributedString = NSAttributedString(
20
+ string: glyphs,
21
+ attributes: [
22
+ .font: font,
23
+ .foregroundColor: UIColor(options.color)
24
+ ]
25
+ )
26
+
27
+ let renderer = UIGraphicsImageRenderer(size: attributedString.size())
28
+ let image = renderer.image { _ in
29
+ attributedString.draw(at: .zero)
30
+ }
31
+
32
+ guard let data = image.pngData() else {
33
+ promise.reject(CreateImageException())
34
+ return
35
+ }
36
+
37
+ let outputURL = URL(fileURLWithPath: "\(NSTemporaryDirectory())\(UUID().uuidString).png")
38
+
39
+ do {
40
+ try data.write(to: outputURL, options: .atomic)
41
+ promise.resolve(outputURL.absoluteString)
42
+ } catch {
43
+ promise.reject(SaveImageException(outputURL.absoluteString))
44
+ }
45
+ }
46
+ #endif
47
+ }
48
+ }
@@ -0,0 +1,10 @@
1
+ // Copyright 2025-present 650 Industries. All rights reserved.
2
+
3
+ import SwiftUI
4
+ import ExpoModulesCore
5
+
6
+ struct RenderToImageOptions: Record {
7
+ @Field var fontFamily: String = ""
8
+ @Field var size: CGFloat = 24
9
+ @Field var color: Color = .black
10
+ }
@@ -0,0 +1 @@
1
+ c029366141433ab312f41026590eb119ef648137f3b6cebeb416531fc0b4cccc
@@ -0,0 +1 @@
1
+ 04d8003327d266d74c7c2123206ff0c008db185c4fe9ce8518e6c47af1ed8d3118db35e094ceb19451c622318ac15e9fa9eaea609d7fae69cedec95e1656c20a
@@ -0,0 +1 @@
1
+ 8a3e0658bef6d46ddbdfaf891baba11daaadbfc8
@@ -0,0 +1 @@
1
+ 02e3e22b8a6570b0a9ae2d3fff74bcb898a90480d271d162ef76c2c6415fd763
@@ -0,0 +1 @@
1
+ 23e09b1c63cedb2c4e2063a509bdd0ecb91c8815cb946ef3707fba50b7ca2f4ac3c20d825847a1885cec0fd3c29dbd153d730acc552a33e5c031928551c707ab
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.font",
6
- "version": "13.1.1",
6
+ "version": "13.2.0",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.font-13.1.1.aar",
28
- "url": "expo.modules.font-13.1.1.aar",
29
- "size": 13045,
30
- "sha512": "6b0d739ff6720adf9bcefcfde410dd8b4c1cd8783abf788d42b429a51caed98dcce305b30ab4ec82dabc0379b46f344ca0581ed1b281b09e1c568319e2563bc5",
31
- "sha256": "df73df860315a2f01896ec47d5ed6740b9b3f7339d47d0418360859f05fe1088",
32
- "sha1": "ac0cf41e2f0905c4d87505fa1bfa5c4bb9ebb0a9",
33
- "md5": "28ac3500cafc491337446819fbff1ed9"
27
+ "name": "expo.modules.font-13.2.0.aar",
28
+ "url": "expo.modules.font-13.2.0.aar",
29
+ "size": 23940,
30
+ "sha512": "23e09b1c63cedb2c4e2063a509bdd0ecb91c8815cb946ef3707fba50b7ca2f4ac3c20d825847a1885cec0fd3c29dbd153d730acc552a33e5c031928551c707ab",
31
+ "sha256": "02e3e22b8a6570b0a9ae2d3fff74bcb898a90480d271d162ef76c2c6415fd763",
32
+ "sha1": "8a3e0658bef6d46ddbdfaf891baba11daaadbfc8",
33
+ "md5": "c4a5fbec91ef91f550b4a16b8011c1da"
34
34
  }
35
35
  ]
36
36
  },
@@ -57,13 +57,13 @@
57
57
  ],
58
58
  "files": [
59
59
  {
60
- "name": "expo.modules.font-13.1.1.aar",
61
- "url": "expo.modules.font-13.1.1.aar",
62
- "size": 13045,
63
- "sha512": "6b0d739ff6720adf9bcefcfde410dd8b4c1cd8783abf788d42b429a51caed98dcce305b30ab4ec82dabc0379b46f344ca0581ed1b281b09e1c568319e2563bc5",
64
- "sha256": "df73df860315a2f01896ec47d5ed6740b9b3f7339d47d0418360859f05fe1088",
65
- "sha1": "ac0cf41e2f0905c4d87505fa1bfa5c4bb9ebb0a9",
66
- "md5": "28ac3500cafc491337446819fbff1ed9"
60
+ "name": "expo.modules.font-13.2.0.aar",
61
+ "url": "expo.modules.font-13.2.0.aar",
62
+ "size": 23940,
63
+ "sha512": "23e09b1c63cedb2c4e2063a509bdd0ecb91c8815cb946ef3707fba50b7ca2f4ac3c20d825847a1885cec0fd3c29dbd153d730acc552a33e5c031928551c707ab",
64
+ "sha256": "02e3e22b8a6570b0a9ae2d3fff74bcb898a90480d271d162ef76c2c6415fd763",
65
+ "sha1": "8a3e0658bef6d46ddbdfaf891baba11daaadbfc8",
66
+ "md5": "c4a5fbec91ef91f550b4a16b8011c1da"
67
67
  }
68
68
  ]
69
69
  },
@@ -77,13 +77,13 @@
77
77
  },
78
78
  "files": [
79
79
  {
80
- "name": "expo.modules.font-13.1.1-sources.jar",
81
- "url": "expo.modules.font-13.1.1-sources.jar",
82
- "size": 2181,
83
- "sha512": "922d17ab9404230df7a55676e7c308ad010b49278562a12051eb7f8f518683f2020eabb96ae0ee79b908dd49572830eea6d9cf7c579ef5db7be04ef2c864a093",
84
- "sha256": "857820932e52dbe80e0f58011d164e892ed37213dd74c3dc30fe70739d0f94fa",
85
- "sha1": "82b8aba4d9525e564f2cbc4299b3623fe5304232",
86
- "md5": "584be3c85f2cea79a438cb3029de44b1"
80
+ "name": "expo.modules.font-13.2.0-sources.jar",
81
+ "url": "expo.modules.font-13.2.0-sources.jar",
82
+ "size": 3643,
83
+ "sha512": "04d8003327d266d74c7c2123206ff0c008db185c4fe9ce8518e6c47af1ed8d3118db35e094ceb19451c622318ac15e9fa9eaea609d7fae69cedec95e1656c20a",
84
+ "sha256": "c029366141433ab312f41026590eb119ef648137f3b6cebeb416531fc0b4cccc",
85
+ "sha1": "58f3bf67ec556651368352816436127f20c27a0c",
86
+ "md5": "85fa250981be0d9c2cfe380914137d32"
87
87
  }
88
88
  ]
89
89
  }
@@ -0,0 +1 @@
1
+ 32487e83f3483cd8f9494f9595ee19c1680d8641d9565832dd5ef6edf6285336
@@ -0,0 +1 @@
1
+ 6919cb414a23fc083a174a869e3701e577eaed75907051f81dc69d67465437a805fb88268810becee817b68fe933d1ec87cf28b87cc6d1c31915b497954956d8
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.font</artifactId>
12
- <version>13.1.1</version>
12
+ <version>13.2.0</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.font</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 22d6632a3c482e6a9d87335cc784380ddb84c413
@@ -0,0 +1 @@
1
+ 2329a4ecf3f9a2f1ac66221df5bfda3e42217dc3c699129253159dabd39ba9a8
@@ -0,0 +1 @@
1
+ eb22c4fa3fd2c30dbe8f58c226f0d9820b04940182ad553cec0e78bb4324d2bac4a6cdc89198a0d9bb3e58b24c7d6600aa028855da52ca34eb5b935c34ac1289
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.font</artifactId>
5
5
  <versioning>
6
- <latest>13.1.1</latest>
7
- <release>13.1.1</release>
6
+ <latest>13.2.0</latest>
7
+ <release>13.2.0</release>
8
8
  <versions>
9
- <version>13.1.1</version>
9
+ <version>13.2.0</version>
10
10
  </versions>
11
- <lastUpdated>20250409202809</lastUpdated>
11
+ <lastUpdated>20250421213308</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- d3167907b5e4411a213dec5782eae5d7
1
+ 03e013cfd9238f8e9bd83c76751baa30
@@ -1 +1 @@
1
- c30e2ff0239e12c28c727a04b383282694a098c5
1
+ 71d5799b8f1517ce9c837dd1105a3c1bf4b12842
@@ -1 +1 @@
1
- b6724bd077f7ff49376e30f1939d6821da92434ff13752ae1711d43262bdddc7
1
+ 9be03f2203a7220638e78d74824e54553443db59a5f71a8f0c5a1c60f6ab59b0
@@ -1 +1 @@
1
- c784c9ff64ba64bf85ca55ecbeb97f5ea0260a302e56308e8fba50307c20f39ef650588adf38a7263c046abd27698b12fa3ed8f852c8f245b8252c548af88146
1
+ 9a1c6d59d8c1637d2c8e9c069de5549f9fdc760b8a8d0e8462692e71ed57117c9aede5de1cffd52489da29e3af1b6509472e5bf344b26e10d43e7ca50608604b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "13.1.1",
3
+ "version": "13.2.0",
4
4
  "description": "Load fonts at runtime and use them in React Native components.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -49,11 +49,12 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@testing-library/react-native": "^13.1.0",
52
- "expo-module-scripts": "^4.1.1"
52
+ "@types/fontfaceobserver": "^2.1.3",
53
+ "expo-module-scripts": "^4.1.2"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "expo": "*",
56
57
  "react": "*"
57
58
  },
58
- "gitHead": "1914bb35d23af23078da37e70988261844436505"
59
+ "gitHead": "f1394f21ff2719a9a3037d7511db170704e5c492"
59
60
  }
@@ -171,7 +171,10 @@ export default {
171
171
  return Promise.resolve();
172
172
  }
173
173
 
174
- return new FontObserver(fontFamilyName, { display: resource.display }).load(null, 6000);
174
+ return new FontObserver(fontFamilyName, {
175
+ // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?
176
+ display: resource.display,
177
+ }).load(null, 6000);
175
178
  },
176
179
  };
177
180
 
@@ -0,0 +1,3 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+
3
+ export default requireNativeModule('ExpoFontUtils');
@@ -0,0 +1,11 @@
1
+ import { NativeModule, registerWebModule, UnavailabilityError } from 'expo-modules-core';
2
+
3
+ import { RenderToImageOptions } from './FontUtils.types';
4
+
5
+ class ExpoFontUtils extends NativeModule {
6
+ async renderToImageAsync(glyphs: string, options?: RenderToImageOptions): Promise<string> {
7
+ throw new UnavailabilityError('expo-font', 'renderToImageAsync');
8
+ }
9
+ }
10
+
11
+ export default registerWebModule(ExpoFontUtils, 'ExpoFontUtils');
@@ -0,0 +1,22 @@
1
+ import { processColor } from 'react-native';
2
+
3
+ import ExpoFontUtils from './ExpoFontUtils';
4
+ import { RenderToImageOptions } from './FontUtils.types';
5
+
6
+ /**
7
+ * Creates an image with provided text.
8
+ * @param glyphs Text to be exported.
9
+ * @param options RenderToImageOptions.
10
+ * @return Promise which fulfils with uri to image.
11
+ * @platform android
12
+ * @platform ios
13
+ */
14
+ export async function renderToImageAsync(
15
+ glyphs: string,
16
+ options?: RenderToImageOptions
17
+ ): Promise<string> {
18
+ return await ExpoFontUtils.renderToImageAsync(glyphs, {
19
+ ...options,
20
+ color: options?.color ? processColor(options.color) : undefined,
21
+ });
22
+ }
@@ -0,0 +1,17 @@
1
+ export interface RenderToImageOptions {
2
+ /**
3
+ * Font family name.
4
+ * @default system default
5
+ */
6
+ fontFamily?: string;
7
+ /**
8
+ * Size of the font.
9
+ * @default 24
10
+ */
11
+ size?: number;
12
+ /**
13
+ * Font color
14
+ * @default 'black'
15
+ */
16
+ color?: string;
17
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './Font';
2
+ export * from './FontUtils';
2
3
  export { useFonts } from './FontHooks';
@@ -0,0 +1 @@
1
+ /// <reference path="../../../expo-asset/src/ts-declarations/react-native-assets.d.ts" />
@@ -1 +0,0 @@
1
- 857820932e52dbe80e0f58011d164e892ed37213dd74c3dc30fe70739d0f94fa
@@ -1 +0,0 @@
1
- 922d17ab9404230df7a55676e7c308ad010b49278562a12051eb7f8f518683f2020eabb96ae0ee79b908dd49572830eea6d9cf7c579ef5db7be04ef2c864a093
@@ -1 +0,0 @@
1
- ac0cf41e2f0905c4d87505fa1bfa5c4bb9ebb0a9
@@ -1 +0,0 @@
1
- df73df860315a2f01896ec47d5ed6740b9b3f7339d47d0418360859f05fe1088
@@ -1 +0,0 @@
1
- 6b0d739ff6720adf9bcefcfde410dd8b4c1cd8783abf788d42b429a51caed98dcce305b30ab4ec82dabc0379b46f344ca0581ed1b281b09e1c568319e2563bc5
@@ -1 +0,0 @@
1
- c19a3a9d984ac22cdb1d0a4ae536ce1b648ea9c5
@@ -1 +0,0 @@
1
- 46723b5fb554fad114adeec00e3b5bc2cc896d1b016294f74c49fd6ff0be2e7d
@@ -1 +0,0 @@
1
- a93a222d6299ccda24ffa9075021cfc5a912c07764e1af8dc5070a65dfb90fe919d60d0fe7d7ff03feb85fe5e4d87dcfe1d28c6a0ceeef088cfbd36a93354ba5
@@ -1 +0,0 @@
1
- dfb73d9881eb258749f74826e800594c6040e29a
@@ -1 +0,0 @@
1
- 61ae2886c0122423a516cf8d8fda69ce601776f0761dee4e15efddc436dfde85
@@ -1 +0,0 @@
1
- ccc71a66e8c82cfd297c79af7d611e978dc1de1f7176cdc4afa1b6667d613ff7ab6a07fc0605063084b17a68edc3d57ecce11d63fa166725333473355b53ab86