Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev wsfb: Prefer wide fonts when EDID data is available.



details:   https://anonhg.NetBSD.org/src/rev/649b78c0375a
branches:  trunk
changeset: 1029177:649b78c0375a
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Dec 24 18:12:58 2021 +0000

description:
wsfb: Prefer wide fonts when EDID data is available.

To give us a better chance of picking a readable font, prefer fonts that
will render at least 3mm wide instead of picking the font that will be
closest to that size.

diffstat:

 sys/dev/rasops/rasops.c |   6 ++++--
 sys/dev/rasops/rasops.h |   6 +++++-
 sys/dev/wsfb/genfb.c    |  14 +++++++++-----
 sys/dev/wsfont/wsfont.c |  17 ++++++++++++-----
 sys/dev/wsfont/wsfont.h |   3 ++-
 5 files changed, 32 insertions(+), 14 deletions(-)

diffs (155 lines):

diff -r 0ae4c8500cdd -r 649b78c0375a sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c   Fri Dec 24 15:26:35 2021 +0000
+++ b/sys/dev/rasops/rasops.c   Fri Dec 24 18:12:58 2021 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rasops.c,v 1.124 2021/10/04 12:26:29 rin Exp $        */
+/*      $NetBSD: rasops.c,v 1.125 2021/12/24 18:12:58 jmcneill Exp $   */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.124 2021/10/04 12:26:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.125 2021/12/24 18:12:58 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_rasops.h"
@@ -264,6 +264,8 @@
                        flags |= WSFONT_FIND_ALPHA;
                if ((ri->ri_flg & RI_PREFER_ALPHA) != 0)
                        flags |= WSFONT_PREFER_ALPHA;
+               if ((ri->ri_flg & RI_PREFER_WIDEFONT) != 0)
+                       flags |= WSFONT_PREFER_WIDE;
                cookie = wsfont_find(NULL,
                        ri->ri_width / wantcols,
                        0,
diff -r 0ae4c8500cdd -r 649b78c0375a sys/dev/rasops/rasops.h
--- a/sys/dev/rasops/rasops.h   Fri Dec 24 15:26:35 2021 +0000
+++ b/sys/dev/rasops/rasops.h   Fri Dec 24 18:12:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rasops.h,v 1.49 2019/11/02 01:14:57 tsutsui Exp $ */
+/*     $NetBSD: rasops.h,v 1.50 2021/12/24 18:12:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -70,6 +70,10 @@
  * use alpha fonts
  */ 
 #define RI_PREFER_ALPHA        0x4000
+/*
+ * Set this to prefer a wider font.
+ */
+#define RI_PREFER_WIDEFONT     0x8000
 
 struct rasops_info {
        /* These must be filled in by the caller */
diff -r 0ae4c8500cdd -r 649b78c0375a sys/dev/wsfb/genfb.c
--- a/sys/dev/wsfb/genfb.c      Fri Dec 24 15:26:35 2021 +0000
+++ b/sys/dev/wsfb/genfb.c      Fri Dec 24 18:12:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfb.c,v 1.84 2021/08/30 22:47:25 jmcneill Exp $ */
+/*     $NetBSD: genfb.c,v 1.85 2021/12/24 18:12:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.84 2021/08/30 22:47:25 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.85 2021/12/24 18:12:58 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -81,7 +81,7 @@
 
 static void    genfb_init_screen(void *, struct vcons_screen *, int, long *);
 static int     genfb_calc_hsize(struct genfb_softc *);
-static int     genfb_calc_cols(struct genfb_softc *);
+static int     genfb_calc_cols(struct genfb_softc *, struct rasops_info *);
 
 static int     genfb_putcmap(struct genfb_softc *, struct wsdisplay_cmap *);
 static int     genfb_getcmap(struct genfb_softc *, struct wsdisplay_cmap *);
@@ -638,7 +638,7 @@
                break;
        }
 
-       wantcols = genfb_calc_cols(sc);
+       wantcols = genfb_calc_cols(sc, ri);
 
        rasops_init(ri, 0, wantcols);
        ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
@@ -687,10 +687,14 @@
 
 /* Return the minimum number of character columns based on DPI */
 static int
-genfb_calc_cols(struct genfb_softc *sc)
+genfb_calc_cols(struct genfb_softc *sc, struct rasops_info *ri)
 {
        const int hsize = genfb_calc_hsize(sc);
 
+       if (hsize != 0) {
+               ri->ri_flg |= RI_PREFER_WIDEFONT;
+       }
+
        return MAX(RASOPS_DEFAULT_WIDTH, hsize / GENFB_CHAR_WIDTH_MM);
 }
 
diff -r 0ae4c8500cdd -r 649b78c0375a sys/dev/wsfont/wsfont.c
--- a/sys/dev/wsfont/wsfont.c   Fri Dec 24 15:26:35 2021 +0000
+++ b/sys/dev/wsfont/wsfont.c   Fri Dec 24 18:12:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsfont.c,v 1.76 2021/11/20 08:16:30 rin Exp $  */
+/*     $NetBSD: wsfont.c,v 1.77 2021/12/24 18:12:58 jmcneill Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.76 2021/11/20 08:16:30 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.77 2021/12/24 18:12:58 jmcneill Exp $");
 
 #include "opt_wsfont.h"
 
@@ -610,10 +610,17 @@
                        if (font->fontwidth != width)
                                return (0);
                } else {
-                       if (font->fontwidth > width)
-                               score -= 10000 + uimin(font->fontwidth - width, 9999);
-                       else
+                       if (font->fontwidth > width) {
+                               score -= uimin(font->fontwidth - width, 9999);
+                               if ((flags & WSFONT_PREFER_WIDE) == 0) {
+                                       score -= 10000;
+                               }
+                       } else {
                                score -= uimin(width - font->fontwidth, 9999);
+                               if ((flags & WSFONT_PREFER_WIDE) != 0) {
+                                       score -= 10000;
+                               }
+                       }
                }
        }
 
diff -r 0ae4c8500cdd -r 649b78c0375a sys/dev/wsfont/wsfont.h
--- a/sys/dev/wsfont/wsfont.h   Fri Dec 24 15:26:35 2021 +0000
+++ b/sys/dev/wsfont/wsfont.h   Fri Dec 24 18:12:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsfont.h,v 1.26 2016/11/20 15:44:40 macallan Exp $     */
+/*     $NetBSD: wsfont.h,v 1.27 2021/12/24 18:12:58 jmcneill Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -67,6 +67,7 @@
 #define WSFONT_FIND_ALL                0xff
 #define WSFONT_FIND_BESTWIDTH  0x1000
 #define WSFONT_PREFER_ALPHA    0x2000
+#define WSFONT_PREFER_WIDE     0x8000
 
 void   wsfont_walk(void (*)(struct wsdisplay_font *, void *, int), void *);
 



Home | Main Index | Thread Index | Old Index