delphi - 如何将字体(FontStyle、FontColor、FontSize)转换为字符串

标签 delphi delphi-7

我想在 SQL 数据库中保存字体(FontStyle、FontColor、FontSize),为此,我需要将其保存为字符串。如何将 Tfont 转换为 TString?

最佳答案

要存储字体,您只需要字体的主要属性,而不是全部。我这样做是为了将字体保存到 INI 文件中。您可以轻松地将其转换为返回字符串(TString)的函数:

procedure TMyIniFile.WriteFont(CONST Section, Ident: string; Value: TFont);
begin
  WriteString (Section, Ident + 'Name',    Value.Name);
  WriteInteger(Section, Ident + 'CharSet', Value.CharSet);
  WriteInteger(Section, Ident + 'Color',   Value.Color);
  WriteInteger(Section, Ident + 'Size',    Value.Size);
  WriteInteger(Section, Ident + 'Style',   Byte(Value.Style));
end;

关于delphi - 如何将字体(FontStyle、FontColor、FontSize)转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19163832/

相关文章:

delphi - 将字符串从代码页 1252 转换为 1250 并返回

Delphi 7 调用 DelphiXE2 dll 导致宽字符串损坏

delphi - 如何在 Delphi 7 中使窗体上的画线不可见

java - Delphi XE5 可以编译一个可以用'System.loadLibrary 在Java 中加载的.so 库吗?

Delphi 和 SAML(Web 应用程序或桌面应用程序)?

delphi - 不使用节读取值

delphi - 如何使编辑控件不接受 0 作为第一位数字?

class - DXE7 : "type A = type B" and var x (of type A):= A. create 导致 E2010 不兼容类型编译错误。为什么?

Delphi 接口(interface)和类变量类型

delphi - 使用 TabStop 和 FocusRect 实现 TLabel?