Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Text Objects change font size when moved with API

1679762335

Edited 1679763721
Pat
Pro
API Scripter
I'm the creator of EmojiBubble in the one-click library, and I was working on an update to the Mod, scaling it up or offering a scaling factor to make the emoji and associated bubbles larger for folks that found the originals too small, and eventually offering scaling of the bubbles for short text messages instead.  This is when I discovered the following:  This is the image of a size 24 created text object using Arial (it has the most emoji support) before it is moved.  The way the EmojiBubble script works, the bubble and emoji follow the token as it moves, maintaining the offset to appear to follow the token. So the bubble (an SVG/line object) and the text (a text object) are moved through object reference and accessing the API.  When it moves, it is very noticeable when it is large -  This is the size it reverts to after it is moved programmatically (presumably now font size 8, the default font size) If I double-click inside the text object to edit it...  it will briefly revert to the set font size when it was created.  It appears that the font size is inconsistent in persistence with a text object created through the API, and I'm not sure why.  let textObj = createObj('text', { pageid: token.get("pageid"), left: x + offsets.textoffsetx, top: y + offsets.textoffsety, width: multiplier * basicmeasure, //30, height: multiplier * basicmeasure, //30, font_size: Math.round(multiplier * 12), //12, layer:"objects", text: emojibuilder(emoji) }); The movement code is simply this:  textObj.set({ left: x + offsets.textoffsetx, top: y + offsets.textoffsety }); It is acting like the place that the font is set on initializing isn't actually being *set*, so I'm going to try doing a second *set* for the font size prior to move, or after creation, and see if that works, but it still points to a weakness in API created text objects over UI created text objects.  Yep, if I re-set the font_size every single time I set any other attributes, I can get it to behave the way it should, but if I open the text object for editing, it *acts* like the size is what I set it to, but the default font size that shows up (as it does when you double-click inside a text object) is still 8, and if I click out without editing, the font scales back to 8 instead of staying at the size it was set at programmatically.
1679765909
Gauss
Forum Champion
Hi Pat, I suggest filing a bug report with the Devs via the Help Center as the forums are primarily for users helping users. 
Hi Pat, I was running into the same issue as you. The following post helped me resolve this with a workaround. <a href="https://app.roll20.net/forum/post/1845393/changing-the-text-property-of-a-text-object-reverts-the-font-size-to-8/?pageforid=1845413#post-1845413" rel="nofollow">https://app.roll20.net/forum/post/1845393/changing-the-text-property-of-a-text-object-reverts-the-font-size-to-8/?pageforid=1845413#post-1845413</a>
1682949524
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
substitoad said: Hi Pat, I was running into the same issue as you. The following post helped me resolve this with a workaround. <a href="https://app.roll20.net/forum/post/1845393/changing-the-text-property-of-a-text-object-reverts-the-font-size-to-8/?pageforid=1845413#post-1845413" rel="nofollow">https://app.roll20.net/forum/post/1845393/changing-the-text-property-of-a-text-object-reverts-the-font-size-to-8/?pageforid=1845413#post-1845413</a> Good lord that's an old solution!
1683480257
Pat
Pro
API Scripter
Wow, thanks substitoad! I guess I did not dig around nearly far back enough... agreed, keithcurtis, that is a really old solution!&nbsp;