|
-
May 22nd, 2017, 01:03 PM
#1
Re: [VB6] Parse Font Name from TTF File/Data
I know someone will mention this, so I'll respond in advance... Why are you not using the table count provided within the TTF format?
The TTF format has a 12-byte header. In that header, it identifies how many tables exist. It also provides some information to enable you to do a binary search to quickly locate a table vs. a sequential search.
You can't trust that header. I've found at least one font that Microsoft happily installed. Its structure said only two tables existed. There is a minimum of 9 required tables. So if the table count was wrong, so was that other info pertaining to binary searches. In that specific example, the 18th table was the one I was looking for. It existed (is a required table), but the table count was entered incorrectly. Probably could've found more, but I chose to write the routines to skip past that header & begin a sequential search; validating as I went along.
Edited: One requirement I refused to be lenient on... Per specifications, each table must be sorted, by name, in ascending order. FYI: Sorted data is a prerequisite for binary searches. So, if that rule is not enforced by the TTF creator, the above routines would abort if the 'name' table came after some other table name higher in the order.
Update: The header must be trusted else the font should be considered invalid or corrupted. After much more research and testing, I found that the fonts in question were actually TTC font files, containing multiple fonts and another table prepended to the file. I have since rewrote the code to address this newer format and some of the following posts touch on that.
Last edited by LaVolpe; May 23rd, 2017 at 06:06 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|