let freetype handle notdef glyph
add comment
This commit is contained in:
parent
1d84d62c12
commit
02c5364f23
1 changed files with 36 additions and 4 deletions
|
@ -702,6 +702,7 @@ class Font {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
stringstream text;
|
stringstream text;
|
||||||
|
bool useNotdef = false;
|
||||||
|
|
||||||
for(const auto & glyphIdentity : variationText){
|
for(const auto & glyphIdentity : variationText){
|
||||||
const uint32_t & charcode = glyphIdentity.charcode;
|
const uint32_t & charcode = glyphIdentity.charcode;
|
||||||
|
@ -720,9 +721,31 @@ class Font {
|
||||||
const_cast <FontVariationCoords &>(glyphIdentity.coords)); // danger?
|
const_cast <FontVariationCoords &>(glyphIdentity.coords)); // danger?
|
||||||
|
|
||||||
FT_UInt glyphIndex = FT_Get_Char_Index(face, charcode);
|
FT_UInt glyphIndex = FT_Get_Char_Index(face, charcode);
|
||||||
if(!glyphIndex){
|
// NOTE: 0 means no glyph as in '.notdef'
|
||||||
continue;
|
// we actually WANT the notdef glyph to render
|
||||||
}
|
// and let FreeType handle this.
|
||||||
|
//
|
||||||
|
// we leave the unwanted logic below for reference
|
||||||
|
// and delete it some time when we're absolutely sure
|
||||||
|
// we do not need it (probably yes).
|
||||||
|
//
|
||||||
|
//if(!glyphIndex){
|
||||||
|
//std::cout << "[font] no glyph index for character " << charcode << ": " << "" << std::endl;
|
||||||
|
//if(!useNotdef){
|
||||||
|
//glyphIndex = FT_Get_Char_Index(face, 0x110000);
|
||||||
|
//std::cout << "[font] no glyph index for character " << charcode << ": " << "attempt replace with notdef" << std::endl;
|
||||||
|
//if(!glyphIndex){
|
||||||
|
//glyphIndex = FT_Get_Char_Index(face, 0x25A1);
|
||||||
|
//std::cout << "[font] no glyph index for character " << charcode << ": " << "attempt replace with white square" << std::endl;
|
||||||
|
//if(!glyphIndex){
|
||||||
|
//std::cerr << "[font] absolutely no glyph index for character " << charcode << ": " << "" << std::endl;
|
||||||
|
//continue;
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
//useNotdef = true;
|
||||||
|
//}
|
||||||
|
//continue;
|
||||||
|
//}
|
||||||
|
|
||||||
FT_Error error = FT_Load_Glyph(face, glyphIndex, loadFlags);
|
FT_Error error = FT_Load_Glyph(face, glyphIndex, loadFlags);
|
||||||
if(error){
|
if(error){
|
||||||
|
@ -1318,7 +1341,16 @@ class Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glyphIt = glyphs.find(glyphIdentity);
|
auto glyphIt = glyphs.find(glyphIdentity);
|
||||||
Glyph & glyph = (glyphIt == glyphs.end()) ? glyphs.begin()->second : glyphIt->second; // in case we have no glyph, draw first one?
|
if(glyphIt == glyphs.end()){
|
||||||
|
glyphIt = glyphs.find({0x110000, glyphIdentity.coords});
|
||||||
|
if(glyphIt == glyphs.end()){
|
||||||
|
glyphIt = glyphs.find({0x25A1, glyphIdentity.coords});
|
||||||
|
if(glyphIt == glyphs.end()){
|
||||||
|
glyphIt = glyphs.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Glyph & glyph = glyphIt->second; // in case we have no glyph, draw first one?
|
||||||
// NOTE: should we do this?
|
// NOTE: should we do this?
|
||||||
|
|
||||||
if(previous != 0 && glyph.index != 0){
|
if(previous != 0 && glyph.index != 0){
|
||||||
|
|
Loading…
Reference in a new issue