Advertisement
Guest User

Peter Eric Williams

a guest
Jan 29th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.94 KB | None | 0 0
  1. // Draw a partial text in a single line without clipping x
  2.  
  3. procedure TFixedFont.WriteText2(x, y: integer; Txt: string;
  4.   var PaintBox1: TPaintBox);
  5. var
  6.   i: cardinal; // PEW
  7.   ch, px, py, TextLength: integer;
  8. begin
  9.   if (Image = nil) or (Txt = '') then
  10.     exit;
  11.   PaintBox1.Canvas.Lock;
  12.   i := 1;
  13.   TextLength := length(Txt);
  14.   while i <= TextLength do
  15.   begin
  16.     ch := ord(Txt[i]);
  17.  
  18.     // i=7
  19.     // Txt[i]=111 'o'
  20.     // ch=121
  21.  
  22.     if (ch >= Rects_low) and (ch <= LastCharacterDefined) then
  23.     begin
  24.       // [ALVAROGP] Rects are not records any more
  25.       for px := 0 to Rects[ch].w - 1 do
  26.         // [ALVAROGP] Rects are not records any more
  27.         for py := 0 to Rects[ch].h - 1 do
  28.           if y + py < PaintBox1.Canvas.ClipRect.Left +
  29.             PaintBox1.Canvas.ClipRect.Bottom - PaintBox1.Canvas.ClipRect.Top
  30.               then
  31.           begin
  32.             if ReverseVideo then
  33.             begin
  34.               // reversed text
  35.               // [ALVAROGP] Rects are not records any more
  36.               if Image.Canvas.Pixels[Rects[ch].x + px, Rects[ch].y + py] =
  37.                 TransparentColor then
  38.                 PaintBox1.Canvas.Pixels[x + px, y + py] := TextColor
  39.               else if not UseTransparentBackground then
  40.                 PaintBox1.Canvas.Pixels[x + px, y + py] := BackgroundColor;
  41.             end
  42.             else
  43.             begin
  44.               // normal text
  45.               // [ALVAROGP] Rects are not records any more
  46.               if Image.Canvas.Pixels[Rects[ch].x + px, Rects[ch].y + py] <>
  47.                 TransparentColor then
  48.                 PaintBox1.Canvas.Pixels[x + px, y + py] := TextColor
  49.               else if not UseTransparentBackground then
  50.                 PaintBox1.Canvas.Pixels[x + px, y + py] := BackgroundColor;
  51.             end
  52.           end;
  53.       x := x + Rects[ch].w + HorizontalGap
  54.     end;
  55.     inc(i);
  56.   end;
  57.   PaintBox1.Canvas.Unlock;
  58.   //PaintBox1.invalidate;
  59. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement