fix: Added asset path fallback null value inside an else clause

This commit is contained in:
Dimitris - Rafail Katsampas
2025-01-25 20:49:59 +02:00
committed by Nathan Walker
parent a21d4f94ac
commit 8726d026fe
3 changed files with 8 additions and 5 deletions

View File

@ -3,7 +3,7 @@ import { ParsedFont, FontStyleType, FontWeightType, FontVariationSettingsType }
import { makeValidator, makeParser } from '../core/properties';
import { Trace } from '../../trace';
export const FONTS_BASE_PATH = '/fonts/';
export const FONTS_BASE_PATH = '/fonts';
export abstract class Font implements FontDefinition {
public static default = undefined;

View File

@ -78,9 +78,12 @@ function loadFontFromFile(fontFamily: string, font: Font): android.graphics.Type
fontAssetPath = basePath + '.ttf';
} else if (fs.File.exists(basePath + '.otf')) {
fontAssetPath = basePath + '.otf';
} else if (Trace.isEnabled()) {
} else {
fontAssetPath = null;
Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
if (Trace.isEnabled()) {
Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
}
}
result = null; // Default
@ -108,7 +111,7 @@ function loadFontFromFile(fontFamily: string, font: Font): android.graphics.Type
}
}
// The value might be null if there has already been an attempt to load the font but failed
// The value will be null if there has already been an attempt to load the font but failed
typefaceCache.set(cacheKey, result);
}

View File

@ -1,7 +1,7 @@
import { Font as FontBase } from './font-common';
export type { FontStyleType, FontWeightType, ParsedFont, FontVariationSettingsType } from './font-interfaces';
export const FONTS_BASE_PATH = '/fonts/';
export const FONTS_BASE_PATH = '/fonts';
export declare class Font extends FontBase {
public static default: Font;