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

Summary: Using SDL_ttf Outline, TTF_GlyphMetrics won't report updated values
Product: SDL_ttf Reporter: Sylvain <sylvain.becker>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86_64   
OS: Linux   
Attachments: patch
test case

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