Skip to content

Commit

Permalink
Introduce new API grapheme_line_segmenter to replace scan API
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <christian@parpart.family>
  • Loading branch information
christianparpart committed Mar 5, 2024
1 parent 943bb41 commit a97b51e
Show file tree
Hide file tree
Showing 12 changed files with 1,666 additions and 24 deletions.
9 changes: 4 additions & 5 deletions src/libunicode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,18 @@ add_library(unicode ${LIBUNICODE_LIB_MODE}
)

if(LIBUNICODE_USE_STD_SIMD)
target_compile_definitions(unicode PRIVATE LIBUNICODE_USE_STD_SIMD)
target_compile_definitions(unicode PUBLIC LIBUNICODE_USE_STD_SIMD)
endif()
if(LIBUNICODE_USE_INTRINSICS)
target_compile_definitions(unicode PRIVATE USE_INTRINSICS)
target_compile_definitions(unicode PUBLIC LIBUNICODE_USE_INTRINSICS)
endif()

set(public_headers
capi.h
codepoint_properties.h
convert.h
emoji_segmenter.h
grapheme_line_segmenter.h
grapheme_segmenter.h
intrinsics.h
multistage_table_view.h
Expand Down Expand Up @@ -161,7 +162,6 @@ add_executable(unicode_tablegen tablegen.cpp)
set_target_properties(unicode_tablegen PROPERTIES CMAKE_BUILD_TYPE Release)
target_link_libraries(unicode_tablegen PRIVATE unicode::loader)


# {{{ installation
set(LIBUNICODE_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/libunicode" CACHE PATH "Installation directory for cmake files, a relative path that will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")
set(LIBUNICODE_INSTALL_CMAKE_FILES ${MASTER_PROJECT} CACHE BOOL "Decides whether or not to install CMake config and -version files.")
Expand Down Expand Up @@ -220,6 +220,7 @@ if(LIBUNICODE_TESTING)
capi_test.cpp
convert_test.cpp
emoji_segmenter_test.cpp
grapheme_line_segmenter_test.cpp
grapheme_segmenter_test.cpp
run_segmenter_test.cpp
scan_test.cpp
Expand Down Expand Up @@ -247,8 +248,6 @@ if(LIBUNICODE_TESTING)
endif()
# }}}



# {{{ unicode_test
if(LIBUNICODE_BENCHMARK)
if(NOT benchmark_FOUND)
Expand Down
4 changes: 2 additions & 2 deletions src/libunicode/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
while (segmenter.codepointsAvailable())
{
auto const cluster = *segmenter;
int thisWidth = unicode::width(cluster.front());
int thisWidth = static_cast<int>(unicode::width(cluster.front()));
if (mode != GC_WIDTH_MODE_NON_MODIFIABLE)
{
for (size_t i = 1; i < size; ++i)
Expand All @@ -60,7 +60,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
{
case 0xFE0E: return 1;
case 0xFE0F: return 2;
default: return unicode::width(codepoint);
default: return static_cast<int>(unicode::width(codepoint));
}
}();
if (width && width != thisWidth)
Expand Down
Loading

0 comments on commit a97b51e

Please sign in to comment.