From 712ca351925273247b0a8226298d0bf3d5822f4d Mon Sep 17 00:00:00 2001 From: lumixraku Date: Wed, 16 Oct 2024 15:36:02 +0800 Subject: [PATCH] fix: no underline & strikeline when vertexangle is -90 --- .../src/components/docs/extensions/line.ts | 16 +++++++++++----- .../src/components/sheets/extensions/font.ts | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/engine-render/src/components/docs/extensions/line.ts b/packages/engine-render/src/components/docs/extensions/line.ts index f66c28b7512..ff89ed2a759 100644 --- a/packages/engine-render/src/components/docs/extensions/line.ts +++ b/packages/engine-render/src/components/docs/extensions/line.ts @@ -15,14 +15,14 @@ */ import type { IScale, ITextDecoration } from '@univerjs/core'; -import { BaselineOffset, BooleanNumber, getColorStyle, TextDecoration } from '@univerjs/core'; +import type { IDocumentSkeletonGlyph } from '../../../basics/i-document-skeleton-cached'; +import type { UniverRenderingContext } from '../../../context'; +import { BaselineOffset, BooleanNumber, getColorStyle, TextDecoration } from '@univerjs/core'; import { COLOR_BLACK_RGB, DEFAULT_OFFSET_SPACING, FIX_ONE_PIXEL_BLUR_OFFSET } from '../../../basics/const'; import { calculateRectRotate } from '../../../basics/draw'; -import type { IDocumentSkeletonGlyph } from '../../../basics/i-document-skeleton-cached'; import { degToRad, getScale } from '../../../basics/tools'; import { Vector2 } from '../../../basics/vector2'; -import type { UniverRenderingContext } from '../../../context'; import { DocumentsSpanAndLineExtensionRegistry } from '../../extension'; import { docExtension } from '../doc-extension'; @@ -39,6 +39,12 @@ export class Line extends docExtension { override draw(ctx: UniverRenderingContext, parentScale: IScale, glyph: IDocumentSkeletonGlyph) { const line = glyph.parent?.parent; + const { renderConfig } = this.extensionOffset; + // rotation of cell text + // rotate up down 90 cause problem, univer-pro/issues/2802, This is only a temporary solution + const vertexAngle = renderConfig?.vertexAngle || 0; + const centerAngle = renderConfig?.centerAngle || 0; + const drawStrikeAndUnderline = !(centerAngle === 0 && vertexAngle !== 0 && vertexAngle % 90 === 0); const { ts: textStyle, bBox, content } = glyph; if (line == null || textStyle == null || content === '\r') { @@ -51,7 +57,7 @@ export class Line extends docExtension { const DELTA = 0.5; const { ul: underline, st: strikethrough, ol: overline, va: baselineOffset, bbl: bottomBorderLine } = textStyle; - if (underline) { + if (drawStrikeAndUnderline && underline) { const startY = asc + dsc; this._drawLine(ctx, glyph, underline, startY, scale); } @@ -61,7 +67,7 @@ export class Line extends docExtension { this._drawLine(ctx, glyph, bottomBorderLine, startY, scale, 2); } - if (strikethrough) { + if (drawStrikeAndUnderline && strikethrough) { // strikethrough position is the middle of bounding box ascent and descent. let startY = asc + bd - strikeoutPosition - DELTA; diff --git a/packages/engine-render/src/components/sheets/extensions/font.ts b/packages/engine-render/src/components/sheets/extensions/font.ts index 239b74d2fd9..411fd67d506 100644 --- a/packages/engine-render/src/components/sheets/extensions/font.ts +++ b/packages/engine-render/src/components/sheets/extensions/font.ts @@ -327,7 +327,7 @@ export class Font extends SheetExtension { endX: number, endY: number, row: number, - column: number, + col: number, overflowCache: ObjectMatrix ) { const documents = this.getDocuments() as Documents; @@ -350,7 +350,7 @@ export class Font extends SheetExtension { // Use fix https://github.com/dream-num/univer/issues/927, Set the actual width of the content to the page width of the document, // so that the divide will be aligned when the skeleton is calculated. - const overflowRectangle = overflowCache.getValue(row, column); + const overflowRectangle = overflowCache.getValue(row, col); const isOverflow = !(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && vertexAngle === 0); if (isOverflow) {