Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: punctuation adjustment issues in slide (#1690)

Ran Luo15cb6df4f022
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/line-adjustment.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/line-adjustment.ts
index df2cb09630..33b89f1753 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/line-adjustment.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/line-adjustment.ts
@@ -208,8 +208,13 @@ function restoreLastCJKGlyphWidth(line: IDocumentSkeletonLine) {
// Compression of punctuation marks at line start or line end
function shrinkStartAndEndCJKPunctuation(line: IDocumentSkeletonLine) {
for (const divide of line.divides) {
+ const glyphGroupLength = divide.glyphGroup.length;
+ if (glyphGroupLength < 2) {
+ continue;
+ }
+
const firstGlyph = divide.glyphGroup[0];
- const lastGlyph = divide.glyphGroup[divide.glyphGroup.length - 1];
+ const lastGlyph = divide.glyphGroup[glyphGroupLength - 1];
if (isCjkRightAlignedPunctuation(firstGlyph.content)) {
const shrinkAmount = firstGlyph.adjustability.shrinkability[0];