|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eo pipefail |
| 4 | +. /etc/functions |
| 5 | + |
| 6 | +TRACE "Under /bin/setconsolefont.sh" |
| 7 | + |
| 8 | +# If the board ships setfont, and the console size is >=1600 lines tall, |
| 9 | +# increase the console font size. |
| 10 | +if [ ! -x /bin/setfont ]; then |
| 11 | + DEBUG "Board does not ship setfont, not checking console font" |
| 12 | + exit 0 |
| 13 | +fi |
| 14 | + |
| 15 | +if [ ! -f /sys/class/graphics/fb0/virtual_size ]; then |
| 16 | + DEBUG "fb0 virtual size is not known" |
| 17 | + exit 0 |
| 18 | +fi |
| 19 | + |
| 20 | +CONSOLE_HEIGHT="$(cut -d, -f2 /sys/class/graphics/fb0/virtual_size)" |
| 21 | + |
| 22 | +# Deciding scale based on resolution is inherently heuristic, as the scale |
| 23 | +# really depends on resolution, physical size, how close the display is to the |
| 24 | +# user, and personal preference. |
| 25 | +# |
| 26 | +# fbwhiptail starts using 1.5x scale at 1350 lines, but we can only choose 1x |
| 27 | +# or 2x (without shipping more fonts). Err toward making the console too large |
| 28 | +# rather than too small and go to 2x at 1350 lines. |
| 29 | +if [ "$CONSOLE_HEIGHT" -ge 1350 ]; then |
| 30 | + DEBUG "Double console font size due to framebuffer height $CONSOLE_HEIGHT" |
| 31 | + # Double the default font size by reading it out, then applying it again |
| 32 | + # with setfont's -d option (double font size) |
| 33 | + setfont -O /tmp/default_font |
| 34 | + setfont -d /tmp/default_font |
| 35 | + rm /tmp/default_font |
| 36 | +else |
| 37 | + DEBUG "Keep default console font size due to framebuffer height $CONSOLE_HEIGHT" |
| 38 | +fi |
0 commit comments