use FT_Load_Sfnt_Table to identify color fonts + load color glyphs with FT_LOAD_COLOR
This commit is contained in:
parent
8e97803e81
commit
a6519c3f6b
1 changed files with 17 additions and 6 deletions
|
@ -29,6 +29,7 @@
|
|||
extern "C"
|
||||
{
|
||||
#include FT_GLYPH_H
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -37,16 +38,23 @@ namespace mapnik
|
|||
{
|
||||
|
||||
font_face::font_face(FT_Face face)
|
||||
: face_(face) {}
|
||||
: face_(face)
|
||||
{
|
||||
static const uint32_t tag = FT_MAKE_TAG('C', 'B', 'D', 'T');
|
||||
unsigned long length = 0;
|
||||
FT_Load_Sfnt_Table(face_, tag, 0, nullptr, &length);
|
||||
if (length) color_font_ = true;
|
||||
}
|
||||
|
||||
bool font_face::set_character_sizes(double size)
|
||||
{
|
||||
return (FT_Set_Char_Size(face_,0,static_cast<FT_F26Dot6>(size * (1<<6)),0,0) == 0);
|
||||
return (FT_Set_Char_Size(face_, 0, static_cast<FT_F26Dot6>(size * (1 << 6)), 0, 0) == 0);
|
||||
}
|
||||
|
||||
bool font_face::set_unscaled_character_sizes()
|
||||
{
|
||||
return (FT_Set_Char_Size(face_,0,face_->units_per_EM,0,0) == 0);
|
||||
FT_F26Dot6 char_height = face_->units_per_EM > 0 ? face_->units_per_EM : 2048.0;
|
||||
return (FT_Set_Char_Size(face_, 0, char_height, 0, 0) == 0);
|
||||
}
|
||||
|
||||
bool font_face::glyph_dimensions(glyph_info & glyph) const
|
||||
|
@ -54,11 +62,14 @@ bool font_face::glyph_dimensions(glyph_info & glyph) const
|
|||
FT_Vector pen;
|
||||
pen.x = 0;
|
||||
pen.y = 0;
|
||||
if (color_font_) FT_Select_Size(face_, 0);
|
||||
FT_Set_Transform(face_, 0, &pen);
|
||||
|
||||
if (FT_Load_Glyph(face_, glyph.glyph_index, FT_LOAD_NO_HINTING))
|
||||
FT_Int32 load_flags = FT_LOAD_DEFAULT;// | FT_LOAD_NO_HINTING;
|
||||
if (color_font_) load_flags |= FT_LOAD_COLOR ;
|
||||
if (FT_Load_Glyph(face_, glyph.glyph_index, load_flags))
|
||||
{
|
||||
MAPNIK_LOG_ERROR(font_face) << "FT_Load_Glyph failed";
|
||||
MAPNIK_LOG_ERROR(font_face) << "FT_Load_Glyph failed :( index=" << glyph.glyph_index << " " << load_flags
|
||||
<< " " << face_->family_name << " " << face_->style_name ;
|
||||
return false;
|
||||
}
|
||||
FT_Glyph image;
|
||||
|
|
Loading…
Add table
Reference in a new issue