Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 May 2000 23:56:18 +0200 (CEST)
From:      hmo@sep.hamburg.com (Helge Oldach)
To:        bryanh@giraffe-data.com
Cc:        ports@freebsd.org
Subject:   netpbm-8.4
Message-ID:  <200005032156.XAA86671@sep.hamburg.com>

next in thread | raw e-mail | index | archive | help

--ELM957390978-85015-0_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Bryan,

pbmtext doesn't handle characters below 0x20 or above 0x7f very well -
they are just replaced by spaces. This is caused by a sign promotion
issue. Attached is a fix for pbmtext.c, making it look into the selected
font whether a specific character is present or not (and only if it
isn't replace it by a space), and correctly handle character codes 0x01
upto 0xff.

Interestingly the built-in "bdf" font (which actually is pbmtext's
default font!) already contains full ISO-8859-1 encoding, but that could
never be used...

Tested on FreeBSD 3.4-STABLE, though it should certainly work on any
decent platform. (FreeBSD port maintainer, please feed this into a patch
file and cvs it.)

Regards,
Helge

--ELM957390978-85015-0_
Content-Type: text/plain; charset=ISO-8859-1
Content-Disposition: attachment; filename=patch-hmo-1
Content-Description: ../../patches/patch-hmo-1
Content-Transfer-Encoding: 7bit

--- pbm/pbmtext.c.orig	Sun Mar 19 05:11:47 2000
+++ pbm/pbmtext.c	Wed May  3 23:32:21 2000
@@ -15,7 +15,7 @@
 #include "pbm.h"
 #include "pbmfont.h"
 
-static void fix_control_chars ARGS(( char* buf ));
+static void fix_control_chars ARGS(( unsigned char* buf, struct font* fn ));
 static void fill_rect ARGS(( bit** bits, int row0, int col0, int height, int width, bit color ));
 
 int
@@ -34,7 +34,7 @@
     struct glyph* glyph;
     int lines, maxlines, line;
     int maxwidth, maxleftb;
-    char* cp;
+    unsigned char* cp;
     char* usage = "[-font <fontfile>] [-builtin <fontname>] [text]";
 
     pbm_init( &argc, argv );
@@ -95,7 +95,7 @@
 	    (void) strcat( buf, argv[argn] );
 	    ++argn;
 	    }
-	fix_control_chars( buf );
+	fix_control_chars( buf, fn );
 	lp[0] = buf;
 	lines = 1;
 	}
@@ -106,7 +106,7 @@
 	    {
 	    int l;
 
-	    fix_control_chars( buf );
+	    fix_control_chars( buf, fn );
 	    l = strlen( buf );
 	    if ( lines >= maxlines )
 		{
@@ -143,7 +143,7 @@
     for ( line = 0; line < lines; ++line ) {
 	int x = 0;
 	int bwid = 0;
-	char lastch;
+	unsigned char lastch;
     int isfirst;   /* logical */
     
     isfirst = 1;   /* initial assumption */
@@ -211,8 +211,9 @@
     }
 
 static void
-fix_control_chars( buf )
-    char* buf;
+fix_control_chars( buf, fn )
+    unsigned char* buf;
+    struct font* fn;
     {
     int i, j, n, l;
 
@@ -228,8 +229,8 @@
 		buf[i] = ' ';
 	    --i;
 	    }
-	else if ( buf[i] < ' ' || buf[i] > '~' )
-	    /* Turn other control chars into a single space. */
+	else if ( !fn->glyph[(int)buf[i]] )
+	    /* Turn unknown chars into a single space. */
 	    buf[i] = ' ';
 	}
     }

--ELM957390978-85015-0_--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005032156.XAA86671>