@@ -6,7 +6,8 @@ import { Label } from "tns-core-modules/ui/label";
66import { FontStyle , FontWeight } from "tns-core-modules/ui/enums" ;
77import * as typeUtils from "tns-core-modules/utils/types" ;
88import { Color } from "tns-core-modules/color" ;
9- import * as font from "tns-core-modules/ui/styling/font" ;
9+ import * as utils from "tns-core-modules/utils/utils" ;
10+ import { isIOS } from "tns-core-modules/platform" ;
1011
1112const genericFontFamilies = [
1213 "system" ,
@@ -46,18 +47,20 @@ let compareIgnoreCase = function (a, b) {
4647 return a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ;
4748} ;
4849
49- if ( font . ios ) {
50- // for (let f = 0; f < embeddedFontNames.length; f++) {
51- // font.ios.registerFont(`fonts/${embeddedFontNames[f]}.ttf`);
52- // }
50+ if ( isIOS ) {
51+ const nsFontFamilies = utils . ios . getter ( UIFont , UIFont . familyNames ) ;
52+ for ( let i = 0 ; i < nsFontFamilies . count ; i ++ ) {
53+ const family = nsFontFamilies . objectAtIndex ( i ) ;
54+ fontFamilies . push ( family )
5355
54- let font_internal = < any > font ;
55- font_internal . ensureSystemFontSets ( ) ;
56+ const nsFonts = UIFont . fontNamesForFamilyName ( family ) ;
57+ for ( let j = 0 ; j < nsFonts . count ; j ++ ) {
58+ const font = nsFonts . objectAtIndex ( j ) ;
59+ fontNames . push ( font )
60+ }
61+ }
5662
57- ( < Set < string > > font_internal . systemFontFamilies ) . forEach ( f => fontFamilies . push ( f ) ) ;
5863 fontFamilies = fontFamilies . sort ( compareIgnoreCase ) ;
59-
60- ( < Set < string > > font_internal . systemFonts ) . forEach ( f => fontNames . push ( f ) ) ;
6164 fontNames = fontNames . sort ( compareIgnoreCase ) ;
6265}
6366
@@ -82,8 +85,7 @@ function generateLabels(layout: StackLayout) {
8285 }
8386 }
8487
85- if ( fontFamilies . length > 0 )
86- {
88+ if ( fontFamilies . length > 0 ) {
8789 layout . addChild ( prepareTitle ( "Font Families" , 24 ) ) ;
8890 }
8991 for ( let f = 0 ; f < fontFamilies . length ; f ++ ) {
@@ -134,12 +136,12 @@ function prepareLabel(fontFamily: string, fontStyle: string, fontWeight: string)
134136 let fontStyleCss = fontStyle !== FontStyle . normal ? `font-style: ${ fontStyle } ; ` : "" ;
135137 let fontWeightCss = fontWeight !== FontWeight . normal ? `font-weight: ${ fontWeight } ; ` : "" ;
136138 let css = `${ fontFamilyCss } ${ fontStyleCss } ${ fontWeightCss } ` ;
137- label . text = `${ typeUtils . getClass ( label ) } {${ css } };` ;
139+ label . text = `${ typeUtils . getClass ( label ) } {${ css } };` ;
138140 label . textWrap = true ;
139141 label . style . textAlignment = "left" ;
140142 label . borderWidth = 1 ;
141143 label . borderColor = black ;
142- label . style . padding = "2" ;
144+ label . style . padding = "2" ;
143145 label . setInlineStyle ( css ) ;
144146 label . on ( "loaded" , args => {
145147 let sender = < Label > args . object ;
0 commit comments