0
[JS] Setting font of a textRange
New Here
,
/t5/illustrator-discussions/js-setting-font-of-a-textrange/td-p/1158280
Aug 27, 2008
Aug 27, 2008
Copy link to clipboard
Copied
Hi
In Ai CS3, I am trying to set the font of an entire textFrame, using this type of syntax:
newFrame.textRange.characterAttributes.textFont.family = "Arial";
Either using 'family' or 'name', this produces no result whatsoever.
Anyone willing to shed light on me - why?
Cheerz,
Art
In Ai CS3, I am trying to set the font of an entire textFrame, using this type of syntax:
newFrame.textRange.characterAttributes.textFont.family = "Arial";
Either using 'family' or 'name', this produces no result whatsoever.
Anyone willing to shed light on me - why?
Cheerz,
Art
TOPICS
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explore related tutorials & articles
Community Expert
,
/t5/illustrator-discussions/js-setting-font-of-a-textrange/m-p/1158281#M238599
Aug 28, 2008
Aug 28, 2008
Copy link to clipboard
Copied
characterAttributes is Read Only according to the JS Reference.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
moniuch
AUTHOR
New Here
,
/t5/illustrator-discussions/js-setting-font-of-a-textrange/m-p/1158282#M238600
Aug 28, 2008
Aug 28, 2008
Copy link to clipboard
Copied
Hm...
If so, then what is the trick to set a font of a frame or a text range?
I have also tried a looped statement like this:
newFrame.textRange.character.characterAttributes.textFont.family = "Arial";
This produces no result either. :(
Artur
If so, then what is the trick to set a font of a frame or a text range?
I have also tried a looped statement like this:
newFrame.textRange.character.characterAttributes.textFont.family = "Arial";
This produces no result either. :(
Artur
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/illustrator-discussions/js-setting-font-of-a-textrange/m-p/1158283#M238601
Aug 28, 2008
Aug 28, 2008
Copy link to clipboard
Copied
See the example given in the textFont object section of the CS3 Javascript Reference. Copy that script and run it. Then, change:
textArtRange = app.activeDocument.textFrames.textRange;
to:
textArtRange = app.activeDocument.textFrames.characters[0];
and run it again.
Then change:
textArtRange.characterAttributes.textFont = app.textFonts[0];
to:
textArtRange.characterAttributes.textFont = app.textFonts.getByName("Verdana");
and run it again.
You cannot always trust the name that is displayed in AI's font menu as the actual name of the font. For example, on my machine, the font listed as "Arial" is actually named "ArialMT".
JET
textArtRange = app.activeDocument.textFrames.textRange;
to:
textArtRange = app.activeDocument.textFrames.characters[0];
and run it again.
Then change:
textArtRange.characterAttributes.textFont = app.textFonts[0];
to:
textArtRange.characterAttributes.textFont = app.textFonts.getByName("Verdana");
and run it again.
You cannot always trust the name that is displayed in AI's font menu as the actual name of the font. For example, on my machine, the font listed as "Arial" is actually named "ArialMT".
JET
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
moniuch
AUTHOR
New Here
,
LATEST
/t5/illustrator-discussions/js-setting-font-of-a-textrange/m-p/1158284#M238602
Aug 29, 2008
Aug 29, 2008
Copy link to clipboard
Copied
Noooow you got me working :)
Thank you. Indeed, the font names got fancy sometimes.
Thank you. Indeed, the font names got fancy sometimes.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

