feat:add letter spacing
This commit is contained in:
@@ -587,6 +587,9 @@ export class Draw {
|
|||||||
ctx.font = this._getFont(element)
|
ctx.font = this._getFont(element)
|
||||||
const fontMetrics = this.textParticle.measureText(ctx, element)
|
const fontMetrics = this.textParticle.measureText(ctx, element)
|
||||||
metrics.width = fontMetrics.width * scale
|
metrics.width = fontMetrics.width * scale
|
||||||
|
if (element.letterSpacing) {
|
||||||
|
metrics.width += element.letterSpacing * scale
|
||||||
|
}
|
||||||
metrics.boundingBoxAscent = (element.value === ZERO ? defaultSize : fontMetrics.actualBoundingBoxAscent) * scale
|
metrics.boundingBoxAscent = (element.value === ZERO ? defaultSize : fontMetrics.actualBoundingBoxAscent) * scale
|
||||||
metrics.boundingBoxDescent = fontMetrics.actualBoundingBoxDescent * scale
|
metrics.boundingBoxDescent = fontMetrics.actualBoundingBoxDescent * scale
|
||||||
if (element.type === ElementType.SUPERSCRIPT) {
|
if (element.type === ElementType.SUPERSCRIPT) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export interface IElementStyle {
|
|||||||
strikeout?: boolean;
|
strikeout?: boolean;
|
||||||
rowFlex?: RowFlex;
|
rowFlex?: RowFlex;
|
||||||
rowMargin?: number;
|
rowMargin?: number;
|
||||||
|
letterSpacing?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITableAttr {
|
export interface ITableAttr {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { deepClone, getUUID } from '.'
|
import { deepClone, getUUID } from '.'
|
||||||
import { ElementType, IEditorOption, IElement } from '..'
|
import { ElementType, IEditorOption, IElement } from '..'
|
||||||
|
import { defaultCheckboxOption } from '../dataset/constant/Checkbox'
|
||||||
import { ZERO } from '../dataset/constant/Common'
|
import { ZERO } from '../dataset/constant/Common'
|
||||||
import { defaultControlOption } from '../dataset/constant/Control'
|
import { defaultControlOption } from '../dataset/constant/Control'
|
||||||
import { EDITOR_ELEMENT_ZIP_ATTR } from '../dataset/constant/Element'
|
import { EDITOR_ELEMENT_ZIP_ATTR } from '../dataset/constant/Element'
|
||||||
@@ -123,10 +124,12 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
|
|||||||
const valueStrList = valueSet.value.split('')
|
const valueStrList = valueSet.value.split('')
|
||||||
for (let e = 0; e < valueStrList.length; e++) {
|
for (let e = 0; e < valueStrList.length; e++) {
|
||||||
const value = valueStrList[e]
|
const value = valueStrList[e]
|
||||||
|
const isLastLetter = e === valueStrList.length - 1
|
||||||
elementList.splice(i, 0, {
|
elementList.splice(i, 0, {
|
||||||
controlId,
|
controlId,
|
||||||
value,
|
value,
|
||||||
type: el.type,
|
type: el.type,
|
||||||
|
letterSpacing: isLastLetter ? defaultCheckboxOption.gap : 0,
|
||||||
control: el.control,
|
control: el.control,
|
||||||
controlComponent: ControlComponent.VALUE
|
controlComponent: ControlComponent.VALUE
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user