Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadAsync(nativeFontName, resource) {
// To revert `${Constants.sessionId}-${name}`
const fontName = nativeFontName.slice(Constants.sessionId.length + 1);
return new Promise((resolve, reject) => {
FontLoader.loadFont(fontName, resource, resolve, reject);
});
},
};
it('should passes when used properly', () => {
(Constants.debugMode: boolean);
(Constants.deviceName: ?string);
(Constants.deviceYearClass: number | null);
(Constants.experienceUrl: string);
(Constants.expoRuntimeVersion: string);
(Constants.expoVersion: string);
(Constants.isDetached: ?boolean);
(Constants.intentUri: ?string);
(Constants.installationId: string);
(Constants.isDevice: boolean);
(Constants.isHeadless: boolean);
(Constants.linkingUri: string);
(Constants.sessionId: string);
(Constants.statusBarHeight: number);
(Constants.systemVersion: ?number);
(Constants.systemFonts: Array);
});
export function processFontFamily(name: string | null): string | null {
if (typeof name !== 'string' || Constants.systemFonts.includes(name) || name === 'System') {
return name;
}
if (name.includes(Constants.sessionId)) {
return name;
}
if (!isLoaded(name)) {
if (__DEV__) {
if (isLoading(name)) {
console.error(
`You started loading the font "${name}", but used it before it finished loading.\n
- You need to wait for Font.loadAsync to complete before using the font.\n
- We recommend loading all fonts before rendering the app, and rendering only Expo.AppLoading while waiting for loading to complete.`
);
} else {
console.error(
`fontFamily "${name}" is not a system font and has not been loaded through Font.loadAsync.\n
- If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.\n
- If this is a custom font, be sure to load it with Font.loadAsync.`
export function getNativeFontName(name: string): string {
if (fontFamilyNeedsScoping(name)) {
return `${Constants.sessionId}-${name}`;
} else {
return name;
}
}
function _getNativeFontName(name) {
if (isWeb) {
return name;
}
return `${Constants.sessionId}-${name}`;
}
if (module && module.exports) {
function _getNativeFontName(name: string): string {
if (isWeb) {
return name;
}
return `${Constants.sessionId}-${name}`;
}
export function getNativeFontName(name) {
if (fontFamilyNeedsScoping(name)) {
return `${Constants.sessionId}-${name}`;
}
else {
return name;
}
}
//# sourceMappingURL=FontLoader.js.map
export function fontFamilyNeedsScoping(name: string): boolean {
return (
(isInClient || isInIOSStandalone) &&
!Constants.systemFonts.includes(name) &&
name !== 'System' &&
!name.includes(Constants.sessionId)
);
}