basiljs/basil.js

typo() return value

Opened this issue · 3 comments

trych commented

Working on adding text placement for shapes, I just realized that I find the return functionality of the typo() function really odd.

If I use it as a getter and try to get the point size of a text frame's text for example, it returns an array of the point size of each paragraph in the text frame.

I find it really random that a paragraph is the unit that gets checked. I wonder how this is helpful to anyone (unless you specifically want to find out point size of each paragraph) and I wonder, if it would make sense to return just the point size that is considered the point size of the text frame's text:

textFrame.texts[0].pointSize

So as to always just have one value returned.

Opinions?

And what happens when there is a textFrame with mixed sizes? Shouldn't it just work for characters?

trych commented

Well, in the current version, what happens if there are paragraphs with mixed text sizes? That's just as incorrect.

Shouldn't it just work for characters?

What do you mean? That it only returns something for characters?

trych commented

Decision was made now, that we only return the value that InDesign would return as well (which is the value of the first insertion point, I suppose). That scenario works for many use cases (getting values of words retrieved by words() etc.), improves other scenarios (getting values of a story does not return a somewhat meaningless array of values) and should considerably improve performance.