2018-02-08 18:06:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#ifndef load_icu_DEFINED
|
|
|
|
#define load_icu_DEFINED
|
|
|
|
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
|
|
|
2019-02-06 02:28:24 +00:00
|
|
|
#include "../private/SkLeanWindows.h"
|
2018-02-08 18:06:56 +00:00
|
|
|
|
2019-02-06 02:28:24 +00:00
|
|
|
#include "unicode/uvernum.h"
|
|
|
|
#include "unicode/udata.h"
|
2019-01-25 17:50:35 +00:00
|
|
|
|
2019-02-06 02:28:24 +00:00
|
|
|
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
|
|
|
|
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
|
|
|
|
|
|
|
|
inline void SkLoadICU() {
|
|
|
|
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
|
|
|
|
if (!module) {
|
|
|
|
SK_ABORT("Failed to load " ICU_UTIL_DATA_SHARED_MODULE_NAME "\n");
|
|
|
|
}
|
|
|
|
FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
|
|
|
|
if (!addr) {
|
|
|
|
SK_ABORT("Symbol " ICU_UTIL_DATA_SYMBOL " missing in "
|
|
|
|
ICU_UTIL_DATA_SHARED_MODULE_NAME ".\n");
|
|
|
|
}
|
|
|
|
UErrorCode err = U_ZERO_ERROR;
|
|
|
|
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
|
|
|
|
if (err != U_ZERO_ERROR) {
|
|
|
|
SkDebugf("udata_setCommonData() returned %d.\n", (int)err);
|
|
|
|
SK_ABORT("");
|
|
|
|
}
|
|
|
|
udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
|
|
|
|
if (err != U_ZERO_ERROR) {
|
|
|
|
SkDebugf("udata_setFileAccess() returned %d.\n", (int)err);
|
|
|
|
SK_ABORT("");
|
|
|
|
}
|
2019-01-25 17:50:35 +00:00
|
|
|
}
|
2018-02-08 18:06:56 +00:00
|
|
|
|
2019-02-06 02:28:24 +00:00
|
|
|
#undef ICU_UTIL_DATA_SHARED_MODULE_NAME
|
|
|
|
#undef ICU_UTIL_DATA_SYMBOL
|
|
|
|
|
2018-02-08 18:06:56 +00:00
|
|
|
#else
|
|
|
|
inline void SkLoadICU() {}
|
|
|
|
#endif // SK_BUILD_FOR_WIN
|
|
|
|
#endif // load_icu_DEFINED
|
|
|
|
|