Module Name: src Committed By: rin Date: Wed Aug 7 12:27:49 UTC 2019
Modified Files: src/sys/dev/rasops: rasops.c rasops1.c rasops1_putchar_width.h rasops_putchar_width.h Log Message: Scaling dimensions of underline by font height. Currently, - offset of underline is fixed to 1-row from bottom of characters, and - height of underline is fixed to 1. Both are good for standard 8x16 fonts. However, it is too thin for larger fonts, especially when used on display of high resolution. Also, 1-row offset of underline is ugly for small fonts, e.g., spleen5x8. Therefore, adjust offset and height as, - no changes for standard 16-height fonts. - scaling by font height for larger fonts. - set offset to zero for fonts of height smaller than 16. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/dev/rasops/rasops.c cvs rdiff -u -r1.34 -r1.35 src/sys/dev/rasops/rasops1.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/rasops/rasops1_putchar_width.h cvs rdiff -u -r1.11 -r1.12 src/sys/dev/rasops/rasops_putchar_width.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/rasops/rasops.c diff -u src/sys/dev/rasops/rasops.c:1.116 src/sys/dev/rasops/rasops.c:1.117 --- src/sys/dev/rasops/rasops.c:1.116 Wed Aug 7 11:57:40 2019 +++ src/sys/dev/rasops/rasops.c Wed Aug 7 12:27:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops.c,v 1.116 2019/08/07 11:57:40 rin Exp $ */ +/* $NetBSD: rasops.c,v 1.117 2019/08/07 12:27:49 rin Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.116 2019/08/07 11:57:40 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.117 2019/08/07 12:27:49 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_rasops.h" @@ -332,7 +332,7 @@ rasops_init(struct rasops_info *ri, int int rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols) { - int bpp, s; + int bpp, height, s; size_t len; s = splhigh(); @@ -483,6 +483,11 @@ rasops_reconfig(struct rasops_info *ri, } else ri->ri_xorigin = ri->ri_yorigin = 0; + /* Scaling underline by font height */ + height = ri->ri_font->fontheight; + ri->ri_ul.off = rounddown(height, 16) / 16; /* offset from bottom */ + ri->ri_ul.height = roundup(height, 16) / 16; /* height */ + /* * Fill in defaults for operations set. XXX this nukes private * routines used by accelerated fb drivers. Index: src/sys/dev/rasops/rasops1.c diff -u src/sys/dev/rasops/rasops1.c:1.34 src/sys/dev/rasops/rasops1.c:1.35 --- src/sys/dev/rasops/rasops1.c:1.34 Fri Aug 2 04:39:09 2019 +++ src/sys/dev/rasops/rasops1.c Wed Aug 7 12:27:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $ */ +/* $NetBSD: rasops1.c,v 1.35 2019/08/07 12:27:49 rin Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.35 2019/08/07 12:27:49 rin Exp $"); #include "opt_rasops.h" @@ -170,12 +170,18 @@ rasops1_putchar(void *cookie, int row, i /* Do underline */ if ((attr & WSATTR_UNDERLINE) != 0) { - DELTA(rp, -(ri->ri_stride << 1), uint32_t *); - tmp = (*rp & lmask) | (fg & rmask); - *rp = tmp; - if (ri->ri_hwbits) { - DELTA(hp, -(ri->ri_stride << 1), uint32_t *); - *hp = tmp; + DELTA(rp, - ri->ri_stride * ri->ri_ul.off, uint32_t *); + if (ri->ri_hwbits) + DELTA(hp, - ri->ri_stride * ri->ri_ul.off, + uint32_t *); + for (height = ri->ri_ul.height; height; height--) { + DELTA(rp, - ri->ri_stride, uint32_t *); + tmp = (*rp & lmask) | (fg & rmask); + *rp = tmp; + if (ri->ri_hwbits) { + DELTA(hp, - ri->ri_stride, uint32_t *); + *hp = tmp; + } } } } else { @@ -223,15 +229,21 @@ rasops1_putchar(void *cookie, int row, i /* Do underline */ if ((attr & WSATTR_UNDERLINE) != 0) { - DELTA(rp, -(ri->ri_stride << 1), uint32_t *); - tmp0 = (rp[0] & lmask) | (fg & ~lmask); - tmp1 = (rp[1] & rmask) | (fg & ~rmask); - rp[0] = tmp0; - rp[1] = tmp1; - if (ri->ri_hwbits) { - DELTA(hp, -(ri->ri_stride << 1), uint32_t *); - hp[0] = tmp0; - hp[1] = tmp1; + DELTA(rp, - ri->ri_stride * ri->ri_ul.off, uint32_t *); + if (ri->ri_hwbits) + DELTA(hp, - ri->ri_stride * ri->ri_ul.off, + uint32_t *); + for (height = ri->ri_ul.height; height; height--) { + DELTA(rp, - ri->ri_stride, uint32_t *); + tmp0 = (rp[0] & lmask) | (fg & ~lmask); + tmp1 = (rp[1] & rmask) | (fg & ~rmask); + rp[0] = tmp0; + rp[1] = tmp1; + if (ri->ri_hwbits) { + DELTA(hp, - ri->ri_stride, uint32_t *); + hp[0] = tmp0; + hp[1] = tmp1; + } } } } Index: src/sys/dev/rasops/rasops1_putchar_width.h diff -u src/sys/dev/rasops/rasops1_putchar_width.h:1.3 src/sys/dev/rasops/rasops1_putchar_width.h:1.4 --- src/sys/dev/rasops/rasops1_putchar_width.h:1.3 Wed Aug 7 11:13:20 2019 +++ src/sys/dev/rasops/rasops1_putchar_width.h Wed Aug 7 12:27:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops1_putchar_width.h,v 1.3 2019/08/07 11:13:20 rin Exp $ */ +/* $NetBSD: rasops1_putchar_width.h,v 1.4 2019/08/07 12:27:49 rin Exp $ */ /* NetBSD: rasops1.c,v 1.28 2019/07/25 03:02:44 rin Exp */ /*- @@ -119,11 +119,16 @@ PUTCHAR_WIDTH(RASOPS_WIDTH)(void *cookie /* Do underline */ if ((attr & WSATTR_UNDERLINE) != 0) { - DELTA(rp, -(ri->ri_stride << 1), COPY_UNIT *); - *rp = fg; - if (ri->ri_hwbits) { - DELTA(hp, -(ri->ri_stride << 1), COPY_UNIT *); - *hp = fg; + DELTA(rp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *); + if (ri->ri_hwbits) + DELTA(hp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *); + for (height = ri->ri_ul.height; height; height--) { + DELTA(rp, - ri->ri_stride, COPY_UNIT *); + *rp = fg; + if (ri->ri_hwbits) { + DELTA(hp, - ri->ri_stride, COPY_UNIT *); + *hp = fg; + } } } } Index: src/sys/dev/rasops/rasops_putchar_width.h diff -u src/sys/dev/rasops/rasops_putchar_width.h:1.11 src/sys/dev/rasops/rasops_putchar_width.h:1.12 --- src/sys/dev/rasops/rasops_putchar_width.h:1.11 Wed Aug 7 11:47:33 2019 +++ src/sys/dev/rasops/rasops_putchar_width.h Wed Aug 7 12:27:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops_putchar_width.h,v 1.11 2019/08/07 11:47:33 rin Exp $ */ +/* $NetBSD: rasops_putchar_width.h,v 1.12 2019/08/07 12:27:49 rin Exp $ */ /* NetBSD: rasops8.c,v 1.41 2019/07/25 03:02:44 rin Exp */ /*- @@ -261,11 +261,17 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH /* Do underline */ if ((attr & WSATTR_UNDERLINE) != 0) { - DELTA(rp, -(ri->ri_stride << 1), STAMP_TYPE *); - SUBST_STAMP(FILLED_STAMP); - if (ri->ri_hwbits) { - DELTA(hp, -(ri->ri_stride << 1), STAMP_TYPE *); - memcpy(hp, rp, SUBST_BYTES); + DELTA(rp, - ri->ri_stride * ri->ri_ul.off, STAMP_TYPE *); + if (ri->ri_hwbits) + DELTA(hp, - ri->ri_stride * ri->ri_ul.off, + STAMP_TYPE *); + for (height = ri->ri_ul.height; height; height--) { + DELTA(rp, - ri->ri_stride, STAMP_TYPE *); + SUBST_STAMP(FILLED_STAMP); + if (ri->ri_hwbits) { + DELTA(hp, - ri->ri_stride, STAMP_TYPE *); + memcpy(hp, rp, SUBST_BYTES); + } } } }