From bd6c7589f001a8095e2786cb6ba553b39612c38a Mon Sep 17 00:00:00 2001 From: xxss0903 <353768356@qq.com> Date: Fri, 11 Oct 2024 22:24:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E7=9A=84=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/liteofd/elements/TextSvg.ts | 100 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/liteofd/elements/TextSvg.ts b/src/liteofd/elements/TextSvg.ts index 6339459..3592660 100644 --- a/src/liteofd/elements/TextSvg.ts +++ b/src/liteofd/elements/TextSvg.ts @@ -77,20 +77,20 @@ export class TextSvg extends BaseSvg { // 去掉publicres中关于字体的粗细的值的显示,只使用字体文件中的字体渲染 // 添加字体粗细 - // let fontWeight = parser.findAttributeValueByKey(findedFont, AttributeKey.Weight) - // if (fontWeight) { - // this.textStyle += `font-weight: ${fontWeight};` - // } - // let fontBold = parser.findAttributeValueByKey(findedFont, AttributeKey.Bold) - // if (fontBold) { - // this.textStyle += `font-weight: bold;` - // } - // // 添加字体斜体 - // let fontItalic = parser.findAttributeValueByKey(findedFont, AttributeKey.Italic) - // console.log("font italic:", fontID, findedFont, fontItalic, node) - // if (fontItalic) { - // this.textStyle += `font-style: italic;` - // } + let fontWeight = parser.findAttributeValueByKey(findedFont, AttributeKey.Weight) + if (fontWeight) { + this.textStyle += `font-weight: ${fontWeight};` + } + let fontBold = parser.findAttributeValueByKey(findedFont, AttributeKey.Bold) + if (fontBold) { + this.textStyle += `font-weight: bold;` + } + // 添加字体斜体 + let fontItalic = parser.findAttributeValueByKey(findedFont, AttributeKey.Italic) + console.log("font italic:", fontID, findedFont, fontItalic, node) + if (fontItalic) { + this.textStyle += `font-style: italic;` + } } } } @@ -113,18 +113,18 @@ export class TextSvg extends BaseSvg { this.textStyle += `font-weight: ${fontWeight};` } // 添加字体颜色 - // this.#addFillColor(nodeData) - // // 添加stroke颜色 - // this.#addStrokeColor(nodeData) + this.#addFillColor(nodeData) + // 添加stroke颜色 + this.#addStrokeColor(nodeData) // stroke宽度 - // let lineWidth = parser.findAttributeValueByKey(nodeData, AttributeKey.LineWidth) - // if (lineWidth) { - // let lineWidthValue = parseFloat(lineWidth) - // this.textStyle += `stroke-width: ${convertToDpi(lineWidthValue)}px;` - // } else { - // this.textStyle += `stroke-width: 0;` - // } + let lineWidth = parser.findAttributeValueByKey(nodeData, AttributeKey.LineWidth) + if (lineWidth) { + let lineWidthValue = parseFloat(lineWidth) + this.textStyle += `stroke-width: ${convertToDpi(lineWidthValue)}px;` + } else { + this.textStyle += `stroke-width: 0;` + } } @@ -202,31 +202,31 @@ export class TextSvg extends BaseSvg { // 字体文件中暂时去掉drawParam的渲染 #addDrawParam(nodeData: XmlData) { - // let drawParamID = parser.findAttributeValueByKey(nodeData, AttributeKey.DrawParam) - // console.log("add text draw params", drawParamID) - // if (drawParamID) { - // let drawParamNode = parser.findNodeByAttributeKeyValue(drawParamID, AttributeKey.ID, this.ofdDocument.publicRes) - // if (drawParamNode) { - // // 填充颜色 - // this.#addFillColor(drawParamNode) - // // 添加线宽度和线条颜色 - // this.#addStrokeColor(drawParamNode) - // console.log("textsvg drawParamNode", drawParamNode) - // // 添加字体粗细 - // let fontWeight = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Weight) - // if (fontWeight) { - // this.textStyle += `font-weight: ${fontWeight};` - // } - // let fontBold = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Bold) - // if (fontBold) { - // this.textStyle += `font-weight: bold;` - // } - // // 添加字体斜体 - // let fontItalic = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Italic) - // if (fontItalic) { - // this.textStyle += `font-style: italic;` - // } - // } - // } + let drawParamID = parser.findAttributeValueByKey(nodeData, AttributeKey.DrawParam) + console.log("add text draw params", drawParamID) + if (drawParamID) { + let drawParamNode = parser.findNodeByAttributeKeyValue(drawParamID, AttributeKey.ID, this.ofdDocument.publicRes) + if (drawParamNode) { + // 填充颜色 + this.#addFillColor(drawParamNode) + // 添加线宽度和线条颜色 + this.#addStrokeColor(drawParamNode) + console.log("textsvg drawParamNode", drawParamNode) + // 添加字体粗细 + let fontWeight = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Weight) + if (fontWeight) { + this.textStyle += `font-weight: ${fontWeight};` + } + let fontBold = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Bold) + if (fontBold) { + this.textStyle += `font-weight: bold;` + } + // 添加字体斜体 + let fontItalic = parser.findAttributeValueByKey(drawParamNode, AttributeKey.Italic) + if (fontItalic) { + this.textStyle += `font-style: italic;` + } + } + } } }