MCPcopy Create free account
hub / github.com/Tencent/libpag / MergeClusters

Function MergeClusters

src/platform/web/NativeTextShaper.cpp:62–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62static void MergeClusters(std::vector<Info>& infos) {
63 auto groupEnd = [&](size_t start) -> size_t {
64 while (++start < infos.size() && infos[start].isContinuation)
65 ;
66 return start;
67 };
68
69 for (size_t count = infos.size(), start = 0, end = count ? groupEnd(0) : 0; start < count;
70 start = end, end = groupEnd(start)) {
71 if (end - start < 2) {
72 continue;
73 }
74
75 auto cluster = infos[start].cluster;
76
77 for (size_t i = start + 1; i < end; i++) {
78 cluster = std::min(cluster, infos[i].cluster);
79 }
80
81 /* Extend end */
82 while (end < infos.size() && infos[end - 1].cluster == infos[end].cluster) {
83 end++;
84 }
85
86 /* Extend start */
87 while (0 < start && infos[start - 1].cluster == infos[start].cluster) {
88 start--;
89 }
90
91 for (auto i = start; i < end; i++) {
92 infos[i].cluster = cluster;
93 }
94 }
95}
96
97std::vector<ShapedGlyph> NativeTextShaper::Shape(const std::string& text,
98 std::shared_ptr<tgfx::Typeface> typeface) {

Callers 1

ShapeMethod · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected