颜色转换成整型保存{也可以用ColorToString  / stringTOColor}
字体用下面的函数转换成字符串,然后保存

unit xFonts;

interface

uses Classes, Graphics, SysUtils;

procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;

implementation

const
  csfsBold      = '|Bold';
  csfsItalic    = '|Italic';
  csfsUnderline = '|Underline';
  csfsStrikeout = '|Strikeout';

//
  // Expected format:
  //   "Arial", 9, [Bold], [clRed]
  //
procedure StringToFont(sFont: string; Font: TFont; bIncludeColor: Boolean = True);
var
  P     : Integer;
  sStyle: string; 
begin
  with Font do
    try
      // get font name
      P := Pos(',', sFont);
      name := Copy(sFont, 2, P - 3);
      Delete(sFont, 1, P);

// get font size
      P := Pos(',', sFont);
      Size := StrToInt(Copy(sFont, 2, P - 2));
      Delete(sFont, 1, P);

// get font style
      P := Pos(',', sFont);
      sStyle := '|' + Copy(sFont, 3, P - 4);
      Delete(sFont, 1, P);

// get font color
      if bIncludeColor then Color := StringToColor(Copy(sFont, 3, Length(sFont) - 3));

// convert str font style to
      // font style
      Style := [];
      if (Pos(csfsBold, sStyle) > 0) then Style := Style + [fsBold];
      if (Pos(csfsItalic, sStyle) > 0) then Style := Style + [fsItalic];
      if (Pos(csfsUnderline, sStyle) > 0) then Style := Style + [fsUnderline];
      if (Pos(csfsStrikeout, sStyle) > 0) then Style := Style + [fsStrikeOut];
    except
    end;
end;

//
// Output format:
//   "Aril", 9, [Bold|Italic], [clAqua]
//
function FontToString(Font: TFont; bIncludeColor: Boolean = True): string;
var
  sStyle: string;
begin
  with Font do
  begin
    // convert font style to string
    sStyle := '';
    if (fsBold in Style) then sStyle := sStyle + csfsBold;
    if (fsItalic in Style) then sStyle := sStyle + csfsItalic;
    if (fsUnderline in Style) then sStyle := sStyle + csfsUnderline;
    if (fsStrikeOut in Style) then sStyle := sStyle + csfsStrikeout;

if ((Length(sStyle) > 0) and ('|' = sStyle[1])) then
      sStyle := Copy(sStyle, 2, Length(sStyle) - 1);

Result := Format('"%s", %d, [%s]',[name, Size, sStyle]);
    if bIncludeColor then
      Result := Result + Format(', [%s]',[ColorToString(Color)]);
  end;
end;

end.

{对INI文件的操作,这里就在叙述了,需要的朋友 必应一下 一大堆}

文档转载『http://bbs.csdn.net/topics/100124538』

