X-Git-Url: https://eleni.mutantstargoat.com/git/?p=winnie;a=blobdiff_plain;f=src%2Ftext.cc;h=ca0bf0bc648928ab76b707ff28f7040d625c9d88;hp=78bbcafacafaeed926cc30f3836dcc08fb5178fd;hb=59cd3a77c4517e387f4c2e21e8b62a9017370116;hpb=695cf39b73ecc76cbbc39e54f844ae55f4a9f938 diff --git a/src/text.cc b/src/text.cc index 78bbcaf..ca0bf0b 100644 --- a/src/text.cc +++ b/src/text.cc @@ -75,15 +75,31 @@ static int draw_glyph(Pixmap *pixmap, int x, int y, char c) unsigned char *bmp_ptr = ft_bmp->buffer; unsigned char *pxm_ptr = pixmap->get_image() + (pixmap->get_width() * y + x) * 4; + Rect clipping_rect = get_clipping_rect(); + for(int i=0; irows; i++) { - for(int j=0; jwidth; j++) { - if(bmp_ptr[j]) { - int a = (int)bmp_ptr[j]; - pxm_ptr[4 * j] = (a * text_color[0] + pxm_ptr[4 * j] * (255 - a)) / 255; - pxm_ptr[4 * j + 1] = (a * text_color[1] + pxm_ptr[4 * j + 1] * (255 - a)) / 255; - pxm_ptr[4 * j + 2] = (a * text_color[2] + pxm_ptr[4 * j + 2] * (255 - a)) / 255; + int dest_y = i + y; + if(dest_y >= clipping_rect.y + clipping_rect.height) { + break; + } + + if(dest_y >= clipping_rect.y) { + for(int j=0; jwidth; j++) { + int dest_x = j + x; + + if(dest_x >= clipping_rect.x + clipping_rect.width) { + break; + } + + if(bmp_ptr[j] && dest_x >= clipping_rect.x) { + int a = (int)bmp_ptr[j]; + pxm_ptr[4 * j] = (a * text_color[0] + pxm_ptr[4 * j] * (255 - a)) / 255; + pxm_ptr[4 * j + 1] = (a * text_color[1] + pxm_ptr[4 * j + 1] * (255 - a)) / 255; + pxm_ptr[4 * j + 2] = (a * text_color[2] + pxm_ptr[4 * j + 2] * (255 - a)) / 255; + } } } + pxm_ptr += 4 * pixmap->get_width(); bmp_ptr += ft_bmp->pitch; }