Skip navigation
Currently Being Moderated

How can I control the line spacing in TLF

Feb 19, 2010 7:49 AM

Hello,

 

Is it possible to control the line spacing in TLF?

For example I might have text lines with font size of 12 (i.e. constant text height) but I would like to be able to change the space between the lines programatically.

Playing with the lineHeight property is not the best approach because in case there are images embedded in the text once lineHeight is set then the image is cut if it is higher than the line height. I really need to control the space between lines but not the lines' height.

 

Thanks

 
Replies
  • Currently Being Moderated
    Feb 19, 2010 10:52 AM   in reply to smirnoff81

    LineHeight an be set as a percentage of fontSize, for example, lineHeight="120%".  The height of an InlineGraphicElement is treated as its fontSize.

     

    Richard

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 19, 2010 4:22 PM   in reply to smirnoff81

    The lineHeight is the maximum of all the lineHeights of the LeafElements on the line.  So you could set your lineHeights for each span to be 12 point and the lineHeight of the InlineGraphicElements to the first multiple of 12 greater than the height.

     

    Is that the effect you are trying to achieve?

     

    Richard

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 22, 2010 10:08 AM   in reply to smirnoff81

    You can specify lineHeight in pixels instead of percentages - lineHeight="12" versus lineHeight="120%"

     

    If you want each line to be exactly the same height - as if the lines were falling on a grid, you can specify a pixel lineHeight with the default leadingModel. In this case we set each line's baseline that many pixels from the last line's baseline. In this case larger type or larger inlines may not fit, so you have to specify a pixel height that's appropriate for the content.

     

    Or if you want lines with larger content to automatically be larger, but the gap between the lines to be constant, then you can choose the ASCENT_DESCENT_UP leadingModel and a pixel lineHeight. In this case lineHeight is the distance between one line's descenders and the next line's ascenders. I think that's what you're asking for.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2010 8:37 AM   in reply to smirnoff81

    I think it's a bug. While graphics don't actually have ascent and descent measures, I think it's reasonable to take the image top and bottom edges for those measures in places where we need them.

     

    Unfortunately I don't think this is a bug that will be fixed for our 1.0 release, so you'll need to work around the problem until we can get a fix in. In another thread I suggested adding a thin space before or after the graphic with an appropriate fontSize.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2010 12:26 PM   in reply to smirnoff81

    I've logged a bug in our internal bug database.

     

    The problem is that graphics don't have ascent or descent values, so my workaround is to add a character that does:

     

    1. Add a space after the graphic

    2. Change the fontSize of the height of the graphic

      (you may need to fiddle with fontSize a bit to get the look you want)

    3. Change trackingRight of the space to it's apparent width

     

    This gives you an "invisible" space that forces TLF to give the graphic enough line height in this situation.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 25, 2010 7:06 AM   in reply to smirnoff81

    We haven't yet decided how we are going to open our bug database to the public, so I unfortunately do not have a bug number that's useful to you.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 27, 2011 12:51 AM   in reply to smirnoff81

    hi, all, i see this prolem in my project now. when set leadingModel ASCENT_DESCENT_UP,  and a constant pixel lineHeight, if insert a image, the text will be mixed up.

     

    i want to know if the newest textlayout framework have fixed this problem? or any solution? thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 28, 2011 1:41 AM   in reply to ShuShenghong

    Box leading model was introduced to solve this particular use case.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 9, 2012 6:27 AM   in reply to Alan Stearns

    hello,

     

    I have a question for line spacing. I'm using TLF and when the text continues to the next line it just starts to overlap the previous one unless I hit return a couple more times. This makes pasting text impossible because when I past it, the text pastes on top of each other as if a book had thrown up. I'm new at FL. Any suggestions?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2012 10:25 PM   in reply to grusso@landmarkinvest.com

    Can you give me a sample to demonstrate your problem?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points