Font Characteristics and TextMetrics
I was trying to write a quick five minute program to report the
characteristics of a font would be but I am not getting the figures I
expect to see. I think it has something to do with Pixels per inch but I
still can't get it exact. Am I doing something obviously wrong? Please
post AND email all replys, my newsserver is poor. Here is the boiled down
version of what I do:
procedure TForm1.docalcs;
var
MyLineHeight : Double;
begin
Form2.font:=FontDialog1.font;
GetTextMetrics( Form2.canvas.Handle, TextMetrics );
MyLineHeight:=((TextMetrics.tmHeight+
(TextMetrics.tmExternalLeading))/Form2.pixelsperinch);
LineHeight.text:=floattostr(MyLineHeight);
LinesPerInch.text:=floattostr(1/MyLineHeight);
AvgCPI.text:=floattostr(1/((TextMetrics.tmAveCharWidth)/Form2.pixelsperinch)
);
LeastCPI.text:=floattostr(1/((TextMetrics.tmMaxCharWidth)/Form2.pixelsperinc
h));
end;
--
Brian C. Layman
Director of Software Development
SoftForms Development Corporation
http://www.softforms.com
BLay...@Softforms.com