Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Gráficos (https://www.clubdelphi.com/foros/forumdisplay.php?f=8)
-   -   Efecto extraño con fuentes (https://www.clubdelphi.com/foros/showthread.php?t=33711)

rebollón 14-07-2006 17:19:29

Efecto extraño con fuentes
 
Hola a todos, me he encontrado con un comportamiento extraño al escribir textos de distinto tamaño en un bitmap. A ver si alguno de vosotros se le sabe porque puede estar pasando esto y me echa un cable. No sé muy bien como explicarlo, por lo que he hecho un ejemplo: en un form he añadido un Timage y un TButton y en el evento click del button he puesto lo siguiente:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  bmp: TBitMap;
  sTexto: String;
begin
  bmp:= TBitMap.Create;
  try
    sTexto:= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
    bmp.Height:= Image1.Height;
    bmp.Width:= Image1.Width;
    bmp.Canvas.Brush.Color:=clWhite;
    bmp.Canvas.Pen.Color:=clBlack;
    bmp.Canvas.Pen.Width:= 1;
    bmp.Canvas.Font.Name:= 'Times New Roman';
    bmp.Canvas.Font.Color:=clBlack;
    bmp.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
    bmp.Canvas.Font.Size:= 17;
    bmp.Canvas.TextOut(20, 20, sTexto);
    bmp.Canvas.Font.Size:= 16;
    bmp.Canvas.TextOut(20, 50, sTexto);
    bmp.Canvas.Font.Size:= 15;
    bmp.Canvas.TextOut(20, 80, sTexto);
    bmp.Canvas.Font.Size:= 14;
    bmp.Canvas.TextOut(20, 110, sTexto);
    bmp.Canvas.Font.Size:= 12;
    bmp.Canvas.TextOut(20, 140, sTexto);
    bmp.Canvas.Font.Size:= 11;
    bmp.Canvas.TextOut(20, 170, sTexto);
    bmp.Canvas.Font.Size:= 10;
    bmp.Canvas.TextOut(20, 200, sTexto);
    bmp.Canvas.Font.Size:= 9;
    bmp.Canvas.TextOut(20, 230, sTexto);
    Image1.Picture.Assign(bmp);
  finally
    bmp.Free
  end;
end;

Al ejecutar el código se ve que las líneas correspondientes al tamaño 9 y 8 ocupan exactamente la misma longitud en pantalla, igual pasa entre los tamaños 7 y 6, sin embargo si escribo las mismas líneas en word salen de longitud distinta, o sea bien. ¿A qué puede ser debido? ¿Se os ocurre algo para resolverlo?


La franja horaria es GMT +2. Ahora son las 23:05:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi