Skip to content

Commit

Permalink
fix(render-engine): punctuation render error in sheet cell (#2034)
Browse files Browse the repository at this point in the history
* fix: punctuation render error in sheet cell

* fix: punctuation render error in sheet cell

* fix: only add the first glyph xOffset
  • Loading branch information
Jocs committed Apr 24, 2024
1 parent 9b0e8d9 commit d7ddad1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/engine-render/src/basics/draw.ts
Expand Up @@ -252,6 +252,7 @@ export function getRotateOrientation(angle: number) {
}

// rotate calculate logic https://www.processon.com/view/link/630df928f346fb0714c9c4ec
// eslint-disable-next-line max-lines-per-function
export function getRotateOffsetAndFarthestHypotenuse(
lines: IDocumentSkeletonLine[],
rectWidth: number,
Expand Down
1 change: 1 addition & 0 deletions packages/engine-render/src/components/docs/document.ts
Expand Up @@ -461,6 +461,7 @@ export class Documents extends DocComponent {
alignOffset
);


const extensionOffset: IExtensionConfig = {
originTranslate,
spanStartPoint,
Expand Down
13 changes: 10 additions & 3 deletions packages/engine-render/src/components/docs/layout/tools.ts
Expand Up @@ -345,11 +345,18 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =
maxLineAsc = Math.max(maxLineAsc, ba);

if (i === divideLength - 1) {
// When the width is set to Infinity, the last divide should also be Infinity, and an actual width needs to be calculated.
actualWidth += glyph.width;
}
}

// When the width is set to Infinity, the last divide should also be Infinity, and an actual width needs to be calculated.
// Use to fix issue: https://github.com/dream-num/univer/issues/2002
// Because the Chinese punctuation marks at the beginning and end of the line are squeezed and narrowed,
// the extruded width needs to be added when calculating the overall width.
if (glyphGroup[0].xOffset !== 0 && i === divideLength - 1) {
actualWidth -= glyphGroup[0].xOffset;
}

if (i === divideLength - 1) {
// if (divide.width === Infinity) {
// divide.width = actualWidth;
Expand Down Expand Up @@ -477,7 +484,7 @@ export function columnIterator(
}
}

// eslint-disable-next-line max-lines-per-function

export function getPositionHorizon(
positionH: ObjectPositionH,
column: IDocumentSkeletonColumn,
Expand Down Expand Up @@ -572,7 +579,7 @@ export function getPositionHorizon(
}
}

// eslint-disable-next-line complexity

export function getPositionVertical(
positionV: ObjectPositionV,
page: IDocumentSkeletonPage,
Expand Down
Expand Up @@ -270,6 +270,7 @@ export class Font extends SheetExtension {
const overflowRectangle = overflowCache.getValue(row, column);
if (!(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && vertexAngle === 0)) {
const contentSize = getDocsSkeletonPageSize(documentSkeleton);

const documentStyle = documentSkeleton.getViewModel().getDataModel().getSnapshot().documentStyle;
if (contentSize && documentStyle) {
const { width } = contentSize;
Expand Down

0 comments on commit d7ddad1

Please sign in to comment.