MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / getFontWeightSuffix

Function getFontWeightSuffix

packages/core/ui/styling/font.android.ts:211–238  ·  view source on GitHub ↗
(fontWeight: FontWeightType)

Source from the content-addressed store, hash-verified

209}
210
211function getFontWeightSuffix(fontWeight: FontWeightType): string {
212 if (typeof fontWeight === 'number') {
213 fontWeight = (fontWeight + '') as any;
214 }
215 switch (fontWeight) {
216 case FontWeight.THIN:
217 return SDK_VERSION >= 16 ? '-thin' : '';
218 case FontWeight.EXTRA_LIGHT:
219 case FontWeight.LIGHT:
220 return SDK_VERSION >= 16 ? '-light' : '';
221 case FontWeight.NORMAL:
222 case '400':
223 case undefined:
224 case null:
225 return '';
226 case FontWeight.MEDIUM:
227 case FontWeight.SEMI_BOLD:
228 return SDK_VERSION >= 21 ? '-medium' : '';
229 case FontWeight.BOLD:
230 case '700':
231 case FontWeight.EXTRA_BOLD:
232 return '';
233 case FontWeight.BLACK:
234 return SDK_VERSION >= 21 ? '-black' : '';
235 default:
236 throw new Error(`Invalid font weight: "${fontWeight}"`);
237 }
238}
239
240function getNumericFontWeight(fontWeight: FontWeightType): number {
241 let value: number;

Callers 1

createTypefaceLegacyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected