--I am working on Webassembly+Skia and since there is no default system fonts in web I was wondering whether there is any way to load custom fonts. If possible how would one achieve it?I have tried this,
static std::map<std::string, sk_sp<SkTypeface>> fontFiles;static void addFontFile(std::string fontName, std::string fontFile) {std::cout << "Adding font file" << std::endl;sk_sp<SkData> data = SkData::MakeFromMalloc(fontFile.c_str(), fontFile.length());auto typeface = SkTypeface::MakeFromData(data);fontFiles[fontName] = typeface;if(typeface == nullptr){std::cout << "Typeface is null" << std::endl;}}
Whenever I am sending a .ttc file as std::string. Typeface returned is always null.
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/afa50165-60b1-4fad-b2c6-d877359019e5%40googlegroups.com.
This might be caused by std::string not behaving exactly like an array of chars. Have you tried using char* instead?
Also, I'm in a similar sitaution, and I use Emscripten's file system API ( https://emscripten.org/docs/api_reference/Filesystem-API.html ) to simulate font files and load typefaces using SkTypeface::MakeFromFile.
On Fri, 3 Jan 2020 at 11:36, Name Unknown <dfau...@gmail.com> wrote:
--I am working on Webassembly+Skia and since there is no default system fonts in web I was wondering whether there is any way to load custom fonts. If possible how would one achieve it?I have tried this,
static std::map<std::string, sk_sp<SkTypeface>> fontFiles;static void addFontFile(std::string fontName, std::string fontFile) {std::cout << "Adding font file" << std::endl;sk_sp<SkData> data = SkData::MakeFromMalloc(fontFile.c_str(), fontFile.length());auto typeface = SkTypeface::MakeFromData(data);fontFiles[fontName] = typeface;if(typeface == nullptr){std::cout << "Typeface is null" << std::endl;}}
Whenever I am sending a .ttc file as std::string. Typeface returned is always null.
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.
This might be caused by std::string not behaving exactly like an array of chars. Have you tried using char* instead?
Also, I'm in a similar sitaution, and I use Emscripten's file system API ( https://emscripten.org/docs/api_reference/Filesystem-API.html ) to simulate font files and load typefaces using SkTypeface::MakeFromFile.
On Fri, 3 Jan 2020 at 11:36, Name Unknown <dfau...@gmail.com> wrote:
--I am working on Webassembly+Skia and since there is no default system fonts in web I was wondering whether there is any way to load custom fonts. If possible how would one achieve it?I have tried this,
static std::map<std::string, sk_sp<SkTypeface>> fontFiles;static void addFontFile(std::string fontName, std::string fontFile) {std::cout << "Adding font file" << std::endl;sk_sp<SkData> data = SkData::MakeFromMalloc(fontFile.c_str(), fontFile.length());auto typeface = SkTypeface::MakeFromData(data);fontFiles[fontName] = typeface;if(typeface == nullptr){std::cout << "Typeface is null" << std::endl;}}
Whenever I am sending a .ttc file as std::string. Typeface returned is always null.
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.
---- failed to open <0> as a font
Great!