字体样式与字符串间的转换

来源:互联网 发布:淘宝客建站程序 编辑:程序博客网 时间:2024/06/11 19:56

//---------------------将字体样式转化为字符串--------------------------
function TFrmRptSetup.SetFontStyle(FS: TFontStyles): string;
var
 StrFS:string;
begin
//
  StrFS:='[';

  if fsBold in FS then
  StrFS:=StrFS +'fsBold';

  if fsItalic in FS then
  if StrFS = '[' then
  StrFS:= StrFS +'fsItalic'
  else
  StrFS:= StrFS +',fsItalic';

  if fsUnderline in FS then
  if StrFS = '[' then
  StrFS := StrFS + 'fsUnderline'
  else
  StrFS := StrFS + ',fsUnderline';

  if fsStrikeOut in FS then
  if StrFS = '['then
  StrFS:= StrFS + 'fsStrikeOut'
  else
  StrFS := StrFS + ',fsStrikeOut';

  StrFS := StrFS + ']';
  Result := StrFS;

end;
//----------------------将字符串转化为字体样式--------------------------
function TFrmRptSetup.GetFontStyle(StrFS: string): TFontStyles;
var
FS:TFontStyles;
begin
  FS:=[];
  if pos('fsBold', StrFS)> 0 then FS:= FS +[fsBold];
  if Pos('fsItalic', StrFS)> 0 then FS:= FS + [fsItalic];
  if Pos('fsUnderline', StrFS)>0 then FS:= FS + [fsUnderline];
  if Pos('fsStrikeOut', StrFS)>0 then FS:= FS +[fsStrikeOut];
  Result:= FS;
end;

原创粉丝点击