全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1162
推到 Plurk!
推到 Facebook!

關於讀取字型檔 xxx.ttf

尚未結案
kipa
一般會員


發表:2
回覆:1
積分:0
註冊:2003-10-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-30 11:36:59 IP:210.64.xxx.xxx 未訂閱
我想讀取TTF檔案中的字型名稱 有朋友給了我一段程式碼不過沒學過Delphi function GetFontName(FileNameTTF : string): string; { return the "friendly name" for a TrueType font from a .TTF file } var hFile : file; Buffer : string; TempName : string; iPos, jPos : Integer; begin {Build name for new resource file in} {a temporary file, and call the API.} TempName := ExtractFilePath(Application.ExeName) '~TEMP.FOT'; { build temporary .FOT file for the .TTF } if CreateScalableFontResource(1, PChar(TempName), PChar(FileNameTTF), nil) then begin { open .FOT file and read it into a string buffer } AssignFile(hFile, TempName); Reset(hFile, 1); SetLength(Buffer, FileSize(hFile)); BlockRead(hFile, Buffer[1], FileSize(hFile)); { The name sits behind the text 'FONTRES:' } iPos := Pos('FONTRES:', Buffer) 8; { search for next null character } jPos := iPos; while Buffer[jPos] <> #0 do Inc(jPos); { Return the font name } Result := Copy(Buffer, iPos, jPos - iPos); { clean up } CloseFile(hFile); DeleteFile(TempName); end else Result:='Error'; // ShowMessage(SysErrorMessage(GetLastError)); end; 看來似乎是檔案讀進來後,去找FONTRES:這個字串吧 我用BCB6寫,看了板上文章試著用TMemoryStream讀進來 可去讀進來後,我卻不會比對,試了半天都做不出來 以前都用fstream似乎沒有TMemoryStream好用 第一次用TMemoryStream卻卡住了...
系統時間:2024-06-27 0:04:12
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!