@@ -146,6 +146,9 @@ private static Paragraph FillOneParagraph(List<FChar> text, int startPos, out in
146146 paragraph . centered = true ;
147147
148148 startPos ++ ;
149+
150+ if ( startPos >= text . Count )
151+ break ;
149152 }
150153 endPos = startPos - 1 ;
151154 for ( int i = startPos ; i < text . Count ; i ++ )
@@ -208,6 +211,7 @@ private static List<RenderUnit> MakeLineRenderSequence(Paragraph text, Font font
208211
209212 if ( generatedLine . Count > 0 && generatedLine . Last ( ) . rightBorderX >= lineWidth )
210213 {
214+ bool notFirstIteration = false ;
211215 while ( generatedLine . Last ( ) . rightBorderX >= lineWidth )
212216 {
213217 bool needsWrapping ;
@@ -229,16 +233,21 @@ private static List<RenderUnit> MakeLineRenderSequence(Paragraph text, Font font
229233 int count = generatedLine . Count - breakPos - 1 ;
230234 generatedLine . RemoveRange ( breakPos + 1 , count ) ;
231235 end -= count ;
236+ if ( notFirstIteration && needsWrapping )
237+ {
238+ end ++ ; //compensate for prev. inserted minus
239+ }
232240
233241 int uselessX ;
234242 if ( needsWrapping )
235243 InsertRenderUnit ( generatedLine , FChar . minus , random , generatedLine . Last ( ) . rightBorderX , out uselessX , font ) ;
244+ notFirstIteration = true ;
236245 }
237246 break ;
238247 }
239248 }
240249
241- if ( text . centered )
250+ if ( text . centered && generatedLine . Count > 0 )
242251 {
243252 int rightDist = fullWidth - generatedLine . Last ( ) . rightBorderX ;
244253 foreach ( RenderUnit unit in generatedLine )
@@ -254,6 +263,18 @@ private static void InsertRenderUnit(List<RenderUnit> list, FChar character, Ran
254263 {
255264 RenderUnit unit = new RenderUnit ( ) ;
256265
266+ if ( ! font . images . ContainsKey ( character ) )
267+ {
268+ unit . x = x ;
269+ unit . image = null ;
270+ unit . corrCharacter = character ;
271+ unit . rightBorderX = unit . x + ( int ) ( 0.3 * Font . pixelsPerCmH ) ;
272+ list . Add ( unit ) ;
273+
274+ newX = x + ( int ) ( 0.3 * Font . pixelsPerCmV ) ;
275+ return ;
276+ }
277+
257278 int selectedImageIndex = random . Next ( font . images [ character ] . Count ( ) ) ;
258279
259280 unit . x = ( int ) ( x - font . leftMargins [ character ] [ selectedImageIndex ] * Font . pixelsPerCmV ) ;
0 commit comments