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

Changing the "text" property of a text object reverts the font_size to 8

I've got some code that creates a text object above a token on the objects layer.I want this text to act as a timer that counts up while it is that player's turn. The issue i'm having is that when I change the "text" property of the text object the font size goes from 64 down to 8, making the text tiny. I tried setting the font_size explicitly but that doesn't work either. I can't think of any way to work around this other than deleting the object and creating a new one. Please help! Code below: var token = getObj("graphic", tokenId); if (token){ var top = token.get('top'); var left = token.get('left'); var height = token.get('height'); var obj = createObj("text", { _pageid: Campaign().get("playerpageid"), layer: "objects", top: top-height, left: left, text: "00:00", font_size: 64 }); var timeout = setTimeout(function(){ obj.set('text', "11:11"); // Also doesn't work //obj.set({text: "11:11", font_size: 64, width: 100}); }, 500); }
1429301529

Edited 1429301694
I just solved this. This happens if the font_family is not set during object creation. Adding: font_family: "Arial", fixed it. Kind of un-obvious behavior, I updated the wiki entry for the Text Object to indicate this behavior. <a href="https://wiki.roll20.net/API:Objects#Text" rel="nofollow">https://wiki.roll20.net/API:Objects#Text</a> font_family "unset" See values in text editing menu. If this is not set, when later changing the value of the "text" property the font_size will shrink to 8.
Great, thanks!