It is possible to make a TLabel
stay vertical, but its text like this:
I have tested some components, but they do not work in the Delphi-XE8 version.
I was able to leave it at 90 degrees, but the numbers go one below the other
Any ideas?
I succeeded as follows. Add text in an image equal to the idea of @ Junior
with the code below.
procedure TForm2.ConvTextOut(CV: TCanvas; const sText: String; x, y,
angle: integer);
var
LogFont: TLogFont;
SaveFont: TFont;
begin
SaveFont := TFont.Create;
SaveFont.Assign(CV.Font);
GetObject(SaveFont.Handle, sizeof(TLogFont), @LogFont);
with LogFont do
begin
lfEscapement := angle *10;
lfPitchAndFamily := FIXED_PITCH or FF_DONTCARE;
end;
CV.Font.Handle := CreateFontIndirect(LogFont);
SetBkMode(CV.Handle, TRANSPARENT);
CV.TextOut(x, y, sText);
CV.Font.Assign(SaveFont);
SaveFont.Free;
end;
ConvTextOut(Origem.Canvas, label1.caption, 0, 0, 0);
Resultado.Width := Origem.Height;
Resultado.Height := Origem.Width;
Resultado.Update;
for k := 0 to Origem.Width do
for Y := 0 to Origem.Height do
Resultado.Canvas.Pixels[Origem.Height-Y, k] := Origem.Canvas.Pixels[k,Y];
One thing that was not 100% in my opinion, was that the caption size inside the image was not a legal size.
You can not rotate the TLabel
component (so far as I discovered), you can find components that support this behavior, FireMonkey is able to generate this effect!
However, follow a procedure that can clear your ideas and maybe get where you want!
Implement this in OnPaint
of the form!
var
lf: TLogFont;
tf: TFont;
begin
with Form1.Canvas do
begin
Font.Name := 'Arial';
Font.Size := 24;
tf := TFont.Create;
try
tf.Assign(Font);
GetObject(tf.Handle, SizeOf(lf), @lf);
lf.lfEscapement := 320;
lf.lfOrientation := 320;
SetBkMode(Handle, TRANSPARENT);
tf.Handle := CreateFontIndirect(lf);
Font.Assign(tf);
finally
tf.Free;
end;
TextOut(10, Height div 2, 'Texto Rotacionado aqui!');
end;
Take a look at FireMonkey , you can find something I can help even more!
If it does not resolve, you can copy String
and generate an image in ( TImage
), rotate and position in TLabel
.
Here's the question and answer on how to convert from String to Image: