mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-11-04 21:06:45 +08:00 
			
		
		
		
	fix: Added asset path fallback null value inside an else clause
This commit is contained in:
		
				
					committed by
					
						
						Nathan Walker
					
				
			
			
				
	
			
			
			
						parent
						
							a21d4f94ac
						
					
				
				
					commit
					8726d026fe
				
			@ -3,7 +3,7 @@ import { ParsedFont, FontStyleType, FontWeightType, FontVariationSettingsType }
 | 
				
			|||||||
import { makeValidator, makeParser } from '../core/properties';
 | 
					import { makeValidator, makeParser } from '../core/properties';
 | 
				
			||||||
import { Trace } from '../../trace';
 | 
					import { Trace } from '../../trace';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const FONTS_BASE_PATH = '/fonts/';
 | 
					export const FONTS_BASE_PATH = '/fonts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export abstract class Font implements FontDefinition {
 | 
					export abstract class Font implements FontDefinition {
 | 
				
			||||||
	public static default = undefined;
 | 
						public static default = undefined;
 | 
				
			||||||
 | 
				
			|||||||
@ -78,10 +78,13 @@ function loadFontFromFile(fontFamily: string, font: Font): android.graphics.Type
 | 
				
			|||||||
			fontAssetPath = basePath + '.ttf';
 | 
								fontAssetPath = basePath + '.ttf';
 | 
				
			||||||
		} else if (fs.File.exists(basePath + '.otf')) {
 | 
							} else if (fs.File.exists(basePath + '.otf')) {
 | 
				
			||||||
			fontAssetPath = basePath + '.otf';
 | 
								fontAssetPath = basePath + '.otf';
 | 
				
			||||||
		} else if (Trace.isEnabled()) {
 | 
							} else {
 | 
				
			||||||
			fontAssetPath = null;
 | 
								fontAssetPath = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (Trace.isEnabled()) {
 | 
				
			||||||
				Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
 | 
									Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		result = null; // Default
 | 
							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);
 | 
							typefaceCache.set(cacheKey, result);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								packages/core/ui/styling/font.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								packages/core/ui/styling/font.d.ts
									
									
									
									
										vendored
									
									
								
							@ -1,7 +1,7 @@
 | 
				
			|||||||
import { Font as FontBase } from './font-common';
 | 
					import { Font as FontBase } from './font-common';
 | 
				
			||||||
export type { FontStyleType, FontWeightType, ParsedFont, FontVariationSettingsType } from './font-interfaces';
 | 
					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 {
 | 
					export declare class Font extends FontBase {
 | 
				
			||||||
	public static default: Font;
 | 
						public static default: Font;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user