[cairo] text on win32

JORDAN MINER jminer2613 at students.pcci.edu
Sat Feb 10 17:32:29 PST 2007

Sorry for the late reply. The email system here swallowed almost every
email I received from Feb 1st to Feb 7th, then delivered all of them on
Feb 8th. I've never had that happen before.

>                                    I'm sorry to hear that you can't
> build cairo versions any faster than a couple of hours each, (why is
> that by the way?).

I have been compiling it with Microsoft's free complier. (The first one
they gave away.) I write my own makefile that defines certain constants,
such as cairo_public=__declspec(dllexport). I include all .c files in the
makefile, remove ones that I know aren't needed, then remove more when
they cause compile errors. With previous versions of cairo, sometimes I've
also had to fix files to compile with Microsoft's compiler. Except for
fixing the files, I don't mind spending time upgrading, as I only need to
every year or so.

>                    This would be a perfect situation for
> git-bisect. The process would be to first get a working copy of git,
> (which for win32 has generally required cygwin, although a recent
> mingw port[*] is starting to show promise).

I've now downloaded and installed cygwin and git, but it's hard for me to
get cairo downloaded with git clone. (Proxy with college internet & slow
connection with off-campus internet.)
However, even though I had never looked at cairo's code, I've have managed
to track down the problem, which is really easy to fix. The problem was
introduced with this commit:

commit bf78be63fc35dc13899209ee818f37fe3f564fed
Author: U-JONATHAN-X60S\jonathan <jonathan at Jonathan-X60s.(none)>
Date:   Fri Dec 15 00:48:54 2006 +0100

    Fix a couple of character spacing issues on Windows

It partially rewrote the way glyphs are shown. Previously, the difference
in user coordinates between two adjacent glyphs was taken, then converted
to logical coordinates by multiplying by WIN32_FONT_LOGICAL_SCALE, and
then passed to Windows. The current code first converts the two adjacent
glyphs' coordinates from user to logical, then takes the difference of
them, then converts them to logical again (even though they are already in
logical coordinates), and then passes them to Windows. Since 1 user equals
32 logical, the characters end up being 32 times too far apart.

> It is the toy API, but it still really needs to work. And this would
> obviously be a big regression between major releases, so it's
> something we should fix before cairo 1.4.0.

Since the bug is in _cairo_win32_surface_show_glyphs, I suppose the bug is
not limited to the toy API after all.

> Consider it filed. I added a note about this to cairo/ROADMAP.

Thank you for considering this bug as important to fix as I do. Here is
the patch, generated with git.

--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1580,8 +1580,8 @@ _cairo_win32_surface_show_glyphs (void			*surface,
             next_logical_x = _cairo_lround (next_user_x);
             next_logical_y = _cairo_lround (next_user_y);

-            dxy_buf[j] = _cairo_lround ((next_logical_x - logical_x) *
-            dxy_buf[j+1] = _cairo_lround ((logical_y - start_y) *
+            dxy_buf[j] = _cairo_lround (next_logical_x - logical_x);
+            dxy_buf[j+1] = _cairo_lround (logical_y - start_y);

             logical_x = next_logical_x;
             logical_y = next_logical_y;

More information about the cairo mailing list