Einige Schriftarten haben nur ein mittleres und ein fettes Gewicht. Mit dem folgenden Code muss ich TFontDialog alle zusammen vermeiden? Bei der Auswahl des Stils Medium aus dem Dialog wird die Gewichtung 500 als Stil BOLD zurückgegeben. Wenn ich diesen Style speichere und TFontDialog wieder öffne, ist er jetzt auf BOLD gesetzt.Wie stelle ich Schriftarten mit mittlerer Schriftgröße mit TFontDialog ein?
FW_THIN = 100;
{$EXTERNALSYM FW_EXTRALIGHT}
FW_EXTRALIGHT = 200;
{$EXTERNALSYM FW_LIGHT}
FW_LIGHT = 300;
{$EXTERNALSYM FW_NORMAL}
FW_NORMAL = 400;
{$EXTERNALSYM FW_MEDIUM}
FW_MEDIUM = 500;
{$EXTERNALSYM FW_SEMIBOLD}
FW_SEMIBOLD = 600;
{$EXTERNALSYM FW_BOLD}
FW_BOLD = 700;
{$EXTERNALSYM FW_EXTRABOLD}
FW_EXTRABOLD = 800;
{$EXTERNALSYM FW_HEAVY}
FW_HEAVY = 900;
{$EXTERNALSYM FW_REGULAR}
FW_REGULAR = FW_NORMAL;
procedure TFontDialog.UpdateFromLogFont(const LogFont: TLogFont);
var
Style: TFontStyles;
begin
with LogFont do
begin
Font.Name := LogFont.lfFaceName;
Font.Height := LogFont.lfHeight;
if FFontCharsetModified then
Font.Charset := TFontCharset(LogFont.lfCharSet);
Style := [];
with LogFont do
begin
if lfWeight > FW_REGULAR then Include(Style, fsBold);
if lfItalic <> 0 then Include(Style, fsItalic);
if lfUnderline <> 0 then Include(Style, fsUnderline);
if lfStrikeOut <> 0 then Include(Style, fsStrikeOut);
end;
Font.Style := Style;
end;
end;
Entsprechend diesem Code, ja - TFontDialog wird nicht für Sie arbeiten, weil jede Schriftart Gewicht> FW_REGULAR fügt nur 'fsBold' zu den' Font.Style', und keine anderen Schriftartengewichte berücksichtigt werden. Dies würde bedeuten, dass Gewichte <= FW_REGULAR nicht fett und> FW_REGULAR ohne andere Überlegungen wären. –
Beachten Sie, dass dies eine Einschränkung von 'TFontDialog' selbst ist, nicht die zugrunde liegende Win32' ChooseFont() 'API. Die VCL hat kein Konzept eines "mittleren" Stils für Schriftarten, eine Schriftart ist entweder fett oder nicht. –