none
How does line spacing works? RRS feed

  • Question

  • I've reached the ends of the internet but was not able to obtain what I'm looking for. And I know in here, I only get the answer.. that is if I asked the question.

    So, the title says it all. I want to know how does line spacing works? 1.0(single) line spacing? 1.5 line spacing? 2.0(double) line spacing?

    And just a follow-up question: (maybe some of these are off-topic, but I need this as well in my study)

    • How does line spacing affects paragraph spacing?

    • I've discovered that pt(point) in line spacing is different from pt(point) in font size. Why so? or how do I measure line spacing?

    • Side question, if for example a paragraph has 1.5 line spacing, how much space is added before the paragraph? after the paragraph?

    According to this article

    Many people probably assume that the “simple” line-spacing options — single and double spacing — merely reflect multiples of the point size of the font they are using. If that were so, single-spacing with any 12-point font would produce lines of text that are 12 points in height and double-spacing would produce lines of text that are 24 points in height. (As a reminder, there are 72 points to an inch; thus, 12 points is 1/6 of an inch and 24 points is 1/3 of an inch.)

    However, that formulation leaves out one crucial factor. In order to improve readability, single and double spacing add a certain amount of vertical distance — in the form of white space — between lines of text, an aspect of typography known as “leading” (pronounced as if it were spelled “ledding”). The amount of leading varies depending on which font you are using (not all 12-point fonts are equal). Typically, single-spaced lines range from 110% to 135% of the font size.

    • Is leading can be found in the XML data? where?


    • Edited by sorryiamnaive Monday, September 7, 2015 3:57 AM additional question
    Monday, September 7, 2015 3:40 AM

