@@ -1248,39 +1248,43 @@ protected void PaintBackground(IGraphics g, RectangleF rect, bool isFirst, bool
12481248 /// <param name="offset">the current scroll offset to offset the words</param>
12491249 private void PaintWords ( IGraphics g , PointF offset )
12501250 {
1251- foreach ( var word in Words )
1251+ if ( Width . Length > 0 )
12521252 {
1253- var wordPoint = new PointF ( word . Left + offset . X , word . Top + offset . Y ) ;
1254- if ( word . Selected )
1253+ var isRtl = Direction == CssConstants . Rtl ;
1254+ foreach ( var word in Words )
12551255 {
1256- // handle paint selected word background and with partial word selection
1257- var wordLine = DomUtils . GetCssLineBoxByWord ( word ) ;
1258- var left = word . SelectedStartOffset > - 1 ? word . SelectedStartOffset : ( wordLine . Words [ 0 ] != word && word . HasSpaceBefore ? - ActualWordSpacing : 0 ) ;
1259- var padWordRight = word . HasSpaceAfter && ! wordLine . IsLastSelectedWord ( word ) ;
1260- var width = word . SelectedEndOffset > - 1 ? word . SelectedEndOffset : word . Width + ( padWordRight ? ActualWordSpacing : 0 ) ;
1261- var rect = new RectangleF ( word . Left + offset . X + left , word . Top + offset . Y , width - left , wordLine . LineHeight ) ;
1256+ var wordPoint = new PointF ( word . Left + offset . X , word . Top + offset . Y ) ;
1257+ if ( word . Selected )
1258+ {
1259+ // handle paint selected word background and with partial word selection
1260+ var wordLine = DomUtils . GetCssLineBoxByWord ( word ) ;
1261+ var left = word . SelectedStartOffset > - 1 ? word . SelectedStartOffset : ( wordLine . Words [ 0 ] != word && word . HasSpaceBefore ? - ActualWordSpacing : 0 ) ;
1262+ var padWordRight = word . HasSpaceAfter && ! wordLine . IsLastSelectedWord ( word ) ;
1263+ var width = word . SelectedEndOffset > - 1 ? word . SelectedEndOffset : word . Width + ( padWordRight ? ActualWordSpacing : 0 ) ;
1264+ var rect = new RectangleF ( word . Left + offset . X + left , word . Top + offset . Y , width - left , wordLine . LineHeight ) ;
12621265
1263- g . FillRectangle ( GetSelectionBackBrush ( false ) , rect . X , rect . Y , rect . Width , rect . Height ) ;
1266+ g . FillRectangle ( GetSelectionBackBrush ( false ) , rect . X , rect . Y , rect . Width , rect . Height ) ;
12641267
1265- if ( HtmlContainer . SelectionForeColor != System . Drawing . Color . Empty && ( word . SelectedStartOffset > 0 || word . SelectedEndIndexOffset > - 1 ) )
1266- {
1267- var orgClip = g . GetClip ( ) ;
1268- g . SetClip ( rect , CombineMode . Exclude ) ;
1269- g . DrawString ( word . Text , ActualFont , ActualColor , wordPoint , new SizeF ( word . Width , word . Height ) ) ;
1270- g . SetClip ( rect ) ;
1271- g . DrawString ( word . Text , ActualFont , GetSelectionForeBrush ( ) , wordPoint , new SizeF ( word . Width , word . Height ) ) ;
1272- g . SetClip ( orgClip ) ;
1268+ if ( HtmlContainer . SelectionForeColor != System . Drawing . Color . Empty && ( word . SelectedStartOffset > 0 || word . SelectedEndIndexOffset > - 1 ) )
1269+ {
1270+ var orgClip = g . GetClip ( ) ;
1271+ g . SetClip ( rect , CombineMode . Exclude ) ;
1272+ g . DrawString ( word . Text , ActualFont , ActualColor , wordPoint , new SizeF ( word . Width , word . Height ) , isRtl ) ;
1273+ g . SetClip ( rect ) ;
1274+ g . DrawString ( word . Text , ActualFont , GetSelectionForeBrush ( ) , wordPoint , new SizeF ( word . Width , word . Height ) , isRtl ) ;
1275+ g . SetClip ( orgClip ) ;
1276+ }
1277+ else
1278+ {
1279+ g . DrawString ( word . Text , ActualFont , GetSelectionForeBrush ( ) , wordPoint , new SizeF ( word . Width , word . Height ) , isRtl ) ;
1280+ }
12731281 }
12741282 else
12751283 {
1276- g . DrawString ( word . Text , ActualFont , GetSelectionForeBrush ( ) , wordPoint , new SizeF ( word . Width , word . Height ) ) ;
1284+ //g.DrawRectangle(Pens.Red, wordPoint.X, wordPoint.Y, word.Width - 1, word.Height - 1);
1285+ g . DrawString ( word . Text , ActualFont , ActualColor , wordPoint , new SizeF ( word . Width , word . Height ) , isRtl ) ;
12771286 }
12781287 }
1279- else
1280- {
1281- //g.DrawRectangle(Pens.Red, wordPoint.X, wordPoint.Y, word.Width - 1, word.Height - 1);
1282- g . DrawString ( word . Text , ActualFont , ActualColor , wordPoint , new SizeF ( word . Width , word . Height ) ) ;
1283- }
12841288 }
12851289 }
12861290
0 commit comments