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

Function prepareLabel

apps/ui/src/fonts-tests/all-fonts-page.ts:110–144  ·  view source on GitHub ↗
(fontFamily: string, fontStyle: string, fontWeight: string)

Source from the content-addressed store, hash-verified

108}
109
110function prepareLabel(fontFamily: string, fontStyle: string, fontWeight: string): View {
111 let label = new Label();
112 label['font-family'] = fontFamily;
113 let fontFamilyCss = `font-family: ${fontFamily}; `;
114 let fontStyleCss = fontStyle !== CoreTypes.FontStyle.normal ? `font-style: ${fontStyle}; ` : '';
115 let fontWeightCss = fontWeight !== CoreTypes.FontWeight.normal ? `font-weight: ${fontWeight}; ` : '';
116 let css = `${fontFamilyCss}${fontStyleCss}${fontWeightCss}`;
117 label.text = `${typeUtils.getClass(label)} {${css}};`;
118 label.textWrap = true;
119 label.style.textAlignment = 'left';
120 label.borderWidth = 1;
121 label.borderColor = black;
122 label.style.padding = '2';
123 label.setInlineStyle(css);
124 label.on('loaded', (args) => {
125 let sender = <Label>args.object;
126 if (sender.ios) {
127 let uiFont = _getUIFont(label);
128 sender.text += `\niOS Font: ${uiFont.fontName};`;
129 if (genericFontFamilies.indexOf(fontFamily) !== -1) {
130 return;
131 }
132 if (uiFont.fontName.replace(' ', '').indexOf((<string>sender['font-family']).replace(' ', '')) !== -1) {
133 sender.color = green;
134 } else {
135 sender.color = red;
136 }
137 }
138 });
139 if (fontFamily === 'FontAwesome') {
140 label.text += '\uF17B\uF10B';
141 }
142
143 return label;
144}
145
146function _getUIFont(view: any): UIFont {
147 if (view.ios) {

Callers 1

generateLabelsFunction · 0.85

Calls 4

_getUIFontFunction · 0.85
indexOfMethod · 0.80
replaceMethod · 0.80
onMethod · 0.65

Tested by

no test coverage detected