summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-07-13 11:14:17 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-07-13 11:15:22 (EDT)
commit0aaf1f20817cace6162a12ead9d74f99d38dff6a (patch)
treec481b3a003bcb9733865f4c7106803110bdd05ad
parentc29bc6055375ceb9e7e71c79b04b8adc777cf190 (diff)
parse_bdf_2_1(): Fix negative bit shift offset
If the font width minus the left margin is greater than the number of bits needed for the character plus the character's x offset, the bit shift offset will be negative. For example, with a font width of 17, left margin of 2, character width of 2 bytes, and character x offset of 1, the following happens: x = (font_bbox_w + font_bbox_x) - figure_margin - (bytes_w * 8 + char_bbox_x) x = (17 + 0) - 2 - (2 * 8 + 1) x = -2
-rwxr-xr-xbin/bdf2fbcon9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/bdf2fbcon b/bin/bdf2fbcon
index b2d8d18..de01179 100755
--- a/bin/bdf2fbcon
+++ b/bin/bdf2fbcon
@@ -275,8 +275,13 @@ sub parse_bdf_2_1
if ($stmt eq 'ENDCHAR') {
$section = BDF_2_1_SECTION_NONE;
} else {
- $font->{'chars'}[$encoding]->{'bitmap'}[$y++] =
- hex($line) << $x;
+ if ($x ge 0) {
+ $font->{'chars'}[$encoding]->{'bitmap'}[$y++] =
+ hex($line) << $x;
+ } else {
+ $font->{'chars'}[$encoding]->{'bitmap'}[$y++] =
+ hex($line) >> (0 - $x);
+ }
}
}
}