Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter to control text line height/leading #152

Closed
antonfirsov opened this issue Dec 7, 2020 · 4 comments · Fixed by #153
Closed

Parameter to control text line height/leading #152

antonfirsov opened this issue Dec 7, 2020 · 4 comments · Fixed by #153
Labels
commercial Used for commercial license holders only. DO NOT ABUSE enhancement

Comments

@antonfirsov
Copy link
Member

antonfirsov commented Dec 7, 2020

Follow-up on SixLabors/ImageSharp.Drawing#112:

We need to introduce a parameter in title in RenderOptions.

That parameter should then somehow alter the following offset value:

var offset = new Vector2(0, lineHeightOfFirstLine - top);

/cc @tocsoft @JimBobSquarePants

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Dec 7, 2020

So I've been doing some reading and according to these Flutter docs LineHeight appears to be a combination of the Leading value (additional spacing split evenly above and below the line) and the font Height value (height (ascent plus descent)).

However, we calculate the Font.LineHeight property as TypoAscender - TypoDescender + TypoLineGap based on the Microsoft docs.

This, as you can imagine, leads me to some confusion.

@antonfirsov @tocsoft I'll definitely need your guidance here. Should we be simply adding a float? LineHeight property and calculating everything from that?

On a side note we should refactor RenderOptions to remove all the constructors and use property initializers.

@tocsoft
Copy link
Member

tocsoft commented Dec 8, 2020

I wouldn't add a LineHeight property instead we should be provide a LineSpacing property (which is how such a feature is presented in Word) and if we are using Word as a strategy then it should be a multiply we apply the calculated LineHeight.

So if you want to increase the spacing between the lines you would provide a number > 1 and to get lines closer a value < 1 with one being our current size and default value.... I also would not stop negative values as I can see it producing some interesting results and can't see why it would break anything.

@JimBobSquarePants
Copy link
Member

Is Word something we want to base our approach on?

Perhaps we should follow the WC3 CSS Fonts Module Level 4 spec and provide overrides for ascent, descent, and line-gap?

https://www.w3.org/TR/css-fonts-4/#font-metrics-override-desc

I'm trying to figure out what Skia and System.Drawing do but it's bizarrely difficult to discover an straight answer.

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Dec 10, 2020

Ok @tocsoft I did some reading and, as ever, your plan is definitely the most sane!

I'm assuming applying the value would be as simple as this then?

var offset = new Vector2(0, (lineHeightOfFirstLine * options.LineSpacing) - top);

Edit. Nope. Adjusting that value appears to offset the first line and doesn't affect wrapped lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commercial Used for commercial license holders only. DO NOT ABUSE enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants