[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Using XftMatrix to solve KOffice's WYSIWYG problem
From:       David Faure <david () mandrakesoft ! com>
Date:       2002-06-11 13:21:14
[Download RAW message or body]

Hello Keith,

Some news from the KWord front:

We finally found a way to get fully proportionnal characters.
Instead of using an integer font size (e.g. 6pt at 50% zoom for a 13pt at 100% zoom)
we use XFT_MATRIX, and an XftMatrix set to scale the fonts
(i.e. we patched Qt to add a QFont::setMatrix(const QWMatrix&)
This gives the desired result, except for one problem:
the hinting (I think this is the right term) is still done for the initial
size, e.g. 13pt. When zooming in, e.g. at 300%, the font is 39pt, so the shape
of the letters should be much more "round". But because FT_Set_Char_Size
is called with a value of 13, the shape is rather polygonal.
The fix would be to either apply the 'scaling' part of the matrix to the
size before passing it to FT_Set_Char_Size (not sure what the mathematical
formula for this would be...), or to simply add an API call to Xft, and to Qt,
so that the app can set the char size itself, in addition to setMatrix.
The first solution looks nicer to me, though. I'll try to get some help
from my mathematics-aware family, to provide a patch ;)

Would it be better to maybe use a high-res fontsize (e.g. 13*20=260pt),
with a matrix set to 'scale down', e.g. by 1/20 for 100% zoom?
We'd still have to set the correct character size, obviously.

With this XftMatrix solution, I'm also having problems doing the right thing
at text layout time, i.e. figuring out the size the characters will have
on screen (to e.g. position the cursor correctly, etc.). If I use the
metrics at 100% and multiply those, it looks correct (with all the code we
had to handle the difference between the proportionnal size and the real
rounded size, cumulating rounding errors etc. - quite ugly).
I'm trying to get rid of all that, but failed up to now. Somehow I don't seem
to get correct font metrics for a 260pt... Ah, I think I remember noticing
that Qt (and maybe X) has a limitation on font sizes. Maybe I should just
use *4 as a reference font for the metrics, instead of *20.

Thanks for any input on this, particularly on the FT_Set_Char_Size issue.
I'm not sure whether to send the Qt patch (QFont::setMatrix) to TrollTech,
given this Xft "bug". Things look nice at 125%/150% zoom though, unlike before;
the hinting problem only becomes visible at 300%+.

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KDE, Making The Future of Computing Available Today

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic