AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Wie LogFont-Struktur füllen?

Ein Thema von BlueStarHH · begonnen am 17. Apr 2008 · letzter Beitrag vom 17. Apr 2008
Antwort Antwort
BlueStarHH

Registriert seit: 28. Mär 2005
Ort: Hannover-Hainholz
801 Beiträge
 
Delphi 11 Alexandria
 
#1

Wie LogFont-Struktur füllen?

  Alt 17. Apr 2008, 15:57
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:
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;
Dieser Code gibt folgendes aus:

Delphi-Quellcode:
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)
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.

Vielen Dank im Voraus!
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#2

Re: Wie LogFont-Struktur füllen?

  Alt 17. Apr 2008, 17:05
Zitat von BlueStarHH:
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.
Wie kommst du dazu, dass sie nicht gleich sein dürfen? Ich zitier mal kurz die MSDN dazu:

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 von BlueStarHH:
Dieser Code gibt folgendes aus:

Delphi-Quellcode:
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)
Mit anderen Worten: Woher du deine Vergleichswerte auch immer hast, der Ersteller der Fonts bzw. Nutzer hat diese angepasst.

Zitat von BlueStarHH:
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.
Mit den Daten kommt man nicht so schnell auf die Höhe/Weite, somit haben die damit nicht allzu viel zu tun.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz