如何将字体(FontStyle,FontColor,FontSize)转换为字符串

Iss*_*ola 3 delphi delphi-7

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

WeG*_*ars 5

要存储字体,您只需要字体的主要属性,而不是全部。我这样做是为了将字体保存到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;
Run Code Online (Sandbox Code Playgroud)