Skip to content

Line height is not properly calculated #16476

Closed

Description

@ocerman

Line height is smaller compared to another browsers when the "line-height" css property is not specified.
Tested on Windows 8.1 x64.

<html>
	<style>
		.utext {
			font-size: 70px;
			font-family: 'Tahoma', 'Ubuntu';
		}
	</style>
	<div class="utext">
		This is a test<br>
		servo servo
	</div>
</html>

font-size

Activity

  1. pyfisch commented on Apr 15, 2017

    @pyfisch
    Contributor

    Can not reproduce on Ubuntu 16.04. Why is the font family either Tahoma or Ubuntu? It may help to remove one font.

  2. atouchet commented on Apr 15, 2017

    @atouchet
    Contributor

    I get the same output as @BlackSVK in Windows 10.

  3. ocerman commented on Apr 15, 2017

    @ocerman
    Author

    @pyfisch It seems it does not matter which font I set.

  4. sciguyryan commented on Apr 15, 2017

    @sciguyryan

    I can confirm that this issue definitely exists on Windows 10. The font also doesn't seem to affect the results at all.

  5. jdm commented on Apr 15, 2017

    @jdm
    Member

    This may be an example of #16034 being an incomplete solution.

  6. added
    P-windows
    on Apr 15, 2017
  7. codec-abc commented on May 2, 2017

    @codec-abc

    jdm is probably right. If someone wants to take a look my previous comment may be a good starting point. I might take a look at it if I have enough time.

  8. hinaria commented on Jun 15, 2017

    @hinaria
    Contributor

    yeah. to further illustrate, the current code returns these font metrics for segoe ui at 40px. if you look closely, the current algorithm for windows reports a line gap of 21px for a 40px font size, which obviously cannot be correct.

    uh oh

    FontMetrics {
        underline_size:   0.9333333333333333px
        underline_offset: -3.4833333333333334px
        strikeout_size:   0.8px
        strikeout_offset: 10.35px
        leading:          15.15px
        x_height:         20px
        em_size:          40px
        ascent:           43.166666666666664px
        descent:          10.033333333333333px
        max_advance:      0px
        average_advance:  0px
        line_gap:         21.283333333333335px
    }

    i will fix this tonight.

  9. added a commit that references this issue on Jun 15, 2017
  10. codec-abc commented on Jun 15, 2017

    @codec-abc

    What you can do is dump the values of the struct returned by the DirectWrite API. As we already summing three fields in the struct to compute the baseline I would be suprised if we need to add more. Maybe it is a problem of sign in the line linegap value of the DirectWrite struct (The 2 others are unsigned) or a unit problem.

  11. hinaria commented on Jun 15, 2017

    @hinaria
    Contributor

    this issue should be fixed in #17340! :D


    @codec-abc of course, that's is the obvious first step. in any case, it's fixed already!

    // segoe ui (as above)
    DWRITE_FONT_METRICS {
        designUnitsPerEm:       2048
        ascent:                 2210
        descent:                514
        lineGap:                0
        capHeight:              1434
        xHeight:                1024
        underlinePosition:      -178
        underlineThickness:     119
        strikethroughPosition:  530
        strikethroughThickness: 102
    }
  12. added a commit that references this issue on Jun 15, 2017
  13. reopened this on Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-platform/fontsP-windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions