Get ICU working on Emscripten builds (build is massive for now, shrink it later)

This commit is contained in:
Yousef Khadadeh 2025-10-13 18:54:33 +03:00
parent 525da85f51
commit da6b245a9b
6 changed files with 29 additions and 17 deletions

View file

@ -2,6 +2,8 @@
#include "CollabTextBoxShaper.hpp"
#include <iostream>
#include <include/core/SkFont.h>
#include <include/core/SkFontMetrics.h>
#include <include/core/SkFontMgr.h>
@ -12,15 +14,12 @@
#include <include/core/SkTextBlob.h>
#include <include/core/SkTypes.h>
#include <include/private/base/SkTFitsIn.h>
#include <modules/skshaper/include/SkShaper.h>
#include <src/base/SkUTF.h>
#include <modules/skshaper/include/SkShaper.h>
#include <modules/skshaper/include/SkShaper_harfbuzz.h>
#include <modules/skshaper/include/SkShaper_skunicode.h>
#include <modules/skshaper/include/SkShaper_factory.h>
#include <modules/skunicode/include/SkUnicode.h>
#include <modules/skunicode/include/SkUnicode_icu.h>
#include <cfloat>
@ -288,8 +287,7 @@ CollabTextBox::ShapeResult CollabTextBox::shape(const char* utf8Text,
//shaper = SkShaper::MakePrimitive();
//#else
shaper = SkShapers::HB::ShaperDrivenWrapper(unicode, fontMgr);
//#endif
//#endi
SkASSERT(shaper);
float height = font.getSpacing();

View file

@ -101,6 +101,9 @@ extern "C"
}
#endif
#include <unicode/udata.h>
std::string icudt; // Put this in global space so that it isn't deallocated
struct MainStruct {
#ifdef USE_BACKEND_VULKAN
#ifdef USE_SKIA_BACKEND_GANESH
@ -385,6 +388,14 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
listOfFilesToOpenFromCommand.emplace_back(std::filesystem::canonical(std::filesystem::path(argv[i])));
switch_cwd();
UErrorCode uerr = U_ZERO_ERROR;
icudt = read_file_to_string("data/icudt77l.dat");
udata_setCommonData((void *) icudt.data(), &uerr);
if (U_FAILURE(uerr)) {
char* errorName = const_cast<char*>(u_errorName(uerr));
std::cout << errorName << std::endl;
}
MainStruct* mSPtr = new MainStruct;
*appstate = (void*)mSPtr;
MainStruct& mS = *mSPtr;