types: add ITextMetrics interface
This commit is contained in:
@@ -2,6 +2,7 @@ import { ElementType, IEditorOption, IElement } from '../../..'
|
||||
import { PUNCTUATION_LIST } from '../../../dataset/constant/Common'
|
||||
import { DeepRequired } from '../../../interface/Common'
|
||||
import { IRowElement } from '../../../interface/Row'
|
||||
import { ITextMetrics } from '../../../interface/Text'
|
||||
import { Draw } from '../Draw'
|
||||
|
||||
export interface IMeasureWordResult {
|
||||
@@ -70,7 +71,7 @@ export class TextParticle {
|
||||
public measureText(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
element: IElement
|
||||
): TextMetrics {
|
||||
): ITextMetrics {
|
||||
// 优先使用自定义字宽设置
|
||||
if (element.width) {
|
||||
const textMetrics = ctx.measureText(element.value)
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { TextDecorationStyle } from '../dataset/enum/Text'
|
||||
|
||||
export interface ITextMetrics {
|
||||
width: number
|
||||
actualBoundingBoxAscent: number
|
||||
actualBoundingBoxDescent: number
|
||||
actualBoundingBoxLeft: number
|
||||
actualBoundingBoxRight: number
|
||||
fontBoundingBoxAscent: number
|
||||
fontBoundingBoxDescent: number
|
||||
}
|
||||
|
||||
export interface ITextDecoration {
|
||||
style?: TextDecorationStyle
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user