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 <[email protected]>
  • Loading branch information
christianparpart committed Mar 1, 2024
1 parent 9c62ac5 commit 3f32345
Show file tree
Hide file tree
Showing 10 changed files with 1,590 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/libunicode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ add_library(unicode ${LIBUNICODE_LIB_MODE}
capi.cpp
codepoint_properties.cpp
emoji_segmenter.cpp
grapheme_line_segmenter.cpp
grapheme_segmenter.cpp
scan.cpp
script_segmenter.cpp
Expand All @@ -125,6 +126,7 @@ set(public_headers
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 @@ -219,6 +221,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
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 3f32345

Please sign in to comment.