Last active
February 11, 2020 16:29
-
-
Save Fuyutsubaki/da5bc0357823da5d6bedbe9eefc2f904 to your computer and use it in GitHub Desktop.
emscriptenでcolor emojiが出ない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// font/に NotoColorEmoji.ttfを置く | |
// binary: clang++ -I /usr/include/freetype2/ -lfreetype tftest.cpp | |
// emscripten: em++ -std=c++17 -s ALLOW_MEMORY_GROWTH=1 -s USE_FREETYPE=1 --preload-file font tftest.cpp -o out.html | |
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
#include FT_TRUETYPE_TABLES_H | |
#include<iostream> | |
int main() | |
{ | |
uint32_t c = U'🐈'; | |
FT_Face face; | |
FT_Library ftlib = nullptr; | |
::FT_Init_FreeType(&ftlib); | |
::FT_New_Face(ftlib, "font/NotoColorEmoji.ttf", 0, &face); | |
FT_ULong length = 0; | |
::FT_Load_Sfnt_Table(face, FT_MAKE_TAG('C', 'B', 'D', 'T'), 0, nullptr, &length); | |
::FT_Select_Size(face,0); | |
uint32_t glyphIndex = FT_Get_Char_Index(face, c); | |
// ここまでゴリゴリ実装 | |
FT_Int x,y,z; | |
::FT_Library_Version(ftlib,&x,&y,&z); | |
std::cout<<x<<"."<<y<<"."<<z<<std::endl; | |
// ここから本題 | |
if (auto error = ::FT_Load_Glyph(face, glyphIndex, FT_LOAD_COLOR)) | |
{ | |
// emscriptenでFT_Load_Glyph=36:128008:497が出る | |
std::cout<<"FT_Load_Glyph="<<error<<":"<<c<<":"<<glyphIndex<<std::endl; | |
return 0; | |
} | |
std::cout<<"complated"<<std::endl; | |
} |
pngに対応してないのが原因と思われる
2.8.1のfreetypeのソースを自前でdownloadしてきて、cmakelistを弄ってpngが動くようにしたら動いた
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
freetypeのversion
バイナリ: 2.8.1
em++: 2.6.0