Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump crengine: text typography by language #1082

Merged
merged 1 commit into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ endif

# crengine, fetched via GIT as a submodule
$(CRENGINE_LIB): $(ZLIB) $(PNG_LIB) $(FREETYPE_LIB) $(HARFBUZZ_LIB) $(FRIBIDI_LIB) \
$(UTF8PROC_LIB) $(JPEG_LIB) $(NANOSVG_HEADERS) \
$(LIBUNIBREAK_LIB) $(UTF8PROC_LIB) $(JPEG_LIB) $(NANOSVG_HEADERS) \
$(CRENGINE_SRC_FILES) $(THIRDPARTY_DIR)/kpvcrlib/*.*
install -d $(CRENGINE_BUILD_DIR)
cd $(CRENGINE_BUILD_DIR) && \
Expand All @@ -186,6 +186,7 @@ $(CRENGINE_LIB): $(ZLIB) $(PNG_LIB) $(FREETYPE_LIB) $(HARFBUZZ_LIB) $(FRIBIDI_LI
FREETYPE_LIB="$(CURDIR)/$(FREETYPE_LIB)" \
HARFBUZZ_LIB="$(CURDIR)/$(HARFBUZZ_LIB)" \
FRIBIDI_LIB="$(CURDIR)/$(FRIBIDI_LIB)" \
LIBUNIBREAK_LIB="$(CURDIR)/$(LIBUNIBREAK_LIB)" \
UTF8PROC_LIB="$(CURDIR)/$(UTF8PROC_LIB)" \
ZLIB="$(CURDIR)/$(ZLIB)" \
LIBS_DIR="$(CURDIR)/$(OUTPUT_DIR)/libs" \
Expand All @@ -198,6 +199,7 @@ $(CRENGINE_LIB): $(ZLIB) $(PNG_LIB) $(FREETYPE_LIB) $(HARFBUZZ_LIB) $(FRIBIDI_LI
-DFREETYPE_INCLUDE_DIR="$(FREETYPE_DIR)/include/freetype2" \
-DHARFBUZZ_INCLUDE_DIR="$(HARFBUZZ_DIR)/include/harfbuzz" \
-DFRIBIDI_INCLUDE_DIR="$(FRIBIDI_DIR)/include" \
-DLIBUNIBREAK_INCLUDE_DIR="$(LIBUNIBREAK_DIR)/include" \
-DUTF8PROC_INCLUDE_DIR="$(UTF8PROC_DIR)" \
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
$(if $(WIN32),-DCMAKE_SYSTEM_NAME=Windows,) \
Expand Down
30 changes: 30 additions & 0 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,35 @@ static int setHyphDictionary(lua_State *L) {
return 0;
}

static int getTextLangStatus(lua_State *L) {
lua_pushstring(L, UnicodeToLocal(TextLangMan::getMainLang()).c_str());
lua_pushstring(L, UnicodeToLocal(TextLangMan::getMainLangHyphMethod()->getId()).c_str());
lua_newtable(L);
LVPtrVector<TextLangCfg> *list = TextLangMan::getLangCfgList();
for(int i = 0; i < list->length(); i++) {
TextLangCfg * lang_cfg = list->get(i);
// Key
lua_pushstring(L, UnicodeToLocal(lang_cfg->getLangTag()).c_str());
// Value: table
lua_newtable(L);

lua_pushstring(L, "hyph_dict_name");
lua_pushstring(L, UnicodeToLocal(lang_cfg->getDefaultHyphMethod()->getId()).c_str());
lua_settable(L, -3);

lua_pushstring(L, "hyph_nb_patterns");
lua_pushinteger(L, lang_cfg->getDefaultHyphMethod()->getCount());
lua_settable(L, -3);

lua_pushstring(L, "hyph_mem_size");
lua_pushinteger(L, lang_cfg->getDefaultHyphMethod()->getSize());
lua_settable(L, -3);

lua_settable(L, -3);
}
return 3;
}

static int loadDocument(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *file_name = luaL_checkstring(L, 2);
Expand Down Expand Up @@ -3284,6 +3313,7 @@ static const struct luaL_Reg cre_func[] = {
{"getHyphDictList", getHyphDictList},
{"getSelectedHyphDict", getSelectedHyphDict},
{"setHyphDictionary", setHyphDictionary},
{"getTextLangStatus", getTextLangStatus},
{"getLatestDomVersion", getLatestDomVersion},
{"getDomVersionWithNormalizedXPointers", getDomVersionWithNormalizedXPointers},
{"requestDomVersion", requestDomVersion},
Expand Down
11 changes: 9 additions & 2 deletions thirdparty/kpvcrlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(CREGINE_INCLUDE_DIR ${CRE_DIR}/include)
assert_var_defined(FREETYPE_INCLUDE_DIR)
assert_var_defined(HARFBUZZ_INCLUDE_DIR)
assert_var_defined(FRIBIDI_INCLUDE_DIR)
assert_var_defined(LIBUNIBREAK_INCLUDE_DIR)
assert_var_defined(UTF8PROC_INCLUDE_DIR)
assert_var_defined(JPEGLIB_INCLUDE_DIR)
assert_var_defined(PNG_INCLUDE_DIR)
Expand All @@ -34,6 +35,7 @@ include_directories(
${FREETYPE_INCLUDE_DIR}
${HARFBUZZ_INCLUDE_DIR}
${FRIBIDI_INCLUDE_DIR}
${LIBUNIBREAK_INCLUDE_DIR}
${UTF8PROC_INCLUDE_DIR}
${ANTIWORD_INCLUDE_DIR}
${CHM_INCLUDE_DIRS}
Expand All @@ -55,6 +57,7 @@ add_definitions(
-DUSE_FREETYPE=1
-DUSE_HARFBUZZ=1
-DUSE_FRIBIDI=1
-DUSE_LIBUNIBREAK=1
-DUSE_UTF8PROC=1
-DUSE_NANOSVG=1
-DALLOW_KERNING=1
Expand All @@ -78,9 +81,10 @@ if(DEFINED ENV{WIN32})
find_library(FREETYPE_LIB NAMES "freetype-6" PATHS $ENV{LIBS_DIR})
find_library(HARFBUZZ_LIB NAMES "harfbuzz-0" PATHS $ENV{LIBS_DIR})
find_library(FRIBIDI_LIB NAMES "fribidi-0" PATHS $ENV{LIBS_DIR})
find_library(LIBUNIBREAK_LIB NAMES "libunibreak-3" PATHS $ENV{LIBS_DIR})
find_library(UTF8PROC_LIB NAMES "utf8proc-2" PATHS $ENV{LIBS_DIR})
find_library(JPEG_LIB NAMES "jpeg-8" PATHS $ENV{LIBS_DIR})
set(THIRDPARTY_LIBS ${ZLIB} ${FREETYPE_LIB} ${HARFBUZZ_LIB} ${FRIBIDI_LIB} ${UTF8PROC_LIB} ${JPEG_LIB} ${PNG_LIB})
set(THIRDPARTY_LIBS ${ZLIB} ${FREETYPE_LIB} ${HARFBUZZ_LIB} ${FRIBIDI_LIB} ${LIBUNIBREAK_LIB} ${UTF8PROC_LIB} ${JPEG_LIB} ${PNG_LIB})
else()
add_library(PNG_LIB SHARED IMPORTED)
set_target_properties(PNG_LIB PROPERTIES IMPORTED_LOCATION $ENV{PNG_LIB})
Expand All @@ -90,13 +94,15 @@ else()
set_target_properties(HARFBUZZ_LIB PROPERTIES IMPORTED_LOCATION $ENV{HARFBUZZ_LIB})
add_library(FRIBIDI_LIB SHARED IMPORTED)
set_target_properties(FRIBIDI_LIB PROPERTIES IMPORTED_LOCATION $ENV{FRIBIDI_LIB})
add_library(LIBUNIBREAK_LIB SHARED IMPORTED)
set_target_properties(LIBUNIBREAK_LIB PROPERTIES IMPORTED_LOCATION $ENV{LIBUNIBREAK_LIB})
add_library(UTF8PROC_LIB SHARED IMPORTED)
set_target_properties(UTF8PROC_LIB PROPERTIES IMPORTED_LOCATION $ENV{UTF8PROC_LIB})
add_library(JPEG_LIB SHARED IMPORTED)
set_target_properties(JPEG_LIB PROPERTIES IMPORTED_LOCATION $ENV{JPEG_LIB})
add_library(ZLIB SHARED IMPORTED)
set_target_properties(ZLIB PROPERTIES IMPORTED_LOCATION $ENV{ZLIB})
set(THIRDPARTY_LIBS ZLIB FREETYPE_LIB HARFBUZZ_LIB FRIBIDI_LIB UTF8PROC_LIB JPEG_LIB PNG_LIB)
set(THIRDPARTY_LIBS ZLIB FREETYPE_LIB HARFBUZZ_LIB FRIBIDI_LIB LIBUNIBREAK_LIB UTF8PROC_LIB JPEG_LIB PNG_LIB)
endif()

message("Will build LIBCHM library")
Expand Down Expand Up @@ -141,6 +147,7 @@ set (CRENGINE_SOURCES
${CRE_DIR}/src/lvbmpbuf.cpp
${CRE_DIR}/src/lvfnt.cpp
${CRE_DIR}/src/hyphman.cpp
${CRE_DIR}/src/textlang.cpp
${CRE_DIR}/src/lvfntman.cpp
${CRE_DIR}/src/lvimg.cpp
${CRE_DIR}/src/crskin.cpp
Expand Down