summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-12-16 15:52:31 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-12-16 15:52:31 +0000
commit788cfa1b3dceba5011fd793a4743401a6c872e40 (patch)
treee32057f2c4c3429c9329a1c7b21f04cf994d7eed
parent5583be94a9bdb6c3fc0c5b8869486ff15f0435af (diff)
Better sti_mapchar() implementation, matches Latin char indexes to HP Roman
font indicies whenever possible.
-rw-r--r--sys/dev/ic/sti.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/sys/dev/ic/sti.c b/sys/dev/ic/sti.c
index baa164462ff..1afdcd29872 100644
--- a/sys/dev/ic/sti.c
+++ b/sys/dev/ic/sti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sti.c,v 1.47 2006/11/29 19:08:22 miod Exp $ */
+/* $OpenBSD: sti.c,v 1.48 2006/12/16 15:52:30 miod Exp $ */
/*
* Copyright (c) 2000-2003 Michael Shalayeff
@@ -896,16 +896,63 @@ sti_cursor(v, on, row, col)
fp->height, fp->width, bmf_invert);
}
+/*
+ * ISO 8859-1 part of Unicode to HP Roman font index conversion array.
+ */
+static const u_int8_t
+sti_unitoroman[0x100 - 0xa0] = {
+ 0xa0, 0xb8, 0xbf, 0xbb, 0xba, 0xbc, 0, 0xbd,
+ 0xab, 0, 0xf9, 0xfb, 0, 0xf6, 0, 0xb0,
+
+ 0xb3, 0xfe, 0, 0, 0xa8, 0xf3, 0xf4, 0xf2,
+ 0, 0, 0xfa, 0xfd, 0xf7, 0xf8, 0, 0xb9,
+
+ 0xa1, 0xe0, 0xa2, 0xe1, 0xd8, 0xd0, 0xd3, 0xb4,
+ 0xa3, 0xdc, 0xa4, 0xa5, 0xe6, 0xe5, 0xa6, 0xa7,
+
+ 0xe3, 0xb6, 0xe8, 0xe7, 0xdf, 0xe9, 0xda, 0,
+ 0xd2, 0xad, 0xed, 0xae, 0xdb, 0xb1, 0xf0, 0xde,
+
+ 0xc8, 0xc4, 0xc0, 0xe2, 0xcc, 0xd4, 0xd7, 0xb5,
+ 0xc9, 0xc5, 0xc1, 0xcd, 0xd9, 0xd5, 0xd1, 0xdd,
+
+ 0xe4, 0xb7, 0xca, 0xc6, 0xc2, 0xea, 0xce, 0,
+ 0xd6, 0xcb, 0xc7, 0xc3, 0xcf, 0xb2, 0xf1, 0xef
+};
+
int
sti_mapchar(v, uni, index)
void *v;
int uni;
u_int *index;
{
- if (uni < 256)
- *index = uni;
+ struct sti_screen *scr = v;
+ struct sti_font *fp = &scr->scr_curfont;
+ int c;
+
+ switch (fp->type) {
+ case STI_FONT_HPROMAN8:
+ if (uni >= 0x80 && uni < 0xa0)
+ c = -1;
+ else if (uni >= 0xa0 && uni < 0x100) {
+ c = (int)sti_unitoroman[uni - 0xa0];
+ if (c == 0)
+ c = -1;
+ } else
+ c = uni;
+ break;
+ default:
+ c = uni;
+ break;
+ }
+
+ if (c == -1 || c < fp->first || c > fp->last) {
+ *index = ' ';
+ return (0);
+ }
- return 1;
+ *index = c;
+ return (5);
}
void