We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4339 - Using SDL_ttf Outline, TTF_GlyphMetrics won't report updated values
Summary: Using SDL_ttf Outline, TTF_GlyphMetrics won't report updated values
Status: RESOLVED FIXED
Alias: None
Product: SDL_ttf
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-29 20:04 UTC by Sylvain
Modified: 2018-10-30 03:19 UTC (History)
0 users

See Also:


Attachments
patch (10.12 KB, patch)
2018-10-29 20:09 UTC, Sylvain
Details | Diff
test case (6.38 KB, text/x-csrc)
2018-10-29 20:13 UTC, Sylvain
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain 2018-10-29 20:04:42 UTC
When using outline style TTF_SetFontOutline(), it appears that TTF_GlyphMetrics won't return the correct glyph values, taking into account the user outline value. 

It also appears the current width is sometime at little bigger (few pixels), when it's not always necessary. it's not the same calculation for other styles.

(reason is because final surface width is *always* incremented of 2 outlines, whereas the ending glyph should contribute by adding max(advance/maxx), and advance remain fixed - not subject to outline style).
Comment 1 Sylvain 2018-10-29 20:09:53 UTC
Created attachment 3413 [details]
patch

Here's a patch.

In fact, the outline feature is spread in several function only to get rendering working.

It's easier to group that.

Parameters that are glyph related can be updated in Load_Glyph(CACHE_METRIC).

Parameters that are font related cannot be updated in openfont(), because the outline has not been set yet. That part needs to be put in a separate function so that a refresh is possible. It's the purpose of TTF_initFontMetrics().
Comment 2 Sylvain 2018-10-29 20:13:41 UTC
Created attachment 3414 [details]
test case

Here's a test-case that set outlines and try all styles and rendering, and pattern.

the patch still have the same output (pixel perfect).
except for the width that may be different by a few pixels (not cropped!).
Comment 3 Sam Lantinga 2018-10-30 03:19:32 UTC
This patch is in, thanks!
https://hg.libsdl.org/SDL_ttf/rev/ff81ac6d76c4