SHARE
TWEET

Untitled

a guest Apr 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/gfx/drivers_font_renderer/stb_unicode.c b/gfx/drivers_font_renderer/stb_unicode.c
  2. index aa74e1b8f5..075490f577 100644
  3. --- a/gfx/drivers_font_renderer/stb_unicode.c
  4. +++ b/gfx/drivers_font_renderer/stb_unicode.c
  5. @@ -152,11 +152,22 @@ static const struct font_glyph *font_renderer_stb_unicode_get_glyph(
  6.     dst = (uint8_t*)self->atlas.buffer + atlas_slot->glyph.atlas_offset_x
  7.           + atlas_slot->glyph.atlas_offset_y * self->atlas.width;
  8.  
  9. -   stbtt_MakeGlyphBitmap(&self->info, dst, self->max_glyph_width, self->max_glyph_height,
  10. -         self->atlas.width, self->scale_factor, self->scale_factor, glyph_index);
  11. -
  12.     stbtt_GetGlyphHMetrics(&self->info, glyph_index, &advance_width, &left_side_bearing);
  13. -   stbtt_GetGlyphBox(&self->info, glyph_index, &x0, NULL, NULL, &y1);
  14. +   if (stbtt_GetGlyphBox(&self->info, glyph_index, &x0, NULL, NULL, &y1))
  15. +   {
  16. +      stbtt_MakeGlyphBitmap(&self->info, dst, self->max_glyph_width, self->max_glyph_height,
  17. +            self->atlas.width, self->scale_factor, self->scale_factor, glyph_index);
  18. +   }
  19. +   else
  20. +   {
  21. +      /* This means the glyph is empty. In this case, stbtt_MakeGlyphBitmap()
  22. +       * fills the corresponding region of the atlas buffer with garbage,
  23. +       * so just zero it */
  24. +      unsigned x, y;
  25. +      for (x = 0; x < self->max_glyph_width; x++)
  26. +         for (y = 0; y < self->max_glyph_height; y++)
  27. +            dst[x + (y * self->atlas.width)] = 0;
  28. +   }
  29.  
  30.     atlas_slot->glyph.width          = self->max_glyph_width;
  31.     atlas_slot->glyph.height         = self->max_glyph_height;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top