Search ICU data on Windows relative to the current module.
Bug: n/a Change-Id: If2fc09f6fc0a24915b4938c62451c693a9712586 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311136 Commit-Queue: Derek Sollenberger <djsollen@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Heather Miller <hcm@google.com> Reviewed-by: Jim Sproch <jsproch@google.com>
This commit is contained in:
parent
3dc0da6c6d
commit
7e9b563179
1
AUTHORS
1
AUTHORS
@ -66,3 +66,4 @@ Yong-Hwan Baek <meisterdevhwan@gmail.com>
|
||||
Alexander Khovansky <alx.khovansky@gmail.com>
|
||||
Zhuo Qingliang <zhuo.dev@gmail.com>
|
||||
Mainframe North <*@mainframe.co.uk>
|
||||
JetBrains <*@jetbrains.com>
|
||||
|
28
third_party/icu/SkLoadICU.cpp
vendored
28
third_party/icu/SkLoadICU.cpp
vendored
@ -68,6 +68,16 @@ static bool init_icu(void* addr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::string library_directory() {
|
||||
HMODULE hModule = NULL;
|
||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
||||
reinterpret_cast<LPCSTR>(&library_directory), &hModule);
|
||||
char path[MAX_PATH];
|
||||
GetModuleFileNameA(hModule, path, MAX_PATH);
|
||||
const char* end = strrchr(path, '\\');
|
||||
return end ? std::string(path, end - path) : std::string();
|
||||
}
|
||||
|
||||
static std::string executable_directory() {
|
||||
HMODULE hModule = GetModuleHandleA(NULL);
|
||||
char path[MAX_PATH];
|
||||
@ -76,17 +86,21 @@ static std::string executable_directory() {
|
||||
return end ? std::string(path, end - path) : std::string();
|
||||
}
|
||||
|
||||
static bool load_from(const std::string& dir) {
|
||||
auto sPath = dir + "\\icudtl.dat";
|
||||
if (void* addr = win_mmap(sPath.c_str())) {
|
||||
if (init_icu(addr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkLoadICU() {
|
||||
static bool good = false;
|
||||
static std::once_flag flag;
|
||||
std::call_once(flag, []() {
|
||||
std::string sPath = executable_directory();
|
||||
sPath += "\\icudtl.dat";
|
||||
if (void* addr = win_mmap(sPath.c_str())) {
|
||||
if (init_icu(addr)) {
|
||||
good = true;
|
||||
}
|
||||
}
|
||||
good = load_from(executable_directory()) || load_from(library_directory());
|
||||
});
|
||||
return good;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user