有些字体只有中等和粗体.鉴于下面的代码,我必须一起避免TFontDialog吗? 从Dialog中选择样式媒体时,它返回权重500集样式BOLD.如果我保存这个样式并打开TFontDialog备份它现在设置为BOLD. FW
从Dialog中选择样式媒体时,它返回权重500集样式BOLD.如果我保存这个样式并打开TFontDialog备份它现在设置为BOLD.
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;不幸的是,VCL提供的TFontDialog对此没有任何了解,也没有Delphi中的TFont. VCL仅承认粗体或非粗体,没有中间字体粗细.您必须完全绕过这些并实现自己的对话框和字体对象来完成此类功能.