The code in FT_Embolden_Bitmap takes a bitmap and produces a bold version of it. I want to do this to use as an outline for my glyphs.

The code creates a new bitmap which may have a new pitch and then enters a loop to copy the data from the old bitmap to the new bitmap a scan line at a time.

However if there was extra padding in the original bitmap it's possible for the new bold bitmap to have a smaller pitch than the original bitmap. This is often the case if the original bitmap was produced by the monochrome Freetype renderer which pads bitmaps to a 16 bit boundary.

My fix is to compute the number of bytes to copy from the pixel width rather than just using the pitch.

    int nBytesToCopy = ( bitmap->width + ppb - 1 ) / ppb;
    if ( bitmap->pitch > 0 )
    {
      for ( i = 0; i < bitmap->rows; i++ )
        FT_MEM_COPY( buffer + new_pitch * ( ypixels + i ),
                     bitmap->buffer + pitch * i, nBytesToCopy );
    }
    else
    {
      for ( i = 0; i < bitmap->rows; i++ )
        FT_MEM_COPY( buffer + new_pitch * i,
                     bitmap->buffer + pitch * i, nBytesToCopy );
    }

What do you think ?

- Ted Packard





_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to