Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: reading font name from font file

366 views
Skip to first unread message

Rudy Velthuis [TeamB]

unread,
Jun 8, 2007, 1:40:45 AM6/8/07
to
08.06.2007 04:36:32, Mr. X wrote:

> Hi Rudy
> I did have a look at all those functions in MSDN before getting here
> :)
>
> The problem with those functions is that you need to assign a font
> (name et al) to the DC before being able to retrieve tjhe related
> data. However, how would i know the font names while adding them to
> the system font resource ? Thanks again

I have no idea how to read them from the fonts on disk. Followup to
.nativeapi.win32.
--
Rudy Velthuis [TeamB] http://rvelthuis.de

"Courage: Two cannibals having oral sex."

Mr. X

unread,
Jun 8, 2007, 3:57:46 AM6/8/07
to
Hi Rudy,

ok
Below, is what i am doing to load the fonts. Now i can read and load the
font file from disk but i need to know the name of the font .. and findfont
cannot supply font name and related data until i apply the font to the
concerned DC and so i have looped to what i was askin in the first place ..
how to get the font name from a font file ? :)

Thanks and Best Regards

if FindFirst(sPath + '*.*', faAnyFile, SR) = 0 then
begin
repeat
if SR.Attr <> faDirectory then
begin
Ext := AnsiUpperCase(ExtractFileExt(SR.Name));
if (Ext = '.TTF') then
begin
FExtList.Add(SR.Name);
Num := Num + AddFontResource(PChar(sPath + SR.Name));
end;
end;
until FindNext(SR) <> 0;
FindCLose(SR);
end;

if FExtList.Count > 0 then
begin
SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
ListBox1.Items.Clear;
ListBox1.Items := Screen.Fonts;
end;

"Rudy Velthuis [TeamB]" <newsg...@rvelthuis.de> wrote in message
news:xn0f77cbac4...@teamb.com...

Jean-Marie Pierrard

unread,
Jun 8, 2007, 7:10:34 AM6/8/07
to
Hi Mr. X,

1) an undocumented way :

procedure TForm1.Button1Click(Sender: TObject);
var
dwLength: DWORD;
hDll: THandle;
GetFontResourceInfo: function(wzFontName: PWideChar; var
dwBufSiz: DWORD;
wzBuffer: PWideChar; dwInfo: DWORD): DWORD; stdcall;
wzFontInfo: array[0..MAX_PATH] of WideChar;
begin
hDll := GetModuleHandle(gdi32);
GetFontResourceInfo := GetProcAddress(hDll,
'GetFontResourceInfoW');
dwLength := SizeOf(wzFontInfo);
GetFontResourceInfo('Arial.ttf', dwLength, wzFontInfo, 1);
ShowMessage('Font name = ' + wzFontInfo);
end;

2) a documented way :

Retrieving font name from TTF file
http://www.codeproject.com/gdi/fontnamefromfile.asp

Best regards,

Jean-Marie

"Mr. X" <no...@here.yet> wrote in message
news:4669...@newsgroups.borland.com...

Peter Below (TeamB)

unread,
Jun 8, 2007, 7:44:38 AM6/8/07
to
Mr. X wrote:

> Hi Rudy,
>
> ok
> Below, is what i am doing to load the fonts. Now i can read and load
> the font file from disk but i need to know the name of the font ..
> and findfont cannot supply font name and related data until i apply
> the font to the concerned DC and so i have looped to what i was askin
> in the first place .. how to get the font name from a font file ? :)

Go Googling for

TTF font file format

The first hits look quite promising...


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com

Mr. X

unread,
Jun 8, 2007, 9:15:57 AM6/8/07
to
Hi Jean
Thanks ... this looks like what I need. Checking them both.

Best Regards

"Jean-Marie Pierrard" <jmpie...@hotmail.com> wrote in message
news:466938fe$1...@newsgroups.borland.com...

Mr. X

unread,
Jun 8, 2007, 9:16:49 AM6/8/07
to
Thanks Peter... looking at that too.

Best Regards

"Peter Below (TeamB)" <none> wrote in message
news:xn0f77ly...@newsgroups.borland.com...

lans...@gmail.com

unread,
Aug 10, 2014, 10:17:06 PM8/10/14
to
Thanks, Peter.
0 new messages