Skip to content

Commit 3f32345

Browse files
Introduce new API grapheme_line_segmenter to replace scan API
Signed-off-by: Christian Parpart <[email protected]>
1 parent 9c62ac5 commit 3f32345

10 files changed

+1590
-16
lines changed

src/libunicode/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ add_library(unicode ${LIBUNICODE_LIB_MODE}
101101
capi.cpp
102102
codepoint_properties.cpp
103103
emoji_segmenter.cpp
104+
grapheme_line_segmenter.cpp
104105
grapheme_segmenter.cpp
105106
scan.cpp
106107
script_segmenter.cpp
@@ -125,6 +126,7 @@ set(public_headers
125126
codepoint_properties.h
126127
convert.h
127128
emoji_segmenter.h
129+
grapheme_line_segmenter.h
128130
grapheme_segmenter.h
129131
intrinsics.h
130132
multistage_table_view.h
@@ -219,6 +221,7 @@ if(LIBUNICODE_TESTING)
219221
capi_test.cpp
220222
convert_test.cpp
221223
emoji_segmenter_test.cpp
224+
grapheme_line_segmenter_test.cpp
222225
grapheme_segmenter_test.cpp
223226
run_segmenter_test.cpp
224227
scan_test.cpp

src/libunicode/capi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
4949
while (segmenter.codepointsAvailable())
5050
{
5151
auto const cluster = *segmenter;
52-
int thisWidth = unicode::width(cluster.front());
52+
int thisWidth = static_cast<int>(unicode::width(cluster.front()));
5353
if (mode != GC_WIDTH_MODE_NON_MODIFIABLE)
5454
{
5555
for (size_t i = 1; i < size; ++i)
@@ -60,7 +60,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
6060
{
6161
case 0xFE0E: return 1;
6262
case 0xFE0F: return 2;
63-
default: return unicode::width(codepoint);
63+
default: return static_cast<int>(unicode::width(codepoint));
6464
}
6565
}();
6666
if (width && width != thisWidth)

0 commit comments

Comments
 (0)