Skip to content

Commit

Permalink
Incorrect display of utf8 text in standalone #889 (#947)
Browse files Browse the repository at this point in the history
* added own-built freetype; removed cairo-wasm

* returned freetype CMakeLists.txt to the original state

* fixed freetype building

* added sans fonts files

* added rendere_font_face_manager; support of external fonts

* added utf8 tests to indigo-ketcher

* clang-format fix for sans fonts files

* clang-format fix for font_face_manager files

* fixed build for non UNIX builds

* clang_format fix

* fixed freetype build

* selected FreeType License (FTL) as used license

* selected FreeType License (FTL) as used license

* moved sans fonts files; added OFL license file

* fixed build and CMakeFiles
  • Loading branch information
IvanMinin authored and Mikalai Sukhikh committed Jan 17, 2023
1 parent 5b9c8ea commit d46c595
Show file tree
Hide file tree
Showing 1,074 changed files with 520,393 additions and 138,593 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option(WITH_STATIC "Build Indigo static library as well as shared" OFF)

# Indigo API options
option(BUILD_INDIGO "Build indigo shared library" ON)
option(USE_FONT_MANAGER "Build indigo render with font_face_manager" OFF)

# Indigo API Wrappers options
option(BUILD_INDIGO_WRAPPERS "Build all existing Indigo API wrappers" ON)
Expand Down Expand Up @@ -82,6 +83,7 @@ if (EMSCRIPTEN)
set(BUILD_BINGO_SQLSERVER OFF)
set(BUILD_BINGO_ORACLE OFF)
set(BUILD_BINGO_ELASTIC OFF)
set(USE_FONT_MANAGER ON)
endif()

if (BUILD_INDIGO OR BUILD_INDIGO_UTILS OR BUILD_BINGO_SQLSERVER OR BUILD_BINGO_ORACLE OR BUILD_BINGO_POSTGRES OR EMSCRIPTEN)
Expand Down
6 changes: 5 additions & 1 deletion api/wasm/indigo-ketcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ add_custom_target(${PROJECT_NAME}
-o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/indigo-ketcher.js
${EMCC_FLAGS}
$<TARGET_OBJECTS:${PROJECT_NAME}-object>
$<TARGET_FILE:indigo-static> $<TARGET_FILE:indigo-inchi-static> $<TARGET_FILE:indigo-renderer-static> $<TARGET_FILE:render2d> $<TARGET_FILE:cairo> $<TARGET_FILE:png> $<TARGET_FILE:pixman> $<TARGET_FILE:indigo-core> $<TARGET_FILE:inchi> $<TARGET_FILE:tinyxml2> $<TARGET_FILE:z>
$<TARGET_FILE:indigo-static> $<TARGET_FILE:indigo-inchi-static> $<TARGET_FILE:indigo-renderer-static> $<TARGET_FILE:render2d> $<TARGET_FILE:cairo> $<TARGET_FILE:freetype> $<TARGET_FILE:png> $<TARGET_FILE:pixman> $<TARGET_FILE:indigo-core> $<TARGET_FILE:inchi> $<TARGET_FILE:tinyxml2> $<TARGET_FILE:z>
DEPENDS ${PROJECT_NAME}-object
)

add_custom_target(${PROJECT_NAME}-test
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test.js ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test64.cdx ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test64.ket ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/utf8_ref.svg ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/utf8_ref.png ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test_symbols_4_styles_2_sizes.ket ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/
COMMAND npm install looks-same
COMMAND node test
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
DEPENDS ${PROJECT_NAME}
Expand Down
3 changes: 3 additions & 0 deletions api/wasm/indigo-ketcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"homepage": "https://lifescience.opensource.epam.com/indigo/api/index.html",
"scripts": {
"test": "node test.js"
},
"dependencies": {
"looks-same": "^8.1.0"
}
}
25 changes: 25 additions & 0 deletions api/wasm/indigo-ketcher/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const indigoModuleFn = require('./indigo-ketcher.js')
const assert = require('assert').strict;
const looksSame = require('looks-same');

// Extremely simple test framework, thanks to @sohamkamari (https://github.com/sohamkamani/nodejs-test-without-library)
let tests = []
Expand Down Expand Up @@ -547,6 +548,30 @@ M END
assert(pdf.indexOf("%PDF-") !== -1);
options.delete();
});

test("render", "uf8_svg", async () => {
let options = new indigo.MapStringString();
options.set("render-output-format", "svg");
var fs = require('fs');
const ket_data = fs.readFileSync("test_symbols_4_styles_2_sizes.ket");
const svg = Buffer.from(indigo.render(ket_data, options), "base64");
fs.writeFileSync("utf8_out.svg",svg);
const {equal} = await looksSame('utf8_ref.svg', 'utf8_out.svg');
assert(equal);
options.delete();
});

test("render", "uf8_png", async () => {
let options = new indigo.MapStringString();
options.set("render-output-format", "png");
var fs = require('fs');
const ket_data = fs.readFileSync("test_symbols_4_styles_2_sizes.ket");
const png = Buffer.from(indigo.render(ket_data, options), "base64");
fs.writeFileSync("utf8_out.png", png);
const {equal} = await looksSame('utf8_ref.png', 'utf8_out.png');
assert(equal);
options.delete();
});
}

// Throws
Expand Down
39 changes: 39 additions & 0 deletions api/wasm/indigo-ketcher/test_symbols_4_styles_2_sizes.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"root": {
"nodes": [
{
"type": "text",
"data": {
"content": "{\"blocks\":[{\"key\":\"8fkt2\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}},{\"key\":\"essc0\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"BOLD\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"98n58\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"ITALIC\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"1ii9e\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"BOLD\"},{\"offset\":0,\"length\":6,\"style\":\"ITALIC\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"2ujgl\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"CUSTOM_FONT_SIZE_26px\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"3qu9p\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"BOLD\"},{\"offset\":0,\"length\":6,\"style\":\"CUSTOM_FONT_SIZE_26px\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"4tqut\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"ITALIC\"},{\"offset\":0,\"length\":6,\"style\":\"CUSTOM_FONT_SIZE_26px\"}],\"entityRanges\":[],\"data\":{}},{\"key\":\"906p1\",\"text\":\"олζθπ∑\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[{\"offset\":0,\"length\":6,\"style\":\"BOLD\"},{\"offset\":0,\"length\":6,\"style\":\"ITALIC\"},{\"offset\":0,\"length\":6,\"style\":\"CUSTOM_FONT_SIZE_26px\"}],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}",
"position": {
"x": 13.9,
"y": -8.275,
"z": 0
},
"pos": [
{
"x": 13.9,
"y": -8.275,
"z": 0
},
{
"x": 13.9,
"y": -12.414999103546144,
"z": 0
},
{
"x": 16.312544059753417,
"y": -12.414999103546144,
"z": 0
},
{
"x": 16.312544059753417,
"y": -8.275,
"z": 0
}
]
}
}
]
}
}
Binary file added api/wasm/indigo-ketcher/utf8_ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d46c595

Please sign in to comment.