Skip to main content
Participating Frequently
August 1, 2016
Answered

Why won't my script resize the font to size 13?

  • August 1, 2016
  • 1 reply
  • 1546 views

I have JavaScript code that is supposed to change the font size for all text boxes. I want to resize the font to size 13. The text boxes range from size 4.76 to size 10.49. Right now, the script only changes them to size 12 or 14 (or anything that isn't 13).

  1. var myDocument = app.activeDocument; 
  2.  
  3.  
  4. var tfs = myDocument.textFrames; 
  5. var n = tfs.length; 
  6.  
  7.  
  8. for ( i = 0 ; i < n ; i++ ) { 
  9.           tfs.textRange.characterAttributes.textFont = app.textFonts.getByName("BebasNeue");  
  10.           tfs.textRange.characterAttributes.size = 13; //nothing happens during this stage unless I change 13 to 14 

Thanks in advance for any help.

This topic has been closed for replies.
Correct answer Silly-V

Weird indeed! By the way, how do you import the XML files into your pie charts? Is there one chart per document, or multiple ones?

Well, can you try to set their font to be another font, and set  ​that​ to 13 and then change back to Bebas?

1 reply

Silly-V
Brainiac
August 1, 2016

I wonder what's going on, because this does work for me- except I do not have this font.

aliceellAuthor
Participating Frequently
August 2, 2016

Wow, weird. You're right. It works with every font other than Bebas Neue...

Maybe this will help. Background: all the text boxes are attached to pie charts, which have been made into variables. I update the variables routinely by importing an XML file (which updates the data in the pie charts). Whenever I import the XML, though, the font size changes to 10.9. Even though the document's default font is set to Bebas Neue 13 pt.

So I then manually ungroup everything in the document, which turns the variables into text boxes that I can call with this script.

Silly-V
Brainiac
August 3, 2016

Thanks for the reply. When I run it, I get a pop-up window saying Lost Items: The current import contains 2 missing Graphs. Proceed?

When I click yes, it tells me "Your variable data has been imported. It contains 2 variables and 2 records. 2 Missing Graph(s)"

I have 1 layer with 2 pie charts. The layer is called Graph, the two charts that I want to update are pie1 and pie2. My dataset (that I posted earlier) is on my desktop, along with the two CSVs for the pie charts. The CSVs are called pie1.csv and pie2.csv. pie1.csv looks like this:

78.3,13.3,3.9,2.1,0.4,1.1,0.2,0.6

Hope that makes sense.


Okay great, I'm replying to your PM regarding this. I am afraid the user-base for graphers in Illustrator, especially ones who use the XML files has got to be one of the most niche subcultures in the world, so it's great to be able to conference on this obscure feature!