[cairo] Re: Drawing text with Windows bitmap fonts
Owen Taylor
otaylor at redhat.com
Tue Jan 23 11:28:58 PST 2007
On Tue, 2007-01-23 at 10:16 -0800, Stuart Parmenter wrote:
> We always create the font with size * WIN32_FONT_LOGICAL_SCALE...
>
> if (scaled_font->preserve_axes) {
> ...
> scaled_font->logical_size = WIN32_FONT_LOGICAL_SCALE *
> _cairo_lround (scaled_font->y_scale);
> ...
> }
> if (!scaled_font->preserve_axes) {
> ...
> scaled_font->logical_size = _cairo_lround (WIN32_FONT_LOGICAL_SCALE *
> scaled_font->y_scale);
> ...
> }
>
> which means that:
> logfont.lfHeight = -scaled_font->logical_size;
> scaled_font->scaled_hfont = CreateFontIndirectW (&logfont);
>
> so for a 10px font we'll create a 320px bitmap font and then we
> SetWorldTransform it back down when we draw it. This just doesn't
> work. Most bitmap fonts aren't going to have 320px versions.
To actually get metrics, you have to select a font into a DC. So,
Windows is never interpreting the size you pass in independent
of the world transform.
Now, it's possible that bitmap fonts simply don't work with
SetWorldTransform() ... it wouldn't be surprising to me ...
but leaving aside that, the logic above is working exactly as
expected.
> fwiw, rotated and scaled text works fine with this set to 1.
Oh, it's not going to be *way* off, but quantizing distances
along a baseline rotated by by, say, 23 degrees, to integer "pixel"
values doesn't make any sense and the results won't be as good.
- Owen
More information about the cairo
mailing list