All replies

  • Hello sorryiamnaive Thanks for contacting Microsoft Support. A support engineer will be in touch by tomorrow to assist further. Thanks.

    Tarun Chopra | Escalation Engineer | Open Specifications Support Team

    Monday, September 7, 2015 6:07 PM
  • Hello sorryiamnaive :

    Josh from our team will contact you to assist further.

    Thanks.


    Tarun Chopra | Escalation Engineer | Open Specifications Support Team


    Tuesday, September 8, 2015 3:22 PM
  • Hi, I will try to address each of your questions individually.

     

    How does line spacing affects paragraph spacing?

    A line spacing value of 1 will not affect paragraph spacing at all. Any value greater than 1 will increase the space between the paragraph and the one that follows. It does not increase the spacing between the paragraph and the previous one.

     

    I've discovered that pt(point) in line spacing is different from pt(point) in font size. Why so? or how do I measure line spacing?

    It depends on the value of lineRule.

    • If lineRule is atLeast or exactly, the value of the line attribute represents 20th's of a point.
    • If lineRule is auto, the value of the line attribute represents 240th's of a line.

     

    Side question, if for example a paragraph has 1.5 line spacing, how much space is added before the paragraph? after the paragraph?

    As mentioned in the answer for question 1, no space is added before the paragraph. A line spacing value of 1.5 will add an amount of white space equal to 50% of the line height below each line.

     

    Is leading can be found in the XML data? where?

    This is not part of the file format but is part of the rendering engine of the application. Calculating leading and line height is a complicated topic and will vary by font and size. Additionally, most applications will have their own way of calculating it with no two being exactly the same. Even different versions of the same application (ex. Word 2010 vs. Word 2016) may not calculate it in the same way.

     

    If you want explicitly set the line height you can set the lineRule to exactly and specify the value for line as 20th's of a point.

     

    More information about the spacing element can be found in ISO/IEC 29500-1 in section 17.3.1.33. Additionally, there are several other threads on this forum that deal with related topics that you might find helpful.

     

    Please let me know if you have any other questions.


    Josh Curry (jcurry) | Escalation Engineer | Open Specifications Support Team

    Thursday, September 10, 2015 3:08 PM
    Moderator
  • It does not increase the spacing between the paragraph and the previous one.

    Shoot! My bad I forgot to mention that I'm working on PresentationML, that is why it took me a moment to comprehend that what you're talking about is WordProcessingML.


    Friday, September 11, 2015 1:09 AM
  • It depends on the value of lineRule.

    • If lineRule is atLeast or exactly, the value of the line attribute represents 20th's of a point.
    • If lineRule is auto, the value of the line attribute represents 240th's of a line.

    I can't seem to find this one in PresentationML, and all I'm getting when setting the line spacing is either:

    <a:lnSpc>
        <a:spcPct val="150000"/>
    </a:lnSpc>

    *1.5 line spacing represented by Spacing Percent

    or

    <a:lnSpc>
        <a:spcPts val="2500"/>
    </a:lnSpc>

    *25-points in 100th of a point represented by Spacing Points


    Friday, September 11, 2015 1:19 AM
  • Side question, if for example a paragraph has 1.5 line spacing, how much space is added before the paragraph? after the paragraph?

    As mentioned in the answer for question 1, no space is added before the paragraph. A line spacing value of 1.5 will add an amount of white space equal to 50% of the line height below each line.

    I'm just going to show an illustration for this question. 

    ^Shown in the image are 3 paragraphs (PARA#1's are on the same paragraph).

    ^Left illustration shows PARA#1 line spacing is 1.5 and on the right PARA#1 line spacing is default(1.0).


    • Edited by sorryiamnaive Monday, September 14, 2015 2:38 AM correction in the illustration
    Friday, September 11, 2015 1:43 AM
  • Hello sorryiamnaive,

    I'm looking into your question regarding PresentationML/DrawingML. Can you clarify how the image you linked was generated? Specifically in the left column, are Para#0 and Para#2 using line spacing of 1.0 or 1.5? I can generate a similar spacing if I make Para#0/Para#2 line spacing 1.0 and Para#1 using 1.5. If I make all three paragraphs use line spacing 1.5, the space between all lines of text is uniform.

    Thanks,
    Kamil Sykora

    Tuesday, September 15, 2015 2:43 PM
  • Left illustration:
    - 3 paragraphs (PARA#0, PARA#1, PARA#2)*

         * Noticed that there are two(2) PARA#1, but it is just actually PARA#1PARA#1 then you shrink the shape to make it to look like it.

    - PARA#0 line spacing : 1.0 (single spacing)/default

    - PARA#1 line spacing : 1.5 (1.5 spacing)

    - PARA#2 line spacing : 1.0 (single spacing)/default

    - Then between PARA#1 and PARA#1 (since it has 1.5 spacing), I wrote what I think the equation for getting the spacing there.

    - I also tried my equation with different line spacing and still it works.*

          *First two lines is on the same paragraph (same thing i did with two(2) PARA#1).

          *Last two lines is on different paragraph and it has single space.

    - So my equation to get the height of the space is just simply:

                 (lineHeight * (spacing - 1)) + (spacing * singleSpace)

    - How have I come up with the equation? I tried measuring the text in pixels using MS Paint. Then with many test cases to support my intuition, I was pretty convinced that I was right.

    Right illustration:

    - 3 paragraphs (PARA#0, PARA#1, PARA#2)

    - All paragraphs has line spacing : 1.0 (single spacing)/default



    Wednesday, September 16, 2015 3:38 AM
  • Hello sorryiamnaive,

    The Line Spacing (21.1.2.2.5 lnSpc (Line Spacing)) element of the ISO/IEC 29500 specification specifies the spacing of the line as a total that is added to the line, both on the top and bottom. It does not specify how much of that space is added in each direction. Furthermore, the calculation is performed in points or percentages whereas the final rendering on screen or captured in a screenshot is in pixels which are device-specific units. This introduces some inaccuracies when trying to measure the space in pixels.

    I'm using the linked/attached picture: 

    to demonstrate some of the values that I observe in my test. Each column is exactly aligned on top and contains the same text with the same sized font. All columns use 0 for spcAft/spcBef. The first column uses single line spacing for all three paragraphs, the second column uses 1.5 spacing for all three paragraphs, the third column uses single line spacing for paragraphs 1 and 3 and 1.5 spacing for paragraph 2.

    When the line spacing for a paragraph is applied, the text is immediately shifted down by the amount of whitespace that was added at the top of each line. This is apparent in the 2nd column in the picture. This top amount is part of the whitespace that was added to the whole line to account for the 1.5 spacing and is about 10 pixels as measured in the picture. The distance from the top of each letter P to the next in the 2nd column is always 50% more than the corresponding distance in the first column since we are adding 50% more line-width compared to the first column. This total increase is approximately 14-15 pixels. The bottom increase is therefore approximately 4-5 pixels. The total increase is the only thing that the lnSpc element specifies, not the top/bottom split.

    The distances in the third column are less intuitive but follow from the split of the top/bottom space added. The transition from paragraph 1 to paragraph 2 is from single to 1.5 spacing and the whitespace increase (as compared to the first column) is about 10 pixels (the top increase added for the first line of paragraph 2). The transition from paragraph 2 to paragraph 3 is about 4-5 pixels larger which is due to the bottom whitespace added to the last line of the second paragraph.

    Similarly in your first example I see that the single line spacing generates a line of 108 pixels (distance from the top of each P in the right column) and 162 pixels for the 1.5 line spacing (distance from the top of each P in the left column, Para#1) for a total increase of 50% = 54 pixels. The distance between the top of the letters between #0 and #1 is 142 pixels - an additional 34 pixels added at the top of Para#1. The distance between the top of the letters for Para#1 and Para#2 is 128 pixels, or 20 extra pixels added at the bottom of Para#1. 34+20 is 54, which is the total additional space for lines in Para#1.

    Let me know if these numbers agree with your other test cases.

    Thanks,
    Kamil Sykora

    Wednesday, September 16, 2015 2:38 PM
  • I have this tests and your solution seems to work only to 2.0 line spacing.

    BTW, this is a different font face compared to the previous illustrations.

    Using your solution, I've constructed an equation to get the amount of spaces added before and after the paragraph.

    valueToBeAddedToALineWithLineSpacing = (lineSpacing - 1) * heightOfASingleSpaced;
    // 96 = (2.0 - 1) x 96;
    
    newHeightOfALine = valueToBeAddedToALineWithLineSpacing + heightOfASingleSpaced;
    // 192 = 96 + 96
    
    valueAddedBeforeParagraph = 0.63 * valueToBeAddedToALineWithLineSpacing;
    // 60.48 = 0.63 * 96;
    
    newHeightBeforeParagraph = valueAddedBeforeParagraph + singleSpacedHeightOfBeforeParagraph;
    // 78.48 = 60.48 + 18;
    
    valueAddedAfterParagraph = 0.37 * valueToBeAddedToALineWithLineSpacing;
    // 35.52 = 0.37 * 96;
    
    newHeightAfterParagraph = valueAddedAfterParagraph + heightOfASingleSpaced;
    // 131.52 = 35.52 + 96;

    Obviously, 63% and 27% are just approximates. Maybe I can deduce to two more decimal places so I can be more precise.


    Thursday, September 17, 2015 9:43 AM
  • Hello sorryiamnaive,

    I have reviewed the test cases in the picture and made similar calculations as before (see below). They appear to match the line width percentages as expected. Please note that the only behavior that is described by the specification is the total line width for any given line spacing. The positioning of the font within the line is an implementation detail. You can use the formula you derived as long as the total line width ends up being the correct % of the 1.0 spacing.

    If you have any test cases that do not agree with this formula, please let me know.

    In the calculations below I note which values are measured from your submitted picture. The rest are simple calculations that derive from those values. The 1.1 case is interesting because the top space is actually reduced but the bottom space is increased more than proportionately to account for the 10% extra space needed.

    Line spacing 1.0
    Top-top distance (measured) = 96
    Border-top distance (measured) = 27
    1.0-1.0 gap (measured) = 35

    Line spacing 2.0
    Top-top distance (measured) = 192 (200% of 96)
    Border-top distance(measured) = 88
    Extra total = 192 - 96 = 96
    Extra top = 88-27 = 61
    Extra bottom = 96-61 = 35
    2.0-1.0 gap (measured) = 70 (original 35 + extra 35)

    Line spacing 1.5
    Top-top distance (measured) = 144 (150% of 96)
    Border-top distance (measured) = 52
    Extra total = 144 - 96 = 48
    Extra top = 52-27 = 25
    Extra bottom = 48-25 = 23
    1.5-1.0 gap (measured) = 58 (original 35 + extra 23)

    Line spacing 1.1
    Top-top distance (measured) = 106 (110% of 96 = 105.6)
    Border-top distance (measured) = 23
    Extra total = 106-96 ~= 10
    Extra top ~= -4
    Extra bottom ~= 10-(-4) = 14
    1.1-1.0 gap (measured) =  48 (original 35 + extra ~14 )

    Line spacing 1.6
    Top-top distance (measured) = 154 (160% of 96 = 153.6)
    Border-top distance (measured) = 59
    Extra total = 154 - 96 ~= 58
    Extra top = 59-27 ~= 32
    Extra bottom = 58-32 ~= 26
    1.6-1.0 gap (measured) = 60 (original 35 + extra 26)


    Thanks,
    Kamil Sykora

    Tuesday, September 29, 2015 4:41 PM