Merge pull request #576 from adamharrison/fix-negative-pens

Fixed negative pens.
This commit is contained in:
Adam 2021-10-02 16:31:42 -04:00 committed by GitHub
commit 6264caffe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -236,7 +236,7 @@ float ren_draw_text(RenFont *font, const char *text, float x, int y, RenColor co
unsigned int codepoint, r, g, b; unsigned int codepoint, r, g, b;
text = utf8_to_codepoint(text, &codepoint); text = utf8_to_codepoint(text, &codepoint);
int bitmap_index = font->subpixel ? (int)(fmod(pen_x, 1.0) * SUBPIXEL_BITMAPS_CACHED) : 0; int bitmap_index = font->subpixel ? (int)(fmod(pen_x, 1.0) * SUBPIXEL_BITMAPS_CACHED) : 0;
GlyphSet* set = font_get_glyphset(font, codepoint, bitmap_index); GlyphSet* set = font_get_glyphset(font, codepoint, bitmap_index + (bitmap_index < 0 ? SUBPIXEL_BITMAPS_CACHED : 0));
GlyphMetric* metric = &set->metrics[codepoint % 256]; GlyphMetric* metric = &set->metrics[codepoint % 256];
int start_x = floor(pen_x) + metric->bitmap_left, end_x = metric->x1 - metric->x0 + pen_x; int start_x = floor(pen_x) + metric->bitmap_left, end_x = metric->x1 - metric->x0 + pen_x;
int glyph_end = metric->x1, glyph_start = metric->x0; int glyph_end = metric->x1, glyph_start = metric->x0;