@@ -52,7 +52,7 @@ public void DoXMLPase(ref string content)
5252 XmlNode common = xml . GetElementsByTagName ( "common" ) [ 0 ] ;
5353 XmlNode page = xml . GetElementsByTagName ( "pages" ) [ 0 ] . FirstChild ;
5454 XmlNodeList chars = xml . GetElementsByTagName ( "chars" ) [ 0 ] . ChildNodes ;
55- XmlNodeList kerns = xml . GetElementsByTagName ( "kernings" ) [ 0 ] . ChildNodes ;
55+
5656
5757 fontName = info . Attributes . GetNamedItem ( "face" ) . InnerText ;
5858 fontSize = ToInt ( info , "size" ) ;
@@ -78,14 +78,20 @@ public void DoXMLPase(ref string content)
7878 ToInt ( charNode , "xadvance" ) ) ;
7979 }
8080
81- kernings = new Kerning [ kerns . Count ] ;
82- for ( int i = 0 ; i < kerns . Count ; i ++ )
81+ // kernings
82+ XmlNode kerningsNode = xml . GetElementsByTagName ( "kernings" ) [ 0 ] ;
83+ if ( kerningsNode != null && kerningsNode . HasChildNodes )
8384 {
84- XmlNode kerningNode = kerns [ i ] ;
85- kernings [ i ] = new Kerning ( ) ;
86- kernings [ i ] . first = ToInt ( kerningNode , "first" ) ;
87- kernings [ i ] . second = ToInt ( kerningNode , "second" ) ;
88- kernings [ i ] . amount = ToInt ( kerningNode , "amount" ) ;
85+ XmlNodeList kerns = kerningsNode . ChildNodes ;
86+ kernings = new Kerning [ kerns . Count ] ;
87+ for ( int i = 0 ; i < kerns . Count ; i ++ )
88+ {
89+ XmlNode kerningNode = kerns [ i ] ;
90+ kernings [ i ] = new Kerning ( ) ;
91+ kernings [ i ] . first = ToInt ( kerningNode , "first" ) ;
92+ kernings [ i ] . second = ToInt ( kerningNode , "second" ) ;
93+ kernings [ i ] . amount = ToInt ( kerningNode , "amount" ) ;
94+ }
8995 }
9096 }
9197
@@ -121,17 +127,22 @@ public void DoTextParse(ref string content)
121127 if ( lines [ i ] . Length > 0 )
122128 break ;
123129 }
124- int count = 0 ;
125- if ( ReadTextCount ( ref lines [ i ++ ] , out count ) )
130+
131+ // kernings
132+ if ( i < l )
126133 {
127- int start = i ;
128- kernings = new Kerning [ count ] ;
129- for ( ; i < l ; i ++ )
134+ int count = 0 ;
135+ if ( ReadTextCount ( ref lines [ i ++ ] , out count ) )
130136 {
131- if ( ! ReadTextKerning ( i - start , ref lines [ i ] , ref list ) )
132- break ;
133- }
134- } ;
137+ int start = i ;
138+ kernings = new Kerning [ count ] ;
139+ for ( ; i < l ; i ++ )
140+ {
141+ if ( ! ReadTextKerning ( i - start , ref lines [ i ] , ref list ) )
142+ break ;
143+ }
144+ } ;
145+ }
135146 }
136147
137148 private void ReadTextInfo ( ref string line )
0 commit comments