How to measure/scale text to fit the desired width?

I would like to measure the width of one or more words (not a paragraph) when rendering with a given font and the font size. Let's say I have the following code creates a new document, layer, and text:

var myDoc = app.documents.add(200, 200);


var textLayer = myDoc.artLayers.add();
textLayer.kind = LayerKind.TEXT;

var text = textLayer.textItem;
text.font = "Impact";
text.size = 72;
text.position = Array(100,100);
text.contents = "SUPER";

I want to measure the width of text .

In the end, I want to resize the text to be a certain width while maintaining its proportions. (The height of the text is not important, than just the width and it should not be distorted). Knowing the width I could easily calculate the correct font size. If there is a better way to this solution to measure the width, please let me know.

Thank you!

The layer has a property "terminals", you can calculate the width.

var width = textLayer.bounds [2] - textLayer.bounds [0];

Tags: Photoshop

Similar Questions

  • I downloaded a game on the internet, and now my screen does not match my screen. I have two large black areas on each side of my screen. How to resize my screen to fit the screen of my computer? (and yes I tried the button expand) :))

    I have two large black areas on each side of my screen. How to resize my screen to fit the screen of my computer? (and yes I tried the button expand) :))

    Hello val2000, welcome.

    These games is managed inside of Internet Explorer? If this isn't the case, then I suggest contacting the manufacturer of your computer for the latest pgrahics drivers. If installation of those who does not resolve the problem, then try to change your resolution to one of the following values (depending on the size of your screen):

    1024 x 768
    1280 x 800 (wide, common form for laptops)
    1280 x 1024
    1680 x 1050 (widescreen)

    To change your resolution:

    1. click on START
    2. click on "Control Panel."
    3. double click on "display".
    4. click on the tab "settings".
    5. change the resolution on your cursor tab and then click on 'Apply' at the bottom right

    Let us know what happens

    Thank you! Ryan Thieman
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to listen to TEXT messages in the air?

    How to listen to TEXT messages in the air? Thank you!

    There is not much available of BB10 exposed to the AIR. If the NDK allows you create a DONKEY for her.

  • How to set a text index in the Data Modeler

    Hello

    How to set a text index (indextype is ctxsys.context) in data maker?

    The SQL command would be:

    create index P1_TEXT_BESCHR_SPRACHE on indextype P1_PDM_MODUL_SPRACHE (DESCRIPTION) is ctxsys.context
    parameters ("lexer global_lexer language format column FORMAT STORAGE PDMSTORE")
    Online
    /


    Thanks in advance for any help.

    Monika

    Hi Monika,

    After you create the relational model, you create a physical. In the physical model there is dialog box properties index, where you can set the properties of context index.

  • How can I transfer text frames of the legend of the Slide Master view to view the film?

    I am a new user of Captivate.

    I created my own master slides. Many of them have blocks of text. My intention was to have the text frames appear whenever I have created a new slide in the Filmstrip view. Instead, I see just the text that I wrote (Insert text "here") in the background. I can't click and change the text in the view of the Film Strip.

    Could someone help me please? How can I make my text in the view of master frames appear as blocks of text whenever I create a new slide in the Filmstrip mode?

    Thank you.

    Levi

    If you want to "text frames", where the text can be changed in the view of the Film Strip, you must insert placeholders on the master slide. You probably insert text captions.

    Anthony

  • How to add a text box to the pdf format, so that others can fill

    How can I insert text in PDF nightclubs as well as others can fill it when it is sent to them?

    Hi susansln123,

    Refer to this KB document for help Acrobat help. Forms.

    Kind regards
    Nicos

  • How to create an oval and thicken the line width?

    I need to create the half oval, but I can't seem to make the width of the line thicker? As you can see on the properties box on the right, where it says details of form, I can't click the color or type to change the line width. Why is this?

    Thank you.

    Screen Shot 2016-01-23 at 1.49.20 PM.png

    Using the tool to create a path in place using change drop down menu shape mode for fill and stroke, the color of your choice and the desired thickness.

  • I use CS6 and I try to make the text field and the identical width text boxes and so that they fill up my spine. Windows in Design mode, I can't find styles to the table styles in the cell of the styles I have unerstand where I am doing the changes

    Sorry for the typing error in "understanding." Please notify

    You're doing a

    ?

    You can style form field input and textarea with CSS code to make them the same width.

    Nancy O.

  • How to export a text file of the web activity and the security report for the family of weekly so I can see ALL the text?

    When I go through online activities, I get a lot of items truncated with... on the ends of phrases. I want to see the range of sentence or text. How can I get this done?

    Hi ColdBlueNorth,

    The features that you are curious about are currently not available in Family Safety. If you think that it would be practical to have options, you can send it to Microsoft who appreciates your comments and considers that the suggestion of a future versions. Please apply for these feature on our feedback page.

    Comments page

    If you have any questions, feel free to post here in the Microsoft Community.

    Thank you.

  • When I use the delete key, it does not delete anything, instead, he types a period. How can I remove text by using the delete key?

    When I hit the button Delete, all I get is a period. Does not, delete just leave behind it a period. How to delete using the delete key, without the period?

    Hello

     
    1 What is the problem occurs with a specific program?
    2. What is the brand and model of the keyboard?
     
    You must select the text you want to delete and press on "remove". "."

    Answer us with more information so that we can better help you.

    Thank you.
  • InDesign: how tilt blocks of text without distorting the text?

    I want to put in place several large blocks of copy to these requirements:

    -the basic lines of the text are at an angle on the page

    -the left and right edges of the text block are shot-on horizontal (aligned with the guides in the screenshot below)

    -the block of text can be enlarged or reduced without changing the angle of the left and right edges

    -forms of the letters themselves are not distorted

    Skew1.gif

    This screenshot shows what I'm after.

    Skew2.gif

    This screenshot shows the real bounding box for the text block.

    Skew3.gif

    This screenshot shows how the angle of the text box changes when I change its size.

    I think Illustrator is a kind of function that allows you to "zero" (reset the transformations of a grid of 90 degrees) an object after it is transformed. Not finding anything like that in InDesign. And I find no way to set a custom angle constraint that would allow me to use the direct Selection (white arrow) tool to change the height or width with confidence.

    I'd appreciate some tips! Thank you for your attention.

    I do so with the example of shooting. Tilt works the same way.

    1. draw your rectangle, I applied a text frame reference grid (textframe options)

    2. with the Selection tool or the transform tool turn the frame in one direction, you can also do this with the entrance of the value in the transform Panel, what I would recommend.

    3. now, select the direct Selection (white arrow) tool and hold the ALT key and click on the frame. Now, only the frame is selected. Turn the other way, or insert the value in the transform Panel.

    I also have another method to offer:

    1. Draw the main frame with the text tool.
    2. Draw a small box above, it must be much smaller than the main frame.
    3. Turn the small frame in the direction that where you want to go the text.
    4. Select the two images.
    5. Go to the Pathfinder > Add.

    Now, you can add text or select a text based frame reference grid. He will do the same as above. May be simpler.

  • How to make a text box in the scroll bar custom FlashCC HTML5 Canvas?

    Hello

    I need to make a scroll for a long text box bar. I wonder how can I achieve this with HTML5 canvas in Flash CC2014?

    Thank you

    Rodrigo

    No, the code is exactly the same except instead of changing the property y of a textfield object, you change the property y of a movieclip (which contains an image of the text your want to display).

  • How to make a text entry for the user to type the name in?

    I do a game in which the user can type in their name, and later in the game, it will say something like:

    "Oh, Kaitlyn, how was your day? But what I really know how to do is make sure the name will be, but NOT all in a sentence in fact. The problem with this is the spacing and punctuation. I tried following a tutorial that gave me this to put in the ActionScript for the output area:

    output_txt. Text = "Hello" + myText + "!";

    Here is the tutorial:

    http://www.danfergusdesign.com/classfiles/oldClasses/VCB331-richMedia1/exercises/inputOutp utText.php

    I think it's because it's for as3 that it doesn't, but I'm kinda new to Flash and it does not seem too difficult. Please give very descriptive instructions.

    What you show will work in AS2 and AS3.  Do you have assigned an instance name textfield (it indicates 'output_txt' in your example)?  Instance names are assigned by selecting the object on the stage and entering the name in the properties panel.

    You must store the name that the user enters in a variable.  This can be done in two different ways.  Do you have something in place for that?

  • How to make readable text fields after the filling of data

    Hello

    Once we get the data in the message text entry fields, we have a few only readable areas.
    I tried to make these fields as readable as follows:

    In the property inspector Table RN, I changed the functional property of 'Read' only True value
    But in the custom OAF page, text box is missing for this field.
    Could someone help me how to do this?

    Thanks in advance
    Nanoo

    Hi Nanoo

    Here's the modified code, you can use

    public void setReadonly()
    {
    XXIDVOImpl vo=getXXVO1();
    Row poRow = vo.first();
    for(int i=0;i
    

    I hope that helps!

    Thank you
    AJ

  • How to create link text instead of the link button

    Hi all

    How to create a link text like "click here" to a page in the application instead of a button link in the form page

    near an element (text field)...

    can we also carry the values of some of the elements form page to the link page which is also a form... ?


    Thanks in advance.

    set the label as <-a href="http://url/">click here<->. Then buld up of your URL using replace values IE

    / pls/apex/f? p = V('APP_ID'):0:V('APP_SESSION'):APPLICATION_PROCESS = MY_PROCESS:NO:P1NAME, P2NAME, P3NAME:P1VALUE, P2VALUE, P3VALUE

    concerning

Maybe you are looking for

  • Yahoo search in Safari engine even if Google is selected

    Safari uses the Yahoo search engine in spite of the fact that Google is selected in the preferences. It is a problem a couple of years and the solutions were incredibly complex and one I don't know they would be still applicable. OS X is El Capitan 1

  • E-mail of 7 years has disappeared

    After having been missing for two weeks, with the iMAC closes. I turned on Mac and I get the message "mail quit unexpectedly.  After learning how to correct this, (from the apple community), I discovered that I have had no e-mail in the mailbox excep

  • HP Pavilion Elite HPE-400Y no video output.

    Hello I have a HP Pavilion Elite HPE-400Y computer that I had stored (unplugged) in a bedroom closet bedroom for almost a year.  It was working fine when I put it in storage. This past weekend, I wanted to use, so I plugged in and connected to an ana

  • Sypris Teslameter Driver_too early to convert version of labview 8.5

    I'm new to the labview program (8.5) and try to use it to run my setup. I have connected the Teslameter/Gaussmeter (FW Bell Sypris 6010) to the computer via the serial port and cable RS-232 and used the driver (of the company) for this type of device

  • Windows Update crashes when installing patches

    Hello I have a problem with Windows Update on my computer Windows Vista 25 Nov. November 25, Windows Update told me of new updates and I chose the option to install the fix and the stop in the night and the system has been blocked to install update 3