(fontFamily: string, fontStyle: string, fontWeight: string)
| 108 | } |
| 109 | |
| 110 | function 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 | |
| 146 | function _getUIFont(view: any): UIFont { |
| 147 | if (view.ios) { |
no test coverage detected