Hi there,
I'm writing a ttf parser and want to learn from the source code of freetype.
My questions are:
1. a simple problem -- I failed to build a demo project using freetype2.
First, I located "the FreeType 2 include directory" by right clicking on project, Properties, Configuration Properties, VC++ Directories, Include Directories, and added "D:\freeT\freetype2\include". Note that my project directory is "D:\freeT\".
Second, I wrote the following code:
#include <ft2build.h>
#include FT_FREETYPE_H
#include <stdio.h>
int main(){
FT_Library library;
FT_Face face; /* handle to face object */
FT_Error error = FT_Init_FreeType( &library );
if ( error ) { printf("Error!\n"); }
error = FT_New_Face( library,
"arial.ttf",
0,
&face );
if ( error ){
printf("ERROR!\n");
}
printf("Hello");
getchar();
return 0;
}
But finally I got the following error message:
>freeT.obj : error LNK2019: unresolved external symbol _FT_New_Face referenced in function _main
1>freeT.obj : error LNK2019: unresolved external symbol _FT_Init_FreeType referenced in function _main
Why? BTW, I tried to build with freetype253.dll and freetype253.lib and succeed!
2. When does the freetype parse the glyph data?
My ttf_parser reads ttf file and parses the tables into classes right away (This process is laterly referred as LOAD time). But now I wonder if I can delay the glyph data parsing process to the time when users fetch the glyph outline (referred as FETCH time). I have two reasons supporting this change.
a) My program parses the glyph data during the LOAD time, and it's really slow to load a ttf file if the file size is as big as tens of MB. In a word, my ttf_parser is slow in LOAD time but fast in FETCH time. Maybe it would be better if I delay the parsing process to FETCH time? But I am also afraid of the trade-off -- the FETCH process might slow down.
b) I realized that lots of the information are stored sequentially and it's easier for parsing if I don't break the file into pieces of tables. Besides, I cannot pre-determine by how many simple glyph a specific composite glyph is composed (is it?). To deal with it I should use std::vector but I prefer not 'cause I will build my parser into dll and using standard containers will cause some trouble.
Um.. I hope I described my question clearly. Any advise will be appreciated! And I'll keep reading the source of freetype. Thanks for your work.
Liu Zhenglai.