From 0aaf1f20817cace6162a12ead9d74f99d38dff6a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 13 Jul 2014 11:14:17 -0400 Subject: 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 --- 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); + } } } } -- cgit v0.9.1