Wed Feb 24 18:33:45 2010 UTC ()
map some more punctuation to more or less good replacements in the IBM
character set


(drochner)
diff -r1.14 -r1.15 src/sys/dev/ic/pcdisplay_chars.c

cvs diff -r1.14 -r1.15 src/sys/dev/ic/pcdisplay_chars.c (expand / switch to unified diff)

--- src/sys/dev/ic/pcdisplay_chars.c 2010/02/10 19:45:30 1.14
+++ src/sys/dev/ic/pcdisplay_chars.c 2010/02/24 18:33:45 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcdisplay_chars.c,v 1.14 2010/02/10 19:45:30 drochner Exp $ */ 1/* $NetBSD: pcdisplay_chars.c,v 1.15 2010/02/24 18:33:45 drochner Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: pcdisplay_chars.c,v 1.14 2010/02/10 19:45:30 drochner Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: pcdisplay_chars.c,v 1.15 2010/02/24 18:33:45 drochner Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/bus.h> 35#include <sys/bus.h>
36 36
37#include <dev/ic/mc6845reg.h> 37#include <dev/ic/mc6845reg.h>
38#include <dev/ic/pcdisplayvar.h> 38#include <dev/ic/pcdisplayvar.h>
39 39
40#include <dev/wscons/unicode.h> 40#include <dev/wscons/unicode.h>
41 41
42#define CONTROL 1 /* XXX smiley */ 42#define CONTROL 1 /* XXX smiley */
43#define NOTPRINTABLE 4 /* diamond XXX watch out - not in ISO part! */ 43#define NOTPRINTABLE 4 /* diamond XXX watch out - not in ISO part! */
@@ -255,51 +255,61 @@ static const struct { @@ -255,51 +255,61 @@ static const struct {
255 {0x2663, 0x05}, /* BLACK CLUB SUIT */ 255 {0x2663, 0x05}, /* BLACK CLUB SUIT */
256 {0x2665, 0x03}, /* BLACK HEART SUIT */ 256 {0x2665, 0x03}, /* BLACK HEART SUIT */
257 {0x2666, 0x04}, /* BLACK DIAMOND SUIT */ 257 {0x2666, 0x04}, /* BLACK DIAMOND SUIT */
258 {0x266a, 0x0d}, /* EIGHTH NOTE */ 258 {0x266a, 0x0d}, /* EIGHTH NOTE */
259 {0x266b, 0x0e}, /* BEAMED EIGHTH NOTES */ 259 {0x266b, 0x0e}, /* BEAMED EIGHTH NOTES */
260}; 260};
261 261
262static const struct { 262static const struct {
263 u_int16_t uni; 263 u_int16_t uni;
264 u_char ibm; 264 u_char ibm;
265 int quality; 265 int quality;
266} replacements[] = { 266} replacements[] = {
267 {0x00af, 0x2d, 3}, /* MACRON -> - */ 267 {0x00af, 0x2d, 3}, /* MACRON -> - */
 268 {0x2010, 0x2d, 3}, /* HYPHEN -> - */
268 {0x2013, 0x2d, 3}, /* EN DASH -> - */ 269 {0x2013, 0x2d, 3}, /* EN DASH -> - */
 270 {0x2014, 0x2d, 3}, /* EM DASH -> - */
 271 {0x2018, 0x60, 3}, /* LEFT SINGLE QUOTATION MARK -> ` */
 272 {0x2019, 0x27, 3}, /* RIGHT SINGLE QUOTATION MARK -> ' */
 273 {0x201A, 0x2c, 3}, /* SINGLE LOW QUOTATION MARK -> , */
 274 {0x201c, 0x22, 3}, /* LEFT DOUBLE QUOTATION MARK -> " */
 275 {0x201d, 0x22, 3}, /* RIGHT DOUBLE QUOTATION MARK -> " */
 276 {0x2039, 0x3c, 3}, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK -> < */
 277 {0x203a, 0x3e, 3}, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -> > */
269 {0x221f, 0xc0, 3}, /* RIGHT ANGLE -> light up and right */ 278 {0x221f, 0xc0, 3}, /* RIGHT ANGLE -> light up and right */
270 {0x222a, 0x55, 3}, /* UNION -> U */ 279 {0x222a, 0x55, 3}, /* UNION -> U */
271 {0x223c, 0x7e, 3}, /* TILDE OPERATOR -> ~ */ 280 {0x223c, 0x7e, 3}, /* TILDE OPERATOR -> ~ */
272 {0x2308, 0xda, 3}, /* LEFT CEILING -> light down and right */ 281 {0x2308, 0xda, 3}, /* LEFT CEILING -> light down and right */
273 {0x2309, 0xbf, 3}, /* RIGHT CEILING -> light down and left */ 282 {0x2309, 0xbf, 3}, /* RIGHT CEILING -> light down and left */
274 {0x230a, 0xc0, 3}, /* LEFT FLOOR -> light up and right */ 283 {0x230a, 0xc0, 3}, /* LEFT FLOOR -> light up and right */
275 {0x230b, 0xd9, 3}, /* RIGHT FLOOR -> light up and left */ 284 {0x230b, 0xd9, 3}, /* RIGHT FLOOR -> light up and left */
276 {0x2329, 0x3c, 3}, /* LEFT-POINTING ANGLE BRACKET -> < */ 285 {0x2329, 0x3c, 3}, /* LEFT-POINTING ANGLE BRACKET -> < */
277 {0x232a, 0x3e, 3}, /* RIGHT-POINTING ANGLE BRACKET -> > */ 286 {0x232a, 0x3e, 3}, /* RIGHT-POINTING ANGLE BRACKET -> > */
278 {_e003U, 0x2d, 3}, /* scan 5 -> - */ 287 {_e003U, 0x2d, 3}, /* scan 5 -> - */
279 {_e005U, 0x5f, 3}, /* scan 9 -> _ */ 288 {_e005U, 0x5f, 3}, /* scan 9 -> _ */
280 {_e00bU, 0x7b, 3}, /* braceleftmid -> { */ 289 {_e00bU, 0x7b, 3}, /* braceleftmid -> { */
281 {_e00cU, 0x7d, 3}, /* bracerightmid -> } */ 290 {_e00cU, 0x7d, 3}, /* bracerightmid -> } */
282 {_e00fU, 0xd9, 3}, /* mirrored not sign? -> light up and left */ 291 {_e00fU, 0xd9, 3}, /* mirrored not sign? -> light up and left */
283 {0x00d7, 0x78, 2}, /* MULTIPLICATION SIGN -> x */ 292 {0x00d7, 0x78, 2}, /* MULTIPLICATION SIGN -> x */
284 {0x00d8, 0xe9, 2}, /* LATIN CAPITAL LETTER O WITH STROKE -> Theta */ 293 {0x00d8, 0xe9, 2}, /* LATIN CAPITAL LETTER O WITH STROKE -> Theta */
285 {0x00f8, 0xed, 2}, /* LATIN SMALL LETTER O WITH STROKE -> phi */ 294 {0x00f8, 0xed, 2}, /* LATIN SMALL LETTER O WITH STROKE -> phi */
286 {0x03a0, 0xe3, 2}, /* GREEK CAPITAL LETTER PI -> pi */ 295 {0x03a0, 0xe3, 2}, /* GREEK CAPITAL LETTER PI -> pi */
287 {0x03a5, 0x59, 2}, /* GREEK CAPITAL LETTER UPSILON -> Y */ 296 {0x03a5, 0x59, 2}, /* GREEK CAPITAL LETTER UPSILON -> Y */
288 {0x03b3, 0x59, 2}, /* GREEK SMALL LETTER GAMMA -> Y */ 297 {0x03b3, 0x59, 2}, /* GREEK SMALL LETTER GAMMA -> Y */
289 {0x03b8, 0xe9, 2}, /* GREEK SMALL LETTER THETA -> Theta */ 298 {0x03b8, 0xe9, 2}, /* GREEK SMALL LETTER THETA -> Theta */
290 {0x03bd, 0x76, 2}, /* GREEK SMALL LETTER NU -> v */ 299 {0x03bd, 0x76, 2}, /* GREEK SMALL LETTER NU -> v */
291 {0x03c9, 0x77, 2}, /* GREEK SMALL LETTER OMEGA -> w */ 300 {0x03c9, 0x77, 2}, /* GREEK SMALL LETTER OMEGA -> w */
292 {0x20ac, 0x45, 2}, /* EURO SIGN -> E */ 301 {0x20ac, 0x45, 2}, /* EURO SIGN -> E */
 302 {0x25cf, 0xf9, 2}, /* BLACK CIRCLE */
293 {_e002U, 0x2d, 2}, /* scan 3 -> - */ 303 {_e002U, 0x2d, 2}, /* scan 3 -> - */
294 {_e004U, 0x2d, 2}, /* scan 7 -> - */ 304 {_e004U, 0x2d, 2}, /* scan 7 -> - */
295 {_e007U, 0xda, 2}, /* bracelefttp -> light down and right */ 305 {_e007U, 0xda, 2}, /* bracelefttp -> light down and right */
296 {_e008U, 0xc0, 2}, /* braceleftbt -> light up and right */ 306 {_e008U, 0xc0, 2}, /* braceleftbt -> light up and right */
297 {_e009U, 0xbf, 2}, /* bracerighttp -> light down and left */ 307 {_e009U, 0xbf, 2}, /* bracerighttp -> light down and left */
298 {_e00aU, 0xd9, 2}, /* bracerighrbt -> light up and left */ 308 {_e00aU, 0xd9, 2}, /* bracerighrbt -> light up and left */
299 {_e00dU, 0x3c, 2}, /* inverted angle? -> < */ 309 {_e00dU, 0x3c, 2}, /* inverted angle? -> < */
300 {_e00eU, 0x3c, 2}, /* angle? -> < */ 310 {_e00eU, 0x3c, 2}, /* angle? -> < */
301 {_e00fU, 0xd9, 2}, /* mirrored not sign? -> light up and left */ 311 {_e00fU, 0xd9, 2}, /* mirrored not sign? -> light up and left */
302 {0x00a9, 0x63, 1}, /* COPYRIGHT SIGN -> c */ 312 {0x00a9, 0x63, 1}, /* COPYRIGHT SIGN -> c */
303 {0x00ae, 0x72, 1}, /* REGISTERED SIGN -> r */ 313 {0x00ae, 0x72, 1}, /* REGISTERED SIGN -> r */
304 {0x00b3, 0x33, 1}, /* SUPERSCRIPT THREE -> 3 */ 314 {0x00b3, 0x33, 1}, /* SUPERSCRIPT THREE -> 3 */
305 {0x00b9, 0x39, 1}, /* SUPERSCRIPT ONE -> 1 */ 315 {0x00b9, 0x39, 1}, /* SUPERSCRIPT ONE -> 1 */
@@ -340,26 +350,30 @@ static const struct { @@ -340,26 +350,30 @@ static const struct {
340 {0x0159, 0x72, 1}, /* LATIN SMALL LETTER R WITH CARON -> r */ 350 {0x0159, 0x72, 1}, /* LATIN SMALL LETTER R WITH CARON -> r */
341 {0x0160, 0x53, 1}, /* LATIN CAPITAL LETTER S WITH CARON -> S */ 351 {0x0160, 0x53, 1}, /* LATIN CAPITAL LETTER S WITH CARON -> S */
342 {0x0161, 0x73, 1}, /* LATIN SMALLLETTER S WITH CARON -> s */ 352 {0x0161, 0x73, 1}, /* LATIN SMALLLETTER S WITH CARON -> s */
343 {0x0164, 0x54, 1}, /* LATIN CAPITAL LETTER T WITH CARON -> T */ 353 {0x0164, 0x54, 1}, /* LATIN CAPITAL LETTER T WITH CARON -> T */
344 {0x0165, 0x74, 1}, /* LATIN SMALL LETTER T WITH CARON -> t */ 354 {0x0165, 0x74, 1}, /* LATIN SMALL LETTER T WITH CARON -> t */
345 {0x016c, 0x55, 1}, /* LATIN CAPITAL LETTER U WITH BREVE -> U */ 355 {0x016c, 0x55, 1}, /* LATIN CAPITAL LETTER U WITH BREVE -> U */
346 {0x016d, 0x75, 1}, /* LATIN SMALL LETTER U WITH BREVE -> u */ 356 {0x016d, 0x75, 1}, /* LATIN SMALL LETTER U WITH BREVE -> u */
347 {0x016e, 0x55, 1}, /* LATIN CAPITAL LETTER U WITH RING ABOVE -> U */ 357 {0x016e, 0x55, 1}, /* LATIN CAPITAL LETTER U WITH RING ABOVE -> U */
348 {0x016f, 0x75, 1}, /* LATIN SMALL LETTER U WITH RING ABOVE -> u */ 358 {0x016f, 0x75, 1}, /* LATIN SMALL LETTER U WITH RING ABOVE -> u */
349 {0x0170, 0x9a, 1}, /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ 359 {0x0170, 0x9a, 1}, /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
350 {0x0171, 0x81, 1}, /* LATIN SMALL LETTER U WITH DOUBLE ACUTE */ 360 {0x0171, 0x81, 1}, /* LATIN SMALL LETTER U WITH DOUBLE ACUTE */
351 {0x017d, 0x5a, 1}, /* LATIN CAPITAL LETTER Z WITH CARON -> Z */ 361 {0x017d, 0x5a, 1}, /* LATIN CAPITAL LETTER Z WITH CARON -> Z */
352 {0x017e, 0x7a, 1}, /* LATIN SMALL LETTER Z WITH CARON -> z */ 362 {0x017e, 0x7a, 1}, /* LATIN SMALL LETTER Z WITH CARON -> z */
 363 {0x201e, 0x22, 1}, /* DOUBLE LOW QUOTATION MARK -> " */
 364 {0x2026, 0x5f, 1}, /* HORIZONTAL ELLIPSIS -> _ */
 365 {0x25a1, 0xfe, 1}, /* WHITE SQUARE */
 366 {0x2606, 0x2a, 1}, /* WHITE STAR -> * */
353}; 367};
354 368
355int 369int
356pcdisplay_mapchar(void *id, int uni, unsigned int *index) 370pcdisplay_mapchar(void *id, int uni, unsigned int *index)
357{ 371{
358 u_int i; 372 u_int i;
359 373
360 if (uni < 128) { 374 if (uni < 128) {
361 *index = uni; 375 *index = uni;
362 return (5); 376 return (5);
363 } else if ((uni < 256) && (isomappings[uni - 128] != NOTPRINTABLE)) { 377 } else if ((uni < 256) && (isomappings[uni - 128] != NOTPRINTABLE)) {
364 *index = isomappings[uni - 128]; 378 *index = isomappings[uni - 128];
365 return (5); 379 return (5);