From e7ba0e5d74064fed307820c5a38f7c920cbc8e0d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 23 Feb 2019 10:23:47 +0100 Subject: [PATCH] Fixed issue-234 by enhancing the drawing algorithm. --- src/laybasic/laybasic/layGridNet.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index b7428c6f53..05845ac97d 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -350,8 +350,8 @@ class ImagePainter continue; } - const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height (); - for (unsigned int i = 0; i < ff.height (); ++i, ++dc) { + const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height () * ff.stride (); + for (unsigned int i = 0; i < ff.height (); ++i, dc += ff.stride ()) { int iy = y - ff.height () + i + 1; if (iy >= 0 || iy < mp_img->height ()) { @@ -359,10 +359,21 @@ class ImagePainter uint32_t *d = (uint32_t *) mp_img->scanLine (y - ff.height () + i); uint32_t m = 1; int ix = x; - for (unsigned int j = 0; j < ff.width (); ++j, m <<= 1, ++ix) { - if (*dc & m && ix >= 0 && ix < mp_img->width ()) { + const uint32_t *ds = dc; + + for (unsigned int j = 0; j < ff.width (); ++j, ++ix) { + + if ((*ds & m) && ix >= 0 && ix < mp_img->width ()) { d[ix] = c.rgb (); } + + m <<= 1; + // word wrap + if (m == 0) { + ++ds; + m = 1; + } + } }