![]() |
Wie LogFont-Struktur füllen?
Hallo wie kann ich die LogFont-Struktur füllen? Die LogFont-Struktur enthält Informationen zu einer Schrift. Einge dieser Infos benötige ich. Wenn ich die LogFont-Struktur mit dem unteren Code fülle, sind lfHeight und lfWidth und auch andere Felder bei allen Fonts immer gleich, obwohl sie es nicht sein dürften.
Delphi-Quellcode:
Dieser Code gibt folgendes aus:
procedure TForm1.Button1Click(Sender: TObject);
procedure TestLogFont(const FontName: string); var LogFont: TLogFont; begin Canvas.Font.Name := FontName; FillChar(LogFont, SizeOf(LogFont), 0); GetObject(Canvas.Font.Handle, SizeOf(TLogFont), @LogFont); Memo1.Lines.Add('lfFaceName: ' + LogFont.lfFaceName); Memo1.Lines.Add('lfHeight: ' + IntToStr(LogFont.lfHeight)); Memo1.Lines.Add('lfWidth: ' + IntToStr(LogFont.lfWidth)); end; begin Memo1.Lines.Clear; TestLogFont('Arial'); TestLogFont('Comic Sans MS'); end;
Delphi-Quellcode:
Ich brauche auch einige andere Werte aus der LogFont-Struktur, deswegen jetzt bitte nicht schreiben, dass man auch auf andere Wege die Höhe/Breite ermitteln kann.
lfFaceName: Arial
lfHeight: -11 (richtig wäre 36) lfWidth: 0 (richtig wäre 14) lfFaceName: Comic Sans MS lfHeight: -11 (richtig wäre 45) lfWidth: 0 (richtig wäre 15) Vielen Dank im Voraus! |
Re: Wie LogFont-Struktur füllen?
Zitat:
MSDN: lfHeight lfHeight Specifies the height, in logical units, of the font's character cell or character. The character height value (also known as the em height) is the character cell height value minus the internal-leading value. The font mapper interprets the value specified in lfHeight in the following manner. Value Meaning > 0 The font mapper transforms this value into device units and matches it against the cell height of the available fonts. 0 The font mapper uses a default height value when it searches for a match. < 0 The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts. For all height comparisons, the font mapper looks for the largest font that does not exceed the requested size. This mapping occurs when the font is used for the first time. For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a specified point size: lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); MSDN: lfWidth Specifies the average width, in logical units, of characters in the font. If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference. Zitat:
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz