Calculating Textarea Height from textsize

  1. 3 months ago

    I would like to design my textarea around the size, around the size of the font?
    I'm not sure what to call the space above and below of the text in a textarea except for padding.
    I also assume Textfield and area are the same. Also, I don't know if textunit (points versus pixels) has anything to do with the calculation.
    The LR is confusing on this part.

    Is there a formula from XOJO for knowing what that padding space is?
    I would also like to know to know how to set this up for cross-platform (points versus pixels), So How to do that?

    It appears that if I have a 30 point size, I will have a padding of 10. It could be 1/3 in addition to the size, because when I change the font size to 60 it seems to be about 20 points

    Best you can hope for is to split into "lines"
    Then get the text height * lines
    But there will be a slight difference because you may get leading, kerning and other typesetting adjustments in a text area that will vary from one typeface to another that the text area uses that you dont have a decent way to account for

    Even using a picture & its graphics area to measure will be different because graphics dont use typesetting functions to measure so you will get these differences

    IF you're trying to do "typesetting" you need to use much lower level functions via declares on whatever OS to get at the leading, interline spacing, kerning metrics etc

  2. Emile S

    Jul 16 Europe (France, Strasbourg)

    @Arthur G I also assume Textfield and area are the same.

    False. If it was the case, why bother present two times the same Control ?

    @Arthur G cross-platform (points versus pixels),

    point vs pixel: not related to platform.

    @Arthur G padding

    I do not know what the word “padding” relates to a word processor (or even a TextArea).

    Did you read:
    http://developer.xojo.com/home
    http://www.xojo.com/learn/index.php

    These are good readings.

  3. Edited 3 months ago by Norman P

    Emile. If you can refer to a page that would be much better.

    Currently I use a calculation very similar to the one here http://forums.realsoftware.com/viewtopic.php?f=21&t=40675 for graphics. If you add text to either field you get white space on top and bottom of the text. This varies depending on the font. Even though the font is at say 20 points, it doesn't appear as 20 points and the white space varies.

    EDIT : NJP cleaned up URL tags as they are not needed

  4. Norman P

    Jul 16 Xojo Inc Answer
    Edited 3 months ago by Norman P

    Best you can hope for is to split into "lines"
    Then get the text height * lines
    But there will be a slight difference because you may get leading, kerning and other typesetting adjustments in a text area that will vary from one typeface to another that the text area uses that you dont have a decent way to account for

    Even using a picture & its graphics area to measure will be different because graphics dont use typesetting functions to measure so you will get these differences

    IF you're trying to do "typesetting" you need to use much lower level functions via declares on whatever OS to get at the leading, interline spacing, kerning metrics etc

  5. Thank you. I was hoping XOJO did a calculation, but I guess not. I'll keep using the known without going into declares. I'd like typesetting but not that much

  6. Edited 3 months ago by Arthur G

    I did find the term. It is leading (as in bedding).
    There is a page for XOJO, http://docs.xojo.com/index.php/TextArea . and then a subpage for linespacing
    As I stated above this isn't exactly what I wanted since this is inter-line and in a textarea.
    It also doesn't define what a 1 in between lines is. One page I saw states http://practicaltypography.com/line-spacing.html is 120% to 140%

or Sign Up to reply!