Hello,
One physical machine running Linux Debian 11 and VirtualBox, one virtual machine running Seven.
Starting Lazarus 2.2.6 in Debian,
Project / New Project / Application, 1 TButton, 1 TMemo, 5 lines of code :
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
Memo1.Font.Name:='Bonita';
Memo1.Font.Size:=60; // 60 to nicely see the problem
Memo1.Append('Bonita');
Memo1.Append('Bonita');
end;
and F9, then opening the project (shared folder) in Seven and voilà :
Debian-Seven.png
Why the Seven window bigger than the Debian window ? If same size, the Seven TMemo looks like empty !
The caret is
77 px height in Debian and
100 px in Seven,
heavy in Debian and
light in Seven, and there are
22 px between the 2 "B" in Debian and
47 in Seven.
Cross-platform, Lazarus, really ? I expected the same results, so I loose my time trying to understand what is happening, but I haven't the skills.
I'm just a fonts' lover.
But sincerly: Why are you doing it in the hard way? Why don't you use the standard TCanvas when you only draw on a bitmap to display it in a TImage?
with something like that ?
procedure TForm1.Button2Click(Sender: TObject);
var
Bitmap: TBitmap;
Metric: TLCLTextMetric;
begin
Bitmap := TBitmap.Create;
Bitmap.Height := 50;
Bitmap.Width := 500;
Bitmap.Canvas.Font.Name:='Palatino Linotype';
Bitmap.Canvas.Font.Height:=20;
Bitmap.Canvas.GetTextMetrics(Metric);
Bitmap.Canvas.TextOut(0, 1, 'Test JjgÄÉÊ ' + IntToStr(Metric.Height) + ' = ' + IntToStr(Metric.Ascender) + ' + ' + IntToStr(Metric.Descender));
Image2.Picture.Assign(Bitmap);
Bitmap.Free;
end;
I loose accents (Basic button) :
img_3tries
3 tries, 3 different values ! A nightmare I've said, yesterday...
Also discovered the following (read comments) :
procedure TForm1.FormPaint(Sender: TObject);
var
tm: TLCLTextMetric;
begin
// regarding Font.name, both commented out so prog uses ide params and shows ÄÉÊ
// but the font is NOT the good one I need !
// if one is activated, prog looses accents and shows AEE...
Label1.Font.Name:='Palatino Linotype'; // new, jpt
// Label1.Font.Name:='Bonita'; // new, jpt
Label1.Font.Size:=20; // new, jpt
Label1.Canvas.GetTextMetrics(tm);
Label2.Caption := Format('Font metrics from Canvas.GetTextMetrics: ' + LineEnding +
'Ascender = %d' + LineEnding +
'Descender = %d' + LineEnding +
'Height = %d', [tm.Ascender, tm.Descender, tm.Height]);
end;
(no image)
And look at the yellow result, below, made with the TFPCustomImage, TFPImageCanvas and TFreeTypeFont, and use the red lines to compare.
I don't understand why the accent on the E between the A and the other E is smaller on the left than on the right, it's a mystery.
But noticed one hour ago that the
font is
wrong, re-read previous text.
And below, in skyblue, a try with LO Writer, which is better than the yellow and lightgray tries.
3tries-with-lowriter
Regards, (not available from this afternoon to late tomorrow morning, see you later, alligator !)
--
jp