Bug 5862

Summary: glyphs metrics should always be hinted, regardless of load_flags
Product: cairo Reporter: Chia-I Wu <b90201047>
Component: freetype font backendAssignee: Owen Taylor <otaylor>
Status: RESOLVED NOTABUG QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: high    
Version: 1.1.1   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: patch
I guess font metrics should be hinted too...
clipped glyphs

Description Chia-I Wu 2006-02-11 17:46:42 UTC
The glyphs metrics should always be hinted, regardless of load_flags, for

1) a glyph might not get hinted even if we ask for hinting in load_flags.
2) since freetype 2.2.0 (not released yet), a hinted glyph is not guaranteed to
have integral metrics.
Comment 1 Chia-I Wu 2006-02-11 17:48:49 UTC
Created attachment 4595 [details] [review]
patch
Comment 2 Chia-I Wu 2006-02-11 19:31:59 UTC
Created attachment 4596 [details] [review]
I guess font metrics should be hinted too...
Comment 3 Chia-I Wu 2006-02-25 20:31:42 UTC
Created attachment 4744 [details]
clipped glyphs

Metrics hinting in cairo, by definition, means quantizing them so that metrics
have integer values.  Without doing this, the inter-character or inter-line
space may be inconsistent.  Another issue is that glyphs may be clipped.

Imagine a typeface with descender 2.4px and a glyph which also has descender
2.4px.	With anti-alias, the glyph has actually descender 3.0px.  While 2.4 is
rounded to 2.0px, the bottom-most pixel of the glyph is clipped.

In this image, you can see that the `g' is clipped (firefox + pango).
Comment 4 Behdad Esfahbod 2006-02-25 23:54:29 UTC
This is the kind of thing that should go into 1.0 branch I believe.  Pango
output looks very bad with FreeType 2.2, so, this is kinda High priority IMO,
and I really prefer not patching for this in Pango...
Comment 5 Chia-I Wu 2006-02-26 01:05:37 UTC
(In reply to comment #4)
> and I really prefer not patching for this in Pango...
That's true.  pango should not be patched for this, for otherwise performing
device-independent layout is not possible with cairo backend.
Comment 6 Behdad Esfahbod 2006-02-26 01:20:52 UTC
You cannot do device-independent layout anyway, if you do any kind of
rounding/hinting.  You always have a dpi setting and always laying out for that
specific setting.  If you have a big enough dpi and large enough fonts, it looks
like it's device-independent.  That's all.
Comment 7 Chia-I Wu 2006-02-26 02:45:54 UTC
Can pango be used to do device-independent layout with cairo backend when
metrics hinting is turned off?  I thought pango is able to do that, as long as
the backend in use can.

My first try was to patch for this in pango.  But that patch would make
device-independent layout with cairo backend impossible.  I soon turned to work
on cairo because it also needs patching and it has a swtich to turn metrics
hinting on or off, which makes my patch correct and cleaner.
Comment 8 Owen Taylor 2006-02-26 03:18:13 UTC
Metric hinting and glyph hinting can be turned on and off independently in Pango
with pango_cairo_context_set_font_options() ... there are some caveats, of course;
for example even with metric hinting off you won't get subpixel glyph positioning,
unless you draw your text as outlines.

So, yes, if you turn metric hinting off, you will get device independent layout.
Comment 9 Behdad Esfahbod 2006-02-27 08:40:14 UTC
David Turner reverted that change.  Closing.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.