[cairo] Re: Drawing text with Windows bitmap fonts

Stuart Parmenter stuartp at gmail.com
Tue Jan 23 00:22:31 PST 2007


So the main problem with bitmap fonts in cairo is
WIN32_FONT_LOGICAL_SCALE (in cairo-win32-private.h) being 32.  This
will break all bitmap fonts since we'll always ask for much larger
fonts than you really want.  In Mozilla we change this to 1 without
any real problems.  You may want to give this a shot.  We can probably
just remove all the logical scale code but we avoid going through the
cairo-win32-font code mostly so I'm not sure if it breaks paths we
don't hit.

Try changing it to 1 and see if it works for you!

stuart

On 1/22/07, Jan Slupski <jslupski at gmail.com> wrote:
> Jan Slupski wrote:
> > Stuart Parmenter wrote:
> >  > Has anyone gotten win32 bitmap fonts to render using cairo?  I'm using
> >  > cairo_show_glyphs() with glyph indexes I've gotten from Uniscribe.
> >  > Things fall apart in _cairo_win32_scaled_font_init_glyph_metrics in
> >  > cairo-win32-font.c when it tries to do GetGlyphOutlineW().  According
> >  > to the MSDN docs, using GGO_GLYPH_INDEX means that it is a true type
> >  > index, which I'm not sure if bitmap fonts really respect.
> >  > GetGlyphOutlineW ends up failing...  I could be going down the wrong
> >  > path here.. was wondering if anyone else had done more digging or had
> >  > any suggestions.
> >
> > Indeed, it seems that support for bitmap fonts is somewhat broken.
> > I am trying to open Windows font called "Small Fonts" (smalle.fon).
> >
> > As stated above, cairo is using _scaled_* functions to operate
> > on that font that seems to be wrong by definition.
> > This ends up on querying the font with GetGlyphOutlineW that
> > by MSDN definition "The GetGlyphOutline function retrieves the outline
> > or bitmap for a character in the *TrueType* font".
> >
> > I think cairo should either properly support windows bitmap fonts
> > (ignoring font size & rotation?), or fail in more meaningful way. It
> > could be either return of an error by cairo's API call, or fallback to a
> > default font in the same way as when unknown font name is passed.
>
> Hi again,
>
> I have opened a bug report for that issue at:
> https://bugs.freedesktop.org/show_bug.cgi?id=9740
>
> Also I have proposed a (temporary?) workaround that forces Windows to
> choose closes matching font from among TrueType fonts only.
>
> CreateFontIndirect parameter OUT_TT_ONLY_PRECIS: Instructs the font
> mapper to choose from only TrueType fonts. If there are no TrueType
> fonts installed in the system, the font mapper returns to default behavior.
>
> All the best,
> Jan
>


More information about the cairo mailing list