TTF: only call FT_Request_Size once after loading.

pull/97/head
whitequark 2016-11-02 08:39:53 +00:00
parent 0e72c606ab
commit b8bec35a0c
1 changed files with 19 additions and 16 deletions

View File

@ -147,6 +147,25 @@ bool TtfFont::LoadFromFile(FT_Library fontLibrary, bool nameOnly) {
if(nameOnly) { if(nameOnly) {
FT_Done_Face(fontFace); FT_Done_Face(fontFace);
fontFace = NULL; fontFace = NULL;
return true;
}
// We always ask Freetype to give us a unit size character.
// It uses fixed point; put the unit size somewhere in the middle of the dynamic
// range of its 26.6 fixed point type, and adjust the factors so that the unit
// matches cap height.
FT_Size_RequestRec sizeRequest;
sizeRequest.type = FT_SIZE_REQUEST_TYPE_REAL_DIM;
sizeRequest.width = 1 << 16;
sizeRequest.height = 1 << 16;
sizeRequest.horiResolution = 128;
sizeRequest.vertResolution = 128;
if(int fterr = FT_Request_Size(fontFace, &sizeRequest)) {
dbp("freetype: cannot set character size: %s",
ft_error_string(fterr));
FT_Done_Face(fontFace);
fontFace = NULL;
return false;
} }
return true; return true;
@ -235,22 +254,6 @@ void TtfFont::PlotString(const std::string &str,
chr, ft_error_string(gid)); chr, ft_error_string(gid));
} }
// We always ask Freetype to give us a unit size character.
// It uses fixed point; put the unit size somewhere in the middle of the dynamic
// range of its 26.6 fixed point type, and adjust the factors so that the unit
// matches cap height.
FT_Size_RequestRec sizeRequest;
sizeRequest.type = FT_SIZE_REQUEST_TYPE_REAL_DIM;
sizeRequest.width = 1 << 16;
sizeRequest.height = 1 << 16;
sizeRequest.horiResolution = 128;
sizeRequest.vertResolution = 128;
if(int fterr = FT_Request_Size(fontFace, &sizeRequest)) {
dbp("freetype: cannot set character size: %s",
ft_error_string(fterr));
return;
}
/* /*
* Stupid hacks: * Stupid hacks:
* - if we want fake-bold, use FT_Outline_Embolden(). This actually looks * - if we want fake-bold, use FT_Outline_Embolden(). This actually looks