[JS] Setting font of a textRange

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

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[i].textRange;
to:
textArtRange = app.activeDocument.textFrames[i].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

Similar Messages

  • Printing Problem with already set Font

    Post Author: tejas_kishanwala
    CA Forum: General
    hi,
    i have created a report using Crystal Report 9 with font Draft 10CPI using Printer EPSON FX-2175 on Windows XP with SP2.  after then when i call this report from my .NET Application (developed on VS 2005). the report is not showing as well printing with the already set Font (Draft 10CPI) Kindly do needful for the same. Tejas Kishanwala 

    Post Author: mewdied
    CA Forum: General
    Is the font Draft 10CPI a printer font?  If it is, you are running across a limitation of .NET not Crystal Reports.  .NET only supports True type and Open type fonts.  Microsoft has a KB about it, but I cannot find it right now.

  • Setting Font Color and Bold Property in ALV Grid

    I have a requirement to set the font in particular ALV Cells  in red color.
    Also this font (text) has to be set to Bold.
    I know how to set cell coloring in ALV Grid, but have no idea regarding how to set font color.
    Could please give me an idea/code segment/suggestion.
    Thank You!

    Please refer this post
    Coloring of ROWS in ALV tree

  • Can't set FONT in iCHAT

    When I try to hit SET FONT in iChat prefs, nothing happens.
    Fonts work in other apps.
    ?????

    I found it. DUH... the font window opened behind my prefs window.

  • [Solved] css setting font family, ff3 vs ie7

    In my css, I've set 'font-family: sans;' in body { }, and in ff3 on my Arch laptop, it displays correctlly. In ie7 on my wifes vista laptop, it still reverts back to w/e serif font it uses if it can't find one set by the web page. I have no idea why this is happening, and I can't seem to fix it. Can anyone give me a hand?
    Last edited by Sjoden (2009-01-04 03:07:09)

    Agh, well, I looked at thayer's blog to see if that worked in both browsers and it did, so I checked to see how he had his fonts set up.
    font-family: Arial, DejaVu Sans, sans-serif;
    The closest I got to that was 'font-family: Arial, DejaVu, sans;'

  • Setting font and color TextItems

    This script is failing to set font, and how can I set font color?; I am new to PS Scripting:
         var originalUnit = preferences.rulerUnits
          preferences.rulerUnits = Units.INCHES
         var docRef = app.documents.add( 11, 17, 300, "Test", NewDocumentMode.CMYK)
        MyLayer = docRef.artLayers.add()
         MyLayer.kind = LayerKind.TEXT
         var myFont = app.fonts.getByName("ArialMT");
         // Set the contents of the text layer.
         var textItemRef = MyLayer.textItem
         textItemRef.font = myFont;
         textItemRef.size = UnitValue(36, 'pt');
         textItemRef.font = '_Aviano-Regular';
         textItemRef.style = "Italic";
         textItemRef.contents = "Sample Text";
         // Restore original ruler unit setting
          app.preferences.rulerUnits = originalUnit
    Thanks

    The font needs to be the postscript name, this will give you a list of them.
    var Dlog =
    "dialog{text:'Script Interface',bounds:[100,100,500,270],"+
    "FontName:DropDownList{bounds:[30,40,370,60]},"+
    "PostScriptName:DropDownList{bounds:[30,100,370,120]},"+
    "statictext0:StaticText{bounds:[40,10,200,30] , text:'Font Name'},"+
    "statictext1:StaticText{bounds:[40,70,141,87] , text:'Postscript Name'},"+
    "button0:Button{bounds:[140,130,240,150] , text:'Ok' }}";
    win = new Window(Dlog,"Use the Postscript Name in your script.");
    var item;
    var item2;
    for (var i=0,len=app.fonts.length;i<len;i++) {
      item = win.FontName.add ('item', "" + app.fonts[i].name);
      item2 = win.PostScriptName.add ('item', "" + app.fonts[i].postScriptName);   
    win.FontName.selection = win.FontName.items[0] ;
    win.PostScriptName.selection = win.PostScriptName.items[0] ;
    win.FontName.onChange = function() {
    win.PostScriptName.selection = win.PostScriptName.items[parseInt(this.selection)] ;
    $.writeln(win.PostScriptName.items[parseInt(this.selection)]);
    win.PostScriptName.onChange = function() {
    win.FontName.selection = win.FontName.items[parseInt(this.selection)] ;
    win.center();
    win.show();
    Here is your code with colour addded...
         var originalUnit = preferences.rulerUnits
          preferences.rulerUnits = Units.INCHES
          var FillColor = new SolidColor;
        FillColor.rgb.hexValue = 'ff0000';
         var docRef = app.documents.add( 11, 17, 300, "Test", NewDocumentMode.CMYK)
        MyLayer = docRef.artLayers.add()
         MyLayer.kind = LayerKind.TEXT
         var myFont = "ArialMT";
         // Set the contents of the text layer.
         var textItemRef = MyLayer.textItem
         textItemRef.font = myFont;
         textItemRef.size = UnitValue(36, 'pt');
         textItemRef.font = myFont;
         //textItemRef.style = "Italic";
         textItemRef.fauxItalic = true;
         textItemRef.contents = "Sample Text";
         textItemRef.color = FillColor;
         // Restore original ruler unit setting
          app.preferences.rulerUnits = originalUnit

  • How do I set font default in aperture?

    how do I set font default in aperture?

    how do I set font default in aperture?
    Do you want to change the size of the fonts or the shape for the fonts in the user interface or in the products (books, webpages)?
    Aperture does not allow to change the fonts used in the graphical user interface, neither the size nor the shape. To change the fonts for the products (books, etc.), pick a theme with the fonts you like.
    Regards
    Léonie

  • Set font size for ChoiceGroup

    Hi,
    Is there any way to set font size of the String elements of ChoiceGroup

    Hi,
    Yes, there is, but only if you're using MIDP2.0.
    Check the API documentation of ChoiceGroup and see that there's a setFont(.., ..) method. The given index (int value) identifies the index of the element in the list for which the font will be set. This means that different elements in one choicegroup can have different fonts.
    Test it carefully, I've noticed that not all devices show correct behaviour on this. Also note that certain devices ignore certain font settings (for example italics, because a lot of native implementations won't have a font in italics).
    Good luck!

  • Set font on a text

    Hi!
    I've got some problem with setting font on a text, this is my coed:
    var ar_delaney_e:Font = new ar_delaney();
    textcount=1;
    //Setting a variable to     ar_delaney_e
    this["font_"+String(textcount)] = "ar_delaney_e";
    //Create a textFormat
    var textFormat:TextFormat = new TextFormat();
    //Setting font textformat fon to ar_delaney_e??
    textFormat.font = this["font_"+String(textcount)];
    //Set textformat to my text
    myText.defaultTextFormat = textFormat;
    Fon is embedded hav also tried textFormat.font = this["font_"+String(textcount)].fontName; instead of textFormat.font = this["font_"+String(textcount)]; but no one of this will work, how can you fix this?

    On stage I got a button with instance name add_text_btn, and a mc called "knapp_bild". So when pressing add_text_btn the function func_add_text_btn creates a movie clip with a text in it and also variables for size, color and font for the text. the two variables size and color works fine.
    add_text_btn.addEventListener(MouseEvent.CLICK, func_add_text_btn);
    function func_add_text_btn(event:MouseEvent):void{
    textcount++;
    var MovieClip:MovieClip = new MovieClip();
    MovieClip.x = 80;
    MovieClip.y = 60;
    MovieClip.alpha = 1;
    MovieClip.name="mc_text"+String(textcount);
    //Variables for font, size and color
    this["size_"+String(textcount)] = 40;
    this["color_"+String(textcount)] = "0x00CC00";
    this["font_"+String(textcount)] = "ar_delaney_e";
    textFormat.font = this["font_"+String(textcount)].fontName;
    textFormat.size = this["size_"+String(textcount)];
    textFormat.color = this["color_"+String(textcount)];
    var textField:TextField = new TextField()
    textField.defaultTextFormat = textFormat;
    textField.autoSize="left";
    textField.text = 'Text '+String(textcount);
    textField.name = "text"+String(textcount);  // give them names
    textField.background=false;
    textField.embedFonts=true;
    var mc_name=String("mc_text"+String(textcount));
    knapp_bild.addChild(MovieClip);
    MovieClip.addChild(textField);
    textField.mouseEnabled=false;
    MovieClip.width=textField.width;
    Later on in the program this["font_"+String(textcount)] will change but it dosen't work in the func_add_text_btn function now so let's just try to fix that first. Hope you can see something that mabe won't work and just ask if you got any qusetion. Thanks for your help!

  • How to set Font in JEditorPane

    i have problem set Font in JEditorPane.please help how to set Font in JEditorPane.
    My Code,
    JEditorPane view = new JEditorPane();
    view.setEditable(false);
    view.setContentType("text/html");
    JScrollPane scroll = new JScrollPane(view);
    scroll.setMinimumSize(new java.awt.Dimension(50, 50));
    scroll.setPreferredSize(new java.awt.Dimension(450, 300));
    scroll.setAutoscrolls(true);
    scroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    view.setBorder(null);
    view.setFont(new java.awt.Font("Monospaced", 0, 12));
    view.setDragEnabled(true);
    view.setMargin(new java.awt.Insets(10, 10, 10, 10));
    view.setMinimumSize(new java.awt.Dimension(100, 20));
    view.setPreferredSize(new java.awt.Dimension(450, 300));

    Have a look at SimpleAttributeSet.

  • Set Font globally in JavaFX

    How I can set the Font type globally in JavaFX application?
    Is there any solution which I can use? in JavaFX 8 the default Font is changed I would like to use the same Font used in JavaFX 2.2.
    Ref Set Font globally in JavaFX - Stack Overflow

    Add a stylesheet with the rule
    .root { -fx-font: 13 "Comic Sans MS"; }
    or whatever font size and family you want.
    You can also use an inline style on the root node, e.g.,
    Parent root = scene.getRoot();
    root.setStyle("-fx-font: 13 \"Comic Sans MS\"; ");

  • How to set font for title and message in JOptionPane?

    Hi,
    I have following test code.
    JOptionPane.showMessageDialog(null, "Some Alert Message", "Alert", JOptionPane.ERROR_MESSAGE);In this code can we set font for "Some Alert Message", "Alert"?
    Regards,
    Kalyani......

    roll-your-own?
    import javax.swing.*;
    class Testing
      public static void main(String[] args)
        JDialog.setDefaultLookAndFeelDecorated(true);
        JOptionPane optionPane = new JOptionPane("<html><font size='5'>Your message here</font></html>");
        optionPane.setOptionType(JOptionPane.DEFAULT_OPTION);
        optionPane.setMessageType(JOptionPane.ERROR_MESSAGE);
        JDialog dialog = optionPane.createDialog(null, "Alert");
        dialog.getLayeredPane().getComponent(1).setFont(dialog.getFont().deriveFont(18f));//size = 18/whatever
        dialog.setModal(true);
        dialog.setVisible(true);
    }

  • How to set font for  JOptionPane.showMessageDialog() ?

    Hi,
    I want to set font for JOptionPane.showMessageDialog(). I have tried with following but it did not worked.
    javax.swing.UIManager.put("JOptionPane.font", "Verdana"); Do any one have idea how to do this. Your suggestion would be helpfull to me.
    Thank you.

    Then you'll have to loop over the components in the JOptionPane and setFont for each JButton. My SwingUtils class (search the net using Darryl SwingUtils, I can't give you a link as it's blocked from my office) can make this easier.
    Sample code:import darrylbu.util.SwingUtils;
    import java.awt.Font;
    import javax.swing.*;
    import javax.swing.plaf.FontUIResource;
    public class OptionPaneFonts {
       public static void main(String[] args) {
          UIManager.put("OptionPane.messageFont", new FontUIResource(new Font(
                  "Verdana", Font.BOLD, 32)));
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new OptionPaneFonts().makeUI();
       public void makeUI() {
          JOptionPane pane = new JOptionPane("So it's a date?",
                  JOptionPane.QUESTION_MESSAGE,
                  JOptionPane.YES_NO_CANCEL_OPTION,
                  UIManager.getIcon("OptionPane.questionIcon"),
                  new String[]{"Okey-dokey", "Not on your life!",
                     "Let me think about it"
                  }, null);
          for (JButton button : SwingUtils.getDescendantsOfType(JButton.class, pane)) {
             button.setFont(new Font("Tahoma", Font.ITALIC, 18));
          JDialog dialog = new JDialog((JWindow) null);
          dialog.setModal(true);
          dialog.add(pane);
          dialog.pack();
          dialog.setLocationRelativeTo(null);
          dialog.setVisible(true);
    }db
    Edited by: DarrylBurke -- shortened the code

  • How do I re-set Font Book to factory settings?

    Hi everybody, hopefully you can help me...
    Just received my Refurbished iMac 21.5-Inch 2,7GHz Quad-Core Intel Core i5. Have loaded all my software, no problem. However, I stupidly and what on earth possessed me to do it I'll never know...dragged 11,000 fonts from an external back-up disk directly into font book late last night. It was verifying all the fonts and flagged up any potential corrupt fonts, I now don't seem to be able to even open Font book without it trying to locate all 11,000 fonts. Is there a way of deleting all of these fonts and doing it properly or re-setting Font book to it's original state. I can't access the preferences on startup as Font Book seems to want to find all the fonts first and i just get a whirly wheel in the bottom right hand corner...I've also tried to locate the fonts in 'library' etc but  they don't seem to be there which makes me wonder of Font Book is stuck in some kind of limbo...this is a monumental FAIL on my part I have to say.
    Any Ideas???
    Many Thanks
    Dave

    User fonts, those not require by the OS, are in two locations;
    Mac HD/Library/Fonts
    ~/Library/Fonts
    I would see if the 11M+ fonts are in ~/Library/Fonts first. If so drag them to the Trash and restart.

  • How to set Font to the ToolTip in JComboBox

    Hi,
    I am having problem in setting font to the ToolTip for JComboBox.
    Help needed asap...
    TIA,
    CK

    From the Mail menu bar click Mail > Preferences then select the Fonts & Colors tab.
    You can reset fonts sizes from there.
    Another way to open Mail Preferences, with Mail running, press Command ,  (comma) on your keyboard.
    The Mavericks upgrade may have reset that data to factory settings.

Maybe you are looking for