如何安装、删除系统中已有的字体(50分)

  • 主题发起人 主题发起人 3h
  • 开始时间 开始时间
3

3h

Unregistered / Unconfirmed
GUEST, unregistred user!
有一问题请教诸位大侠,有很多字体文件,如*.FNT,*.FOT等,如何使它们安装到WINDOWS的目录中让WINDOWS承认呢?最好能够弹出一个象WINDOWS那样的对话框。另外如何删除系统中已有的字体呢?多谢! <br><br>
 
增加字体比较容易,删除稍微困难点,<br>因为Windows的字体管理功能很差!<br><br>AddFontResource('c:/simkai.ttf')<br>RemoveFontResource('c:/simkai.ttf')
 
删除后别忘了要用SendMessage发送一条WM_FONTCHANGE消息通知其他程序
 
全说了:((<br>我的答案:参见已答问题
 
no,no,no。<br>我用过不行,没有任何反应的。<br>就算有发送也不行。系统没有任何反应,在控制面板中的<br>字体文件夹也找不到任何迹象。<br>再问相近的一个问题,用screen.font忘记后面有没有S了,<br>反正差不多,用这个获得系统字体的列表,但在“字体”<br>文件夹删或加字体后,再用这个取列表,竟然没改,非得<br>应用程序重新起动,为什么?有没有办法解决?<br>多谢!
 
哈哈,这个问题正好碰到我了 :-)<br>Screen.Fonts是在程序启动时初始化的,<br>不会在任何时候更新。<br><br>我有一个完整的程序演示如何安装新字体,<br>可以给你发过去。
 
1.添加,删除后都要发送一条WM_FONTCHANGE消息通知其他程序系统字体表发生了变化<br>2.删除字体后如果字体正在被某一个程序使用,则系统字体表不会发生变化, 一直到使<br>&nbsp; 用该字体的全部进程释放后才改变.<br>3.用AddFontResource添加的字体好像是不会影响到Windows系统目录下的Fonts目录,<br>&nbsp; 所以用控制面板是看不到变化的<br>4.Windows/Fonts目录下的字体每次启动机器是自动装入系统的,用RemoveFontResourde<br>&nbsp; 函数好像不会把这个目录下的字体文件删除<br><br>
 
&nbsp; windows中关于字体的信息是放在注册表<br>HKEY_LOCAL_MACHINE/SoftWare/Microsoft/Windows/CurrentVersion/Fonts条目中
 
to dwwang: 那就要快了。 ;)<br><br>问题接着来,对于TTF的字体如何取得信息?
 
什么?难道你没收到我的e-mail?<br>
 
有的。现在的问题是,请先看我的程序:<br>procedure TMainForm.FileListBox1Click(Sender: TObject);<br>Var<br>&nbsp; &nbsp; &nbsp;i : Integer;<br>&nbsp; &nbsp; &nbsp;Path : String;<br>&nbsp; &nbsp; &nbsp;RemoveOK : Boolean;<br>begin<br>&nbsp; &nbsp; &nbsp;RemoveOk := true;<br>&nbsp; &nbsp; &nbsp;If OneFileName &lt;&gt; '' then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Edit1.Font.Name := FontNameList.Items[1];<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage(OneFileName);<br>&nbsp; &nbsp; &nbsp; &nbsp; while RemoveOK do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if RemoveFontResource(PChar(OneFileName))=true then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessage('ok'); &nbsp;《-- 在这里老显示OK。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RemoveOK := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else showmessage('no');<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );<br>&nbsp; &nbsp; &nbsp; &nbsp; OneFileName := '';<br>&nbsp; &nbsp; &nbsp; &nbsp; End;<br><br>&nbsp; &nbsp; &nbsp;If FileListBox1.SelCount = 1 then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; OneFileName := FileListBox1.FileName;<br>&nbsp; &nbsp; &nbsp; &nbsp; AddFontResource(Pchar(OneFileName));<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );<br><br>&nbsp; &nbsp; &nbsp; &nbsp; If ViewP.Down then &nbsp; 〈--VIEWP是一个ToolBar97的按钮,用来决定是否预览。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FillList;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for i:=0 to FFonts.Count - 1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if FontNameList.Items.IndexOf(FFonts.Strings)= -1 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If FFonts.Strings[1] &lt;&gt; '@' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessage(FFonts.Strings); &nbsp;《-见后<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Edit1.Font.Name := FFonts.Strings;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>end;<br><br>在见后那里,可能由于不能移除原来那个字体的原因,会重复几次出现字体名。<br>应该是不能移除的原因吧?<br>请大家共同研究,并祝大家新年好!<br><br>注:FillList是dwwang写的让FFonts取得字体名列表的过程。
 
多人接受答案了。
 

Similar threads

后退
顶部