freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] croped bitmaps and scalable glyph metrics


From: Werner LEMBERG
Subject: Re: [Freetype] croped bitmaps and scalable glyph metrics
Date: Thu, 03 Jul 2003 11:28:23 +0200 (CEST)

Sorry for the late reply.

> I am trying to produce the PCL-style bitmap and TrueType fonts,
> using FreeType 2.  My first problem is that I can not get croped
> bitmaps, while loading and rendering glyphs.  I have tried different
> flags (like FT_LOAD_RENDER, which is supposed to crop bitmaps
> automatically and FT_LOAD_CROP_BITMAP), but it does not work -
> bitmaps are still the same size and uncropped.  Probably I am
> missing something but what exactly...

To really help you we need some example code.

> Moreover, as far as I can see - bitmaps always have an even pitch,
> so sometimes it gives one extra whole "white" byte at the end of
> each row - which I have to take out additionally.  May be it is also
> possible to change this behaviour?

No, it isn't.  But it should be straightforward to remove it during
copying the bitmap.

> The second problem: I need to get the metrics information for some
> particular scalable glyphs in font's units.  But when loading glyph
> without setting the font size the "face->glyph->metrics.height" and
> "face->glyph->metrics.width" always give a strange number of "64"
> (for lowercase letters) for TrueType and Type 1 fonts.  It can not
> be right, can it?  BBox being 1000+ / 2000+ font units wide and
> high...

If you use the FT_LOAD_NO_SCALE flag, the metrics are returned in font
units, otherwise you get metrics in 26.6 format -- only with
FT_LOAD_NO_SCALE you can avoid setting the font size (you get an error
otherwise).

Sample code (omitting error handling):

  FT_Init_FreeType(&library);
  FT_New_Face(library, font_name, 0, &face);
  FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE);

Now face->glyph->metrics holds the metrics in font units.  Note that
this works for scalable fonts only.


    Werner



reply via email to

[Prev in Thread] Current Thread [Next in Thread]