Skip to main content
Known Participant
May 26, 2020
Question

Paragraph text not wrapping with higher DPI (javascript)

  • May 26, 2020
  • 1 reply
  • 1570 views

I have a weird problem in Javascript with Paragraph text. My script creates text layers for labels and needs the text to fit the document width. For font attributes it uses a template text layer which is copied, changed to paragraph text, width and height set to document size and contents text set. This works as expected with DPI set to 72 which corresponds to 1 pixel= 1 pt . The ruler units are pixels.

 

If now I resize the image to 300 DPI, not reampling (i.e. page size changes, not pixel count) this does not work anymore. The template text layer is correctly scaled from roughly 69pt down to 16.56 pt (Unitvalues do correctly reflect the change to 300DPI in the baseUnit, thus conversion correct). When width and height of the text item are set to the document width and height they are automatically correctly scaled from 350ox to 84pt (as text item always uses pt). But when a text which would require 2 lines is assigned it flows out of the document on one single line.

 

So far I have checked a lot of things like nmoBreak set to false, useAutoLeading to true, autoLeadingAount=120% (i.e. nm problem to fit 2 16pt lines into 84pt). I did also try to force leading to fix value with nmo change in behavior. Once the same document is in 72pt again, the same script works as expected.

 

Am I missing something here, or is this a bug?

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
May 26, 2020

Do you really expect meaningful feedback without providing the Script and the layered file? 

So far we don’t even know if the Type Layer is Point Text or Paragraph Text. 

Known Participant
May 26, 2020

Yes, actually I do 😉 Providing the script is not possible because it is a very complex one with over 2000 lines of code. In rteturn I did provide all steps the script does. Also, and here sorry to say, reading helps, I mentioned 3 times that this is of course paragraph text, where one of the 3 does explicitely state that I change the textItem to paragraph text.


Below is the code extract as well as the bogous text with 300DPI. The same text in same size will render as expected on 2 lines with 72DPI.


Notes:

  • Document is 350x350px 300DPI
  • 72DPI & 69pt text all works fine, 300DPI 16.56pt(scaled) text not
  • textLayer is an object of my own layer class and textLayer.Layer is the ArtLayer
  • lt.Duplicate duplkicates the template text layer. Parameters do only impact naming and positioning in Layer tree
  • The template text layer has no special settings, only color & font size. I used fixed and auto leading, both working fine with 72DPI, and failing with 300DPI

 

  var textLayer=lt.Duplicate(layer,ElementPlacement.PLACEBEFORE,"Label","none");

  // Now set the text attributes
  var ti=textLayer.Layer.textItem;
  ti.kind=TextType.PARAGRAPHTEXT;
  ti.width=doc.width;
  ti.height=doc.height;

  ti.contents=label;
Known Participant
May 26, 2020

Or post screenshots where we can see the Transform Controls of the type layer in the two resulting files. 


Thanks, got it, and attached files to original post.

 

Both files had the same initial state except for the image resolution (72 or 300DPI) and processed by the exact same script with same options (while options actually do not impact text creation). The created layers are visible in both files, once formatted as expected /72DPI) and once single line (300DPI).