expo-font 57.0.0 → 57.0.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/android/build.gradle +2 -2
  3. package/build/ExpoFontLoader.web.d.ts.map +1 -1
  4. package/build/ExpoFontLoader.web.js +17 -3
  5. package/build/ExpoFontLoader.web.js.map +1 -1
  6. package/expo-module.config.json +1 -1
  7. package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.module → 57.0.2/expo.modules.font-57.0.2.module} +7 -7
  8. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.module.md5 +1 -0
  9. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.module.sha1 +1 -0
  10. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.module.sha256 +1 -0
  11. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.module.sha512 +1 -0
  12. package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.pom → 57.0.2/expo.modules.font-57.0.2.pom} +1 -1
  13. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.pom.md5 +1 -0
  14. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.pom.sha1 +1 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.pom.sha256 +1 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.2/expo.modules.font-57.0.2.pom.sha512 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml +4 -4
  18. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.md5 +1 -1
  19. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha1 +1 -1
  20. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha256 +1 -1
  21. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha512 +1 -1
  22. package/package.json +3 -3
  23. package/prebuilds/output/debug/xcframeworks/ExpoFont.tar.gz +0 -0
  24. package/prebuilds/output/release/xcframeworks/ExpoFont.tar.gz +0 -0
  25. package/src/ExpoFontLoader.web.ts +18 -3
  26. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.module.md5 +0 -1
  27. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.module.sha1 +0 -1
  28. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.module.sha256 +0 -1
  29. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.module.sha512 +0 -1
  30. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.pom.md5 +0 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.pom.sha1 +0 -1
  32. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.pom.sha256 +0 -1
  33. package/local-maven-repo/host/exp/exponent/expo.modules.font/57.0.0/expo.modules.font-57.0.0.pom.sha512 +0 -1
  34. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0-sources.jar → 57.0.2/expo.modules.font-57.0.2-sources.jar} +0 -0
  35. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0-sources.jar.md5 → 57.0.2/expo.modules.font-57.0.2-sources.jar.md5} +0 -0
  36. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0-sources.jar.sha1 → 57.0.2/expo.modules.font-57.0.2-sources.jar.sha1} +0 -0
  37. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0-sources.jar.sha256 → 57.0.2/expo.modules.font-57.0.2-sources.jar.sha256} +0 -0
  38. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0-sources.jar.sha512 → 57.0.2/expo.modules.font-57.0.2-sources.jar.sha512} +0 -0
  39. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.aar → 57.0.2/expo.modules.font-57.0.2.aar} +0 -0
  40. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.aar.md5 → 57.0.2/expo.modules.font-57.0.2.aar.md5} +0 -0
  41. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.aar.sha1 → 57.0.2/expo.modules.font-57.0.2.aar.sha1} +0 -0
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.aar.sha256 → 57.0.2/expo.modules.font-57.0.2.aar.sha256} +0 -0
  43. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{57.0.0/expo.modules.font-57.0.0.aar.sha512 → 57.0.2/expo.modules.font-57.0.2.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,17 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 57.0.2 — 2026-08-28
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [web] Fixed `isLoaded()` always returning `false` on Firefox, and on every engine for font families whose name needs quoting, by normalizing quotes when comparing family names against the CSSOM. This also stops `loadAsync()` from injecting a duplicate `@font-face` rule on every call and makes `unloadAsync()` and `getLoadedFonts()` behave consistently across engines. ([#49266](https://github.com/expo/expo/pull/49266) by [@irfanfandi](https://github.com/irfanfandi))
18
+ - [web] Match `@font-face` rules by comparing the rule's bare family name against the caller's literal name, so families whose names contain quotes or padding resolve correctly, and fixed `unloadAsync()` deleting wrong rules when several rules match. ([#49379](https://github.com/expo/expo/pull/49379) by [@vonovak](https://github.com/vonovak))
19
+
20
+ ## 57.0.1 — 2026-07-15
21
+
22
+ _This version does not introduce any user-facing changes._
23
+
13
24
  ## 57.0.0 — 2026-06-25
14
25
 
15
26
  ### 🛠 Breaking changes
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '57.0.0'
7
+ version = '57.0.2'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.font"
11
11
  defaultConfig {
12
12
  versionCode 29
13
- versionName "57.0.0"
13
+ versionName "57.0.2"
14
14
  }
15
15
  }
16
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFontLoader.web.d.ts","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAkD9D,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,oBAAoB,CAoGlD,CAAC;wBAcyB,OAAO,cAAc;AAAhD,wBAAiD;AAiBjD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAQzF"}
1
+ {"version":3,"file":"ExpoFontLoader.web.d.ts","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAiE9D,QAAA,MAAM,cAAc,EAAE,QAAQ,CAAC,oBAAoB,CAoGlD,CAAC;wBAcyB,OAAO,cAAc;AAAhD,wBAAiD;AAiBjD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAQzF"}
@@ -25,10 +25,24 @@ function getFontFaceRules() {
25
25
  }
26
26
  return [];
27
27
  }
28
+ // `_createWebFontTemplate` writes the family name quoted, but engines disagree about whether
29
+ // the CSSOM keeps the quotes (Firefox always does), so normalize them away before comparing.
30
+ function normalizeFontFamilyName(fontFamily) {
31
+ // jsdom leaves `style.fontFamily` undefined on the `@font-face` rules it parses.
32
+ const trimmed = fontFamily?.trim();
33
+ if (!trimmed) {
34
+ return '';
35
+ }
36
+ const quote = trimmed[0];
37
+ if (trimmed.length >= 2 && (quote === '"' || quote === "'") && trimmed.endsWith(quote)) {
38
+ return trimmed.slice(1, -1).replace(/\\(.)/g, '$1');
39
+ }
40
+ return trimmed;
41
+ }
28
42
  function getFontFaceRulesMatchingResource(fontFamilyName, options) {
29
43
  const rules = getFontFaceRules();
30
44
  return rules.filter(({ rule }) => {
31
- return (rule.style.fontFamily === fontFamilyName &&
45
+ return (normalizeFontFamilyName(rule.style.fontFamily) === fontFamilyName &&
32
46
  (options && options.display ? options.display === rule.style.fontDisplay : true));
33
47
  });
34
48
  }
@@ -46,7 +60,7 @@ const ExpoFontLoader = {
46
60
  if (!sheet)
47
61
  return;
48
62
  const items = getFontFaceRulesMatchingResource(fontFamilyName, options);
49
- for (const item of items) {
63
+ for (const item of items.reverse()) {
50
64
  sheet.deleteRule(item.index);
51
65
  }
52
66
  },
@@ -73,7 +87,7 @@ const ExpoFontLoader = {
73
87
  return getLoadedServerFonts();
74
88
  }
75
89
  const rules = getFontFaceRules();
76
- return rules.map(({ rule }) => rule.style.fontFamily);
90
+ return rules.map(({ rule }) => normalizeFontFamilyName(rule.style.fontFamily));
77
91
  },
78
92
  isLoaded(fontFamilyName, resource = {}) {
79
93
  if (typeof window === 'undefined') {
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE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,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,8BAA8B;IACrC,MAAM,EAAE,SAAS,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,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["import { CodedError, registerWebModule } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport type { ExpoFontLoaderModule } from './ExpoFontLoader';\nimport type { UnloadFontOptions } from './Font';\nimport { FontDisplay, type FontResource } from './Font.types';\nimport {\n addServerFont,\n getLoadedServerFonts,\n getServerResourceDescriptors as readServerResourceDescriptors,\n isServerFontLoaded,\n} from './serverContext';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (typeof window === 'undefined') {\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 ExpoFontLoader: Required<ExpoFontLoaderModule> = {\n async unloadAllAsync(): Promise<void> {\n if (typeof window === 'undefined') 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 = readServerResourceDescriptors();\n\n return elements\n .map((element) => {\n switch (element.type) {\n case 'style':\n return `<style id=\"${element.id}\">${element.css}</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 getServerResourceDescriptors() {\n return readServerResourceDescriptors();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return getLoadedServerFonts();\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 isServerFontLoaded(fontFamilyName);\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(vonovak): This is used in RN vector-icons to load fonts dynamically on web. Changing the signature is breaking.\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (__DEV__ && typeof resource !== 'object') {\n // to help devving on web, where loadAsync interface is different from native\n throw new CodedError(\n 'ERR_FONT_SOURCE',\n `Expected font resource of type \\`object\\` instead got: ${typeof resource}`\n );\n }\n if (typeof window === 'undefined') {\n addServerFont({\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(resource.testString ?? null, 12000);\n },\n};\n\nconst isServer = process.env.EXPO_OS === 'web' && typeof window === 'undefined';\n\nfunction createExpoFontLoader() {\n return ExpoFontLoader;\n}\nconst toExport = isServer\n ? ExpoFontLoader\n : // @ts-expect-error: registerWebModule calls `new` on the module implementation.\n // Normally that'd be a class but that doesn't work on server, so we use a function instead.\n // TS doesn't like that but we don't need it to be a class.\n registerWebModule(createExpoFontLoader, 'ExpoFontLoader');\n\nexport default toExport as typeof ExpoFontLoader;\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\n return styleElement;\n}\n\nconst CSS_IDENT_RE = /^[a-zA-Z_-][\\w-]*$/;\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n const display =\n typeof resource.display === 'string' && CSS_IDENT_RE.test(resource.display)\n ? resource.display\n : FontDisplay.AUTO;\n return `@font-face{font-family:${JSON.stringify(fontFamily)};src:url(${JSON.stringify(\n resource.uri\n )});font-display:${display}}`;\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 return !isSafari && !isIOS && !isEdge && !isIE;\n}\n"]}
1
+ {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,4BAA4B,IAAI,6BAA6B,EAC7D,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,SAAS,qBAAqB;IAC5B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Q,CAAC,CAAC;IAE/D,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,+FAA+F;IAC/F,wDAAwD;IACxD,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC;QAC5B,MAAM,cAAc,GAAG,YAAmB,CAAC;QAC3C,cAAc,CAAC,UAAU,CAAC,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC,OAAO;YACnE,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,GAAG,SAAS;YAC/C,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,8BAA8B;IACrC,MAAM,EAAE,SAAS,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,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["import { CodedError, registerWebModule } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport type { ExpoFontLoaderModule } from './ExpoFontLoader';\nimport type { UnloadFontOptions } from './Font';\nimport { FontDisplay, type FontResource } from './Font.types';\nimport {\n addServerFont,\n getLoadedServerFonts,\n getServerResourceDescriptors as readServerResourceDescriptors,\n isServerFontLoaded,\n} from './serverContext';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (typeof window === 'undefined') {\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\n// `_createWebFontTemplate` writes the family name quoted, but engines disagree about whether\n// the CSSOM keeps the quotes (Firefox always does), so normalize them away before comparing.\nfunction normalizeFontFamilyName(fontFamily: string): string {\n // jsdom leaves `style.fontFamily` undefined on the `@font-face` rules it parses.\n const trimmed = fontFamily?.trim();\n if (!trimmed) {\n return '';\n }\n const quote = trimmed[0];\n if (trimmed.length >= 2 && (quote === '\"' || quote === \"'\") && trimmed.endsWith(quote)) {\n return trimmed.slice(1, -1).replace(/\\\\(.)/g, '$1');\n }\n return trimmed;\n}\n\nfunction getFontFaceRulesMatchingResource(\n fontFamilyName: string,\n options?: UnloadFontOptions\n): RuleItem[] {\n const rules = getFontFaceRules();\n return rules.filter(({ rule }) => {\n return (\n normalizeFontFamilyName(rule.style.fontFamily) === fontFamilyName &&\n (options && options.display ? options.display === (rule.style as any).fontDisplay : true)\n );\n });\n}\n\nconst ExpoFontLoader: Required<ExpoFontLoaderModule> = {\n async unloadAllAsync(): Promise<void> {\n if (typeof window === 'undefined') 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.reverse()) {\n sheet.deleteRule(item.index);\n }\n },\n\n getServerResources(): string[] {\n const elements = readServerResourceDescriptors();\n\n return elements\n .map((element) => {\n switch (element.type) {\n case 'style':\n return `<style id=\"${element.id}\">${element.css}</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 getServerResourceDescriptors() {\n return readServerResourceDescriptors();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return getLoadedServerFonts();\n }\n const rules = getFontFaceRules();\n return rules.map(({ rule }) => normalizeFontFamilyName(rule.style.fontFamily));\n },\n\n isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {\n if (typeof window === 'undefined') {\n return isServerFontLoaded(fontFamilyName);\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(vonovak): This is used in RN vector-icons to load fonts dynamically on web. Changing the signature is breaking.\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (__DEV__ && typeof resource !== 'object') {\n // to help devving on web, where loadAsync interface is different from native\n throw new CodedError(\n 'ERR_FONT_SOURCE',\n `Expected font resource of type \\`object\\` instead got: ${typeof resource}`\n );\n }\n if (typeof window === 'undefined') {\n addServerFont({\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(resource.testString ?? null, 12000);\n },\n};\n\nconst isServer = process.env.EXPO_OS === 'web' && typeof window === 'undefined';\n\nfunction createExpoFontLoader() {\n return ExpoFontLoader;\n}\nconst toExport = isServer\n ? ExpoFontLoader\n : // @ts-expect-error: registerWebModule calls `new` on the module implementation.\n // Normally that'd be a class but that doesn't work on server, so we use a function instead.\n // TS doesn't like that but we don't need it to be a class.\n registerWebModule(createExpoFontLoader, 'ExpoFontLoader');\n\nexport default toExport as typeof ExpoFontLoader;\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\n return styleElement;\n}\n\nconst CSS_IDENT_RE = /^[a-zA-Z_-][\\w-]*$/;\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n const display =\n typeof resource.display === 'string' && CSS_IDENT_RE.test(resource.display)\n ? resource.display\n : FontDisplay.AUTO;\n return `@font-face{font-family:${JSON.stringify(fontFamily)};src:url(${JSON.stringify(\n resource.uri\n )});font-display:${display}}`;\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 return !isSafari && !isIOS && !isEdge && !isIE;\n}\n"]}
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.font",
11
- "version": "57.0.0",
11
+ "version": "57.0.2",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.font",
6
- "version": "57.0.0",
6
+ "version": "57.0.2",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.font-57.0.0.aar",
28
- "url": "expo.modules.font-57.0.0.aar",
27
+ "name": "expo.modules.font-57.0.2.aar",
28
+ "url": "expo.modules.font-57.0.2.aar",
29
29
  "size": 29409,
30
30
  "sha512": "27cd5270fb4a9e9c93cecfde8eb7521dea8ba1d6ff2523d2512ecdafa7a58b68c5c1e07c331f3c6bc16af18f8289d55bd01ace60feca7af8aaa2f6e9f3b487e1",
31
31
  "sha256": "d7ea73905f045bfec5b9c40172b9b29f327d7a80a0bf05389d12966d157a1430",
@@ -71,8 +71,8 @@
71
71
  ],
72
72
  "files": [
73
73
  {
74
- "name": "expo.modules.font-57.0.0.aar",
75
- "url": "expo.modules.font-57.0.0.aar",
74
+ "name": "expo.modules.font-57.0.2.aar",
75
+ "url": "expo.modules.font-57.0.2.aar",
76
76
  "size": 29409,
77
77
  "sha512": "27cd5270fb4a9e9c93cecfde8eb7521dea8ba1d6ff2523d2512ecdafa7a58b68c5c1e07c331f3c6bc16af18f8289d55bd01ace60feca7af8aaa2f6e9f3b487e1",
78
78
  "sha256": "d7ea73905f045bfec5b9c40172b9b29f327d7a80a0bf05389d12966d157a1430",
@@ -91,8 +91,8 @@
91
91
  },
92
92
  "files": [
93
93
  {
94
- "name": "expo.modules.font-57.0.0-sources.jar",
95
- "url": "expo.modules.font-57.0.0-sources.jar",
94
+ "name": "expo.modules.font-57.0.2-sources.jar",
95
+ "url": "expo.modules.font-57.0.2-sources.jar",
96
96
  "size": 4135,
97
97
  "sha512": "99aeb8a7c324e889d4140890af18771545c97a69e128bf6a3fb2e70f3ddde11ec292c4d8e3b6470f0c7d0db50db21b782e1382767807899c9b1faf4552f0d41d",
98
98
  "sha256": "87a25fe7ac775341198279e739706b7594f5a863da55f215422209e737e5562f",
@@ -0,0 +1 @@
1
+ e1c8fd6414766dd948f03f2d00bc28571335a21b9196e138c3a39a6e60e5a70d
@@ -0,0 +1 @@
1
+ 0b1fc2552c730a8d43c4137ef470dce609e5c0d5678f96927b9cb4b6ba37e1a8eeef60d99faec716c07c3fbb5f72889fb1d3f553fd50f305f6249ce266b77f46
@@ -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>57.0.0</version>
12
+ <version>57.0.2</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
+ 974b65b7798117841c31ae1edae92923cd28625b
@@ -0,0 +1 @@
1
+ adb909c80d534084d7d24a23460d85e6cc0ff5acd57ced6ed2e2bbcc4e15a182
@@ -0,0 +1 @@
1
+ 723cd92c25f6932eb0530a1e1d2225249bafae27af00c773dcf02039d0cf729b4a8ebd92a3219f1f25a04c04c38cacc31014f8ad7b567bf4e6446ede6fd6632f
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.font</artifactId>
5
5
  <versioning>
6
- <latest>57.0.0</latest>
7
- <release>57.0.0</release>
6
+ <latest>57.0.2</latest>
7
+ <release>57.0.2</release>
8
8
  <versions>
9
- <version>57.0.0</version>
9
+ <version>57.0.2</version>
10
10
  </versions>
11
- <lastUpdated>20260625191735</lastUpdated>
11
+ <lastUpdated>20260828104235</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 28fa225c1b879a3e9d2a1798d4fc2f1e
1
+ b792110bb036b103911c9089cf46859a
@@ -1 +1 @@
1
- e96ea56479dcd84a45f02687b36de17768456dd2
1
+ 88f17a91ddb12a5422f2ace0b5912f772f601622
@@ -1 +1 @@
1
- 4e624dffdfd829e81f2b8051dcb6db4a5cbae8c90ee2f019d9449ff77ad87ea5
1
+ 03a7f4fba36f3c70165da3615c2a73c5f68f977780fbdb6dd9f77645b87be05e
@@ -1 +1 @@
1
- 95ba3668b4d9ee7921fc55a0f481413bf8e4b6cc3df490d6cf0940020b1ee411acd4cb57bd2b9e3c310dc3034917a565b2a1151efca09c5d3aca1d8b6bcf1467
1
+ 3fc7e4edb573de298a103760f055a124469fee448cb2dd47f11144e8306e4b3a7edef2bfc48c917a14506b15c5c66773b5c495fda2be1d68548cae345e399687
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "57.0.0",
3
+ "version": "57.0.2",
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",
@@ -43,7 +43,7 @@
43
43
  "@types/fontfaceobserver": "^2.1.3",
44
44
  "@types/node": "^22.14.0",
45
45
  "@types/react": "~19.2.0",
46
- "expo": "57.0.0-preview.0",
46
+ "expo": "57.0.18",
47
47
  "expo-module-scripts": "56.0.3"
48
48
  },
49
49
  "peerDependencies": {
@@ -51,7 +51,7 @@
51
51
  "react": "*",
52
52
  "react-native": "*"
53
53
  },
54
- "gitHead": "e3eb896c5fdcd89e0cded98ff4e35c9db12cc9c0",
54
+ "gitHead": "c3739f09b6a7620729ce7e305e88a2ec8bc79c3c",
55
55
  "scripts": {
56
56
  "build": "expo-module build",
57
57
  "clean": "expo-module clean",
@@ -40,6 +40,21 @@ function getFontFaceRules(): RuleItem[] {
40
40
  return [];
41
41
  }
42
42
 
43
+ // `_createWebFontTemplate` writes the family name quoted, but engines disagree about whether
44
+ // the CSSOM keeps the quotes (Firefox always does), so normalize them away before comparing.
45
+ function normalizeFontFamilyName(fontFamily: string): string {
46
+ // jsdom leaves `style.fontFamily` undefined on the `@font-face` rules it parses.
47
+ const trimmed = fontFamily?.trim();
48
+ if (!trimmed) {
49
+ return '';
50
+ }
51
+ const quote = trimmed[0];
52
+ if (trimmed.length >= 2 && (quote === '"' || quote === "'") && trimmed.endsWith(quote)) {
53
+ return trimmed.slice(1, -1).replace(/\\(.)/g, '$1');
54
+ }
55
+ return trimmed;
56
+ }
57
+
43
58
  function getFontFaceRulesMatchingResource(
44
59
  fontFamilyName: string,
45
60
  options?: UnloadFontOptions
@@ -47,7 +62,7 @@ function getFontFaceRulesMatchingResource(
47
62
  const rules = getFontFaceRules();
48
63
  return rules.filter(({ rule }) => {
49
64
  return (
50
- rule.style.fontFamily === fontFamilyName &&
65
+ normalizeFontFamilyName(rule.style.fontFamily) === fontFamilyName &&
51
66
  (options && options.display ? options.display === (rule.style as any).fontDisplay : true)
52
67
  );
53
68
  });
@@ -67,7 +82,7 @@ const ExpoFontLoader: Required<ExpoFontLoaderModule> = {
67
82
  const sheet = getFontFaceStyleSheet();
68
83
  if (!sheet) return;
69
84
  const items = getFontFaceRulesMatchingResource(fontFamilyName, options);
70
- for (const item of items) {
85
+ for (const item of items.reverse()) {
71
86
  sheet.deleteRule(item.index);
72
87
  }
73
88
  },
@@ -98,7 +113,7 @@ const ExpoFontLoader: Required<ExpoFontLoaderModule> = {
98
113
  return getLoadedServerFonts();
99
114
  }
100
115
  const rules = getFontFaceRules();
101
- return rules.map(({ rule }) => rule.style.fontFamily);
116
+ return rules.map(({ rule }) => normalizeFontFamilyName(rule.style.fontFamily));
102
117
  },
103
118
 
104
119
  isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {
@@ -1 +0,0 @@
1
- 266236a7b54017d90f2b8ef7edf5a6e88d347ff7
@@ -1 +0,0 @@
1
- 813bfd329e21e61c841de93032279dae1b28374c22b08125de8fefb55f6e2f58
@@ -1 +0,0 @@
1
- 6c5c4a942f3fb57241ef7229e1759f448c3d57e6d9c48e0c7c274aa9e169c8fbb454eff6b4ffacafe903e9d3a82489f979f306f5819581e7dae10a70a19e60a2
@@ -1 +0,0 @@
1
- 2fc645aa8ca3b02e8489939b1c53de8196804c0c
@@ -1 +0,0 @@
1
- 260ef88c16e89025431b2f078e8d70699763a07b36a769ddebe849b7db81dd43
@@ -1 +0,0 @@
1
- 2645e98c1ab115e5e4925f5f98d063b1891159f577419e535bc2442c502adb9213f1c58fdb3dcfc8e9e0adeb31c3973ea4ec741b378b678634b2101b2fc1239e