delphi 颜色,字体保存到INI文件的更多相关文章

  1. 记录python爬取猫眼票房排行榜(带stonefont字体网页),保存到text文件,csv文件和MongoDB数据库中

    猫眼票房排行榜页面显示如下: 注意右边的票房数据显示,爬下来的数据是这样显示的: 网页源代码中是这样显示的: 这是因为网页中使用了某种字体的缘故,分析源代码可知: 亲测可行: 代码中获取的是国内票房榜 ...

  2. iOS开发——数据持久化&本地数据的存储(使用NSCoder将对象保存到.plist文件)

    本地数据的存储(使用NSCoder将对象保存到.plist文件)   下面通过一个例子将联系人数据保存到沙盒的“documents”目录中.(联系人是一个数组集合,内部为自定义对象).   功能如下: ...

  3. np.savetxt()——将array保存到txt文件,并保持原格式

    问题:1.如何将array保存到txt文件中?2.如何将存到txt文件中的数据读出为ndarray类型? 需求:科学计算中,往往需要将运算结果(array类型)保存到本地,以便进行后续的数据分析. 解 ...

  4. 关于爬取数据保存到json文件,中文是unicode解决方式

    流程: 爬取的数据处理为列表,包含字典.里面包含中文, 经过json.dumps,保存到json文件中, 发现里面的中文显示未\ue768这样子 查阅资料发现,json.dumps 有一个参数.ens ...

  5. ffmpeg学习(二) 通过rtsp获取H264裸流并保存到mp4文件

    本篇将使用上节http://www.cnblogs.com/wenjingu/p/3977015.html中编译好的库文件通过rtsp获取网络上的h264裸流并保存到mp4文件中. 1.VS2010建 ...

  6. python爬取当当网的书籍信息并保存到csv文件

    python爬取当当网的书籍信息并保存到csv文件 依赖的库: requests #用来获取页面内容 BeautifulSoup #opython3不能安装BeautifulSoup,但可以安装Bea ...

  7. 使用scrapy爬取的数据保存到CSV文件中,不使用命令

    pipelines.py文件中 import codecs import csv # 保存到CSV文件中 class CsvPipeline(object): def __init__(self): ...

  8. 使用pandas中的raad_html函数爬取TOP500超级计算机表格数据并保存到csv文件和mysql数据库中

    参考链接:https://www.makcyun.top/web_scraping_withpython2.html #!/usr/bin/env python # -*- coding: utf-8 ...

  9. 未能将基于用户的Visual C++项目设置保存到user文件错误的解决

    作者:朱金灿 来源:http://blog.csdn.net/clever101 最近遇见一个诡异错误,将Win7家庭版升级到Win7旗舰版.然后使用原来安装的VS2008开发,保存工程时总是出现未能 ...

随机推荐

  1. WIFI 状态栏显示的wifi信号强度与wifisetting列表不一致

    [DESCRIPTION] 状态栏显示的wifi信号强度与wifisetting列表不一致(不同步) [ANALYSIS] 1.apk都是接收RSSI_CHANGED intent,并调用WifiMa ...

  2. Normal Equation of Computing Parameters Analytically

    Normal Equation Note: [8:00 to 8:44 - The design matrix X (in the bottom right side of the slide) gi ...

  3. RSA DH

    https://www.cnblogs.com/hiflora/archive/2013/07/04/3171775.html http://www.ruanyifeng.com/blog/2013/ ...

  4. php实现Bloom Filter

    Bloom Filter(BF) 是由Bloom在1970年提出的一种多哈希函数映射的高速查找算法,用于高速查找某个元素是否属于集合, 但不要求百分百的准确率. Bloom filter通经常使用于爬 ...

  5. [Now] Deploy a Node project with Zeit’s Now

    Use Zeit’s now to deploy a node application from your local machine to a remote cloud service in mom ...

  6. Loader之一:基本原理 分类: H1_ANDROID 2013-11-16 10:29 1923人阅读 评论(0) 收藏

    参考APIDEMO及http://developer.android.com/guide/components/loaders.html#app 1.Introduced in Android 3.0 ...

  7. [内核编程] Windebug双机调试环境搭建

    Windebug双机调试环境搭建    开始进行内核编程/驱动编程的调试工作是非常烦人的,由于程序运行与内核层不受操作系统的管控,所以容易引起主机蓝屏和崩溃是常有的事.这也就使得内核程序的调试成了一大 ...

  8. thinkphp,onethink,thinkox验证码不显示

    使用验证码的时候,一开始正常,后来不显示了 网上说是utf-8的编码问题,什么bom去掉,转化为无bom的格式 我都试了,没用 后来知道是在调用验证码的地方  写上 Public function v ...

  9. [TypeScript] Simplify asynchronous callback functions using async/await

    Learn how to write a promise based delay function and then use it in async await to see how much it ...

  10. window对象属性alert、confirm、prompt怎么使用?

    window对象属性alert.confirm.prompt怎么使用? 一.总结 1.参数依次复杂,返回值依次复杂,但是感觉都是一一继承的,所以很好想也很好写. 二.window对象alert.con ...