Displaying text works on emscripten version

This commit is contained in:
Yousef Khadadeh 2025-11-11 19:52:45 +03:00
parent cdbff3c043
commit b8fb00e218
6 changed files with 38 additions and 15 deletions

View file

@ -5,6 +5,7 @@
#include <Eigen/Dense>
#include <include/core/SkFont.h>
#include <include/core/SkFontMgr.h>
#include <include/core/SkTypeface.h>
#include <modules/skparagraph/include/FontCollection.h>
#include <modules/svg/include/SkSVGDOM.h>
#include <Helpers/SCollision.hpp>
@ -108,7 +109,6 @@ struct UpdateInputData {
SkFont get_font(float fSize) const;
uint16_t fontSize = 16;
sk_sp<SkTypeface> textTypeface;
sk_sp<skia::textlayout::FontCollection> fontCollection;
@ -116,7 +116,11 @@ struct UpdateInputData {
bool hoverObstructed = false;
bool acceptingTextInput = false;
float deltaTime = 0.0f;
sk_sp<SkFontMgr> textFontMgr;
sk_sp<SkFontMgr> textFontMgrLocal;
sk_sp<SkFontMgr> textFontMgrFallback;
sk_sp<SkTypeface> textTypeface;
DefaultStringArena* strArena;
std::shared_ptr<Theme> theme;
std::unordered_map<std::string, sk_sp<SkSVGDOM>> svgData;

View file

@ -10,9 +10,21 @@
bool GUIStuff::FontPicker::update(UpdateInputData& io, std::string* fontName, GUIManager* gui) {
if(sortedFontList.empty()) {
auto icu = SkUnicodes::ICU::Make();
for(int i = 0; i < io.textFontMgr->countFamilies(); i++) {
for(int i = 0; i < io.textFontMgrLocal->countFamilies(); i++) {
SkString familyNameSkString;
io.textFontMgr->getFamilyName(i, &familyNameSkString);
io.textFontMgrLocal->getFamilyName(i, &familyNameSkString);
if(familyNameSkString.isEmpty())
continue;
std::string familyName(familyNameSkString.c_str(), familyNameSkString.size());
sortedFontList.emplace_back(familyName);
std::transform(familyName.begin(), familyName.end(), familyName.begin(), ::tolower);
sortedFontListLowercase.emplace_back(familyName);
}
for(int i = 0; i < io.textFontMgrFallback->countFamilies(); i++) {
SkString familyNameSkString;
io.textFontMgrFallback->getFamilyName(i, &familyNameSkString);
if(familyNameSkString.isEmpty())
continue;
std::string familyName(familyNameSkString.c_str(), familyNameSkString.size());
sortedFontList.emplace_back(familyName);
std::transform(familyName.begin(), familyName.end(), familyName.begin(), ::tolower);