[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freetype] How to get a postscript font's name?
From: |
Anthony Feick |
Subject: |
Re: [Freetype] How to get a postscript font's name? |
Date: |
Mon, 15 Oct 2001 11:26:55 -0500 |
Can someone tell me how to get a postscript font's name from its file
using FT? I see the definition of the T1_FontInfo structure in the FT
docs, and it seems that that structure would give me the info I want,
but I can't figure out how to get one of those puppies from the FT API.
What am I missing?
If you look at the T1_FontInfo structure you actually only get the full_name
and the family_name. The postscript name, or FontName as it is tagged, is
different.
I mentioned this issue back in May (subject 'postscript font names'):
http://www.freetype.org/pipermail/freetype/2001-May/subject.html
My workaround for it was to open up the font file & do a manual search for
the FontName tag:
const char * const kFontName = "/FontName";
unsigned int GetT1PostScriptName(char* fontName)
{
unsigned int headerSize = 5000;
char buffer[5000];
FILE * fontFILE = ::fopen(fontName, "rb");
::fread(buffer, 1, headerSize, fontFILE);
char * tok = NULL;
for (unsigned int i = 0; i < headerSize; ++i)
{
if (strncmp(buffer+i, kFontName, strlen(kFontName)) == 0)
{
tok = strtok(buffer + i + strlen(kFontName), " /\r\n\t");
if(name)
strcpy(name, tok);
return strlen(tok);
}
}
return 0;
}
Hopefully the indents stay so you can read the code. I also had to do
something similar to this to get the Encoding for T1 fonts.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
- Re: [Freetype] How to get a postscript font's name?,
Anthony Feick <=