bugThe FreeType Project - Bugs: bug #57668, FT_Glyph_To_Bitmap fails with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #57668: FT_Glyph_To_Bitmap fails with 'Raster_Overflow' after using FT_Glyph_StrokeBorder

Submitter:  Michael Yabooza <macdue>
Submitted:  Sun 26 Jan 2020 04:02:31 PM UTC
   
 
Severity:  3 - Normal Item Group:  None
Status:  Invalid Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Planned Release:  None

Fri 01 May 2020 10:42:31 PM UTC, comment #2: 

From my reading of C++, you are not supposed to pass nullptr as a function argument. That is different from NULL. Please reopen if you can crash with NULL. nullptr cannot be converted to integer and used in "if(!nullptr)". 


Alexei Podtelezhnikov <podtelez>
Group Member
Fri 31 Jan 2020 08:16:32 AM UTC, comment #1: 

To help us debug this issue please provide a very small stand-alone program that compiles out of the box, that runs on the console (it doesn't have to produce any graphical output), and that triggers the problem.

Alexei?

Werner LEMBERG <wl>
Group administrator
Sun 26 Jan 2020 04:02:31 PM UTC, original submission:  

This may not be a bug (but I've been unable to find any help or solution for several days).

I've been trying to draw some text with a stroke boarder with Freetype 2.10.1 & ran into an issue where `FT_Glyph_To_Bitmap' fails after using `FT_Glyph_StrokeBorder'.


void drawGlyph(
  FT_GlyphSlot& glyphSlot,
  cimg_t& image,
  int shiftX,
  int shiftY,
  unsigned char fontColor[] = NULL,
  FT_Stroker stroker = nullptr,
  unsigned char strokeColor[] = NULL
){
  shiftY -= tfpos2int(glyphSlot->metrics.horiBearingY);
  if (stroker != nullptr) {
    FT_Glyph glyph;
    if (FT_Get_Glyph(glyphSlot, &glyph) != 0) {
      puts("Can't get glyph!");
      return;
    }
    if (glyph->format != FT_GLYPH_FORMAT_OUTLINE) {
      puts("Can't stroke!");
      return;
    }
    if (FT_Glyph_StrokeBorder(&glyph, stroker, false, true) != 0) {
      puts("Stroke failed!");
      return;
    }
    if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, true) != 0) {
      puts("Bitmap failed!");
      return;
    }
    FT_BitmapGlyph bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(glyph);
    drawBitmap(bitmapGlyph->bitmap, image, shiftX, shiftY, strokeColor);
    FT_Done_Glyph(glyph);
  }
  // Drawing glyph without stroke works fine
  if (FT_Render_Glyph(glyphSlot, FT_RENDER_MODE_NORMAL) != 0) {
    return;
  }
  drawBitmap(glyphSlot->bitmap, image, shiftX, shiftY, fontColor);
}


The glyph slot is loaded earlier in the code with:

FT_Set_Pixel_Sizes(face, 0, heightText);
FT_GlyphSlot glyphSlot = face->glyph;
FT_Load_Char(face, symbol, FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP);


And the stroker is set as:

FT_Stroker_Set(m_stroker, 2 * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);


When attempting to render text with my (drawGlyph) function & a stroker passed to it will fail the to 'to bitmap' stage (i.e print "Bitmap failed!" and return).

I'm using this font: https://github.com/MacDue/DueUtil/raw/master/assets/fonts/Due_Robo.ttf

Michael Yabooza <macdue>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #48289:  benfont.ttf added by macdue (55KiB - font/ttf)
file #48290:  cimg_freetype.cpp added by macdue (4KiB - text/x-c++src)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by podtelez (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by macdue (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-01 podtelez StatusNeed Info Invalid
        Open/ClosedOpen Closed
    2020-01-31 wl StatusNone Need Info
    2020-01-26 macdue Attached File- Added benfont.ttf, #48289
        Attached File- Added cimg_freetype.cpp, #48290

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code