it seems most of my calculations for freetype are based on ceil() so yes...
if any fraction round up...
do you keep the original freetype bitmap? Or are you moving it to an
internal format?
I use FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); which has a
bitmap in the face->glyph structure that gets filled in and apparently
sized appropriate for the glyph... but that's not an outline.  I process
the bitmap and skip any areas that are blank outside the character... I
assumed it would be on some worst-case... that included the expected white
area around the character; and I wanted a minimal character
representation... but then once I have that I have exact w/h of the bitmap;
so I end up building a opengl texture with exact characters + 1 row between
so I don't get antialias overflows... based on character height for
matching rows and appending across...

 seems to measure all lines of a character, find least bit set call it
left, find max x bit set, call it+1 right, and set character size to
right-left.  if right > 0...
I tried to match up like metrics->horiBearing and stuff; but never worked
well until I just scanned for the data in the bitmap....




On Sun, Nov 2, 2014 at 2:41 AM, Marco Wertz <marco.we...@gmx.de> wrote:

> > > when using FT_Outline_Get_BBox() to get the dimensions of the
> > > outline, the values are all in the 26.6 fixed point format. How do I
> > > determine the optimal pixel size for a bitmap to pass to
> > > FT_Outline_Get_Bitmap() so that the outline fits *exactly* into the
> > > bitmap dimensions?
> > >
> > > The obvious approach would be something like this:
> > >
> > > width = bbox.xMax - bbox.xMin;
> > > height = bbox.yMax - bbox.yMin;
> > >
> > > pixelwidth = width >> 6;
> > > pixelheight = height >> 6;
> > >
> > > if((width & 0x3f) > 31) pixelwidth++;
> > > if((height & 0x3f) > 31) pixelheight++;
> > >
> > > This will add another pixel in case the fractional part of the 26.6
> > > fixed point value is >= 0.5. But I'm not sure if this is the right
> > > approach....
> >
> > Yes, this looks good.
>
> Actually, it doesn't work for all outlines. I have an outline here for
> which (bbox.yMax - bbox.yMin) is 23448, i.e. the integer part is 366 and
> the fractional part is 24. As the fractional part is less than 0.5, I
> do not add another row. So the bitmap I pass to FT_Outline_Get_Bitmap()
> has 366 rows. This, however, is not enough as the topmost row is missing.
> FT_Outline_Get_Bitmap() actually draws 367 rows for this outline although
> the fractional part is less than 0.5.
>
> What's the recommended way of dealing with this behaviour? Should I always
> allocate one row and one column more if the fractional part is != 0? But
> this
> might lead to empty rows/columns, doesn't it? What's the suggested way of
> dealing with this problem? I'd like my bitmap to have the *exact* size
> of the shape, i.e. without an empty rows or columns.
>
> How can I achieve this? I could of course always add the additional
> column/row
> and then check for empty rows and columns and clip them but that's some
> unnecessary overhead if you ask me.
>
> Marco
>
> _______________________________________________
> Freetype mailing list
> Freetype@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/freetype
>
_______________________________________________
Freetype mailing list
Freetype@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to