-
Notifications
You must be signed in to change notification settings - Fork 254
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
Ascender and Descender calculation seems off #7
Comments
I can confirm the issue. Using Google Open Sans Regular font
while
Rendering After manually replacing metrics in I've located the issue in NOTICE: I'm not quite sure that this is the right way to solve this issue. I've done tests only with Open Sans (variants Regular and Bold), and DejaVu Sans Regular fonts, and only with DomPDF library. Workaround for DomPDFUse custom
Package versions
|
Hey fellows, during our implementation of a design editor, based on KonvaJS where the customer can declare and place marker elements, we had big trouble with this issue. The post-rendering of dynamic elements is processed via DomPDF. Due to the wrong calculation of the Ascender and Descender, the text is not placed at the correct position. I was calculating a lot of time and came to the following result. After I made these changes, our rendered PDFs are looking perfect. Best regards Jan |
Thanks for the issue analysis! Feel free to submit a pull request if you have time, but we'll review and work that into an upcoming release regardless if appropriate. |
@shokre Thanks a lot, the workaround works!
This issue is probably caused by the difference between the terms "Ascender" / "Descender" in AFM and TrueType
So Ascender/Descender in AFM cannot be calculated from TrueType font metadata (neither "hhea" nor "OS/2"). Unfortunately, I'm not ready to make patch and submit pull request now. |
This is exactly right, except that php-font-lib should be doing the work so that the values in the AFM/UFM are correct. I tested with Open Sans and get the expected results. The updated logic will populate CapHeight (H), XHeight (x), Ascender (d), and Descender (p) values based on the glyph data as outlined by the specification. Ascender and Descender will fall back to the old logic if their respective glyphs are not present since the spec language around those values is that they are "usually" or "typically" based on those characters. I couldn't think of a related TrueType table record to reference for the other two values so they will not have a fallback and will be excluded if their glyphs are not present. |
CapHeight, XHeight, Ascender, and Descender values should be based off of character data. fixes #7
CapHeight, XHeight, Ascender, and Descender values should be based off of character data. fixes #7
While use one of the Google webfonts: drsugiyama-regular, i noticed that php-font-lib created some really high ascender and descender limits, causing some extra line spacing. (DomPDF use)
Link to the font used from Google's web font:
http://www.google.com/fonts/#ChoosePlace:select/Collection:Dr+Sugiyama
Are the ascender and descender wrong in the font, causing this issue? If you look at the font loaded within the browser, paragraph layouts do not seem to show the extra line spacing.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1304232-ascender-and-descender-calculation-seems-off?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: