Agamnentzar / ag-psd

Javascript library for reading and writing PSD files
Other
489 stars 66 forks source link

When writing to a psd file, how to create regional text, I used the following method, but it had no effect. Please help me, thank you very much #181

Closed automan-bot closed 3 months ago

automan-bot commented 3 months ago

Here's part of the source code for my project, I used shapeType, boxBounds to create the area text, but the resulting psd was still line text

let fontSize = object.fontSize * scaleY;
let boxWidth = object.width * scaleX;
let boxHeight = object.height * scaleY;
if (boxHeight / fontSize > 1.5) {
      return {
        name "Text Layer",
        opacity: object.opacity * 255,
        text: {
          text: object.text, 
          transform: [1, 0, 0, 1, left, top + fontSize],
          style: {
            font: { name: getPsFontfamily(object.fontFamily) }, 
            fontSize: fontSize,
            fauxBold: getFontWeightIsBlod(object.fontWeight),
            fillColor: convertColorToRGB(object.fill), // opaque red
            shapeType: "box",
            boxBounds: [0, 0, boxWidth, boxHeight],
          },
        },
        hidden: !object.visible,
      };
}
automan-bot commented 3 months ago

Expected results: 想要的效果

Current Results: 目前的结果

Agamnentzar commented 3 months ago

@automan-bot did you manage to resolve it or you closed the issue accidentally?