mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Implement FreeTypeFont::hasCodePoint()
This commit is contained in:
parent
7cd92041b3
commit
556dcceaff
@ -83,6 +83,15 @@ namespace ft {
|
||||
return int(m_face->descender * y_scale);
|
||||
}
|
||||
|
||||
bool hasCodePoint(int codepoint) const {
|
||||
if (m_face) {
|
||||
codepoint = FT_Get_Char_Index(m_face, codepoint);
|
||||
return (codepoint != 0);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Cache& cache() { return m_cache; }
|
||||
|
||||
protected:
|
||||
|
@ -20,7 +20,6 @@ namespace she {
|
||||
FreeTypeFont::FreeTypeFont(const char* filename, int height)
|
||||
: m_face(m_ft.open(filename))
|
||||
{
|
||||
ASSERT(m_face.isValid());
|
||||
if (m_face.isValid())
|
||||
m_face.setSize(height);
|
||||
}
|
||||
@ -71,7 +70,7 @@ void FreeTypeFont::setAntialias(bool antialias)
|
||||
|
||||
bool FreeTypeFont::hasCodePoint(int codepoint) const
|
||||
{
|
||||
return true; // TODO
|
||||
return m_face.hasCodePoint(codepoint);
|
||||
}
|
||||
|
||||
FreeTypeFont* loadFreeTypeFont(const char* filename, int height)
|
||||
|
@ -39,6 +39,13 @@ retry:;
|
||||
uint32_t code = *it;
|
||||
if (code && !font->hasCodePoint(code)) {
|
||||
Font* newFont = font->fallback();
|
||||
|
||||
// Search a valid fallback
|
||||
while (newFont && !newFont->hasCodePoint(code))
|
||||
newFont = newFont->fallback();
|
||||
if (!newFont)
|
||||
break;
|
||||
|
||||
y += font->height()/2 - newFont->height()/2;
|
||||
|
||||
font = newFont;
|
||||
|
Loading…
Reference in New Issue
Block a user