# X coexisting with 80x25 virtual consoles



## Bill Evans at Mariposa (Oct 15, 2015)

On 10.2-RELEASE, I quickly discovered that if I bring up X and want to go to a virtual console by pressing, say `<Alt><F2>`, I need to place into /boot/loader.conf:


```
kern.vty=vt
```
I discovered an unpleasant side effect, though. When I go from X to a virtual console, I don't get the old-fashioned 80x25 screen any more; the characters are much smaller.  The closest I can get to restoring that look is:


```
vidcontrol -f vgarom-8x16
```
That gives me a pretty nice font; not as nice as what's native in the machine, but close enough.  But it's 80x33, not 80x25.  Is there a way to maybe adopt this font, but force there to be only 25 lines on the screen?


----------



## chrbr (Oct 15, 2015)

A section of vt(4) says

```
LOADER TUNABLES
  These settings can be entered at the loader(8) prompt or in
  loader.conf(5).

  hw.vga.textmode
  Set to 1 to use virtual terminals in text mode instead of graph‐
  ics mode.  Features that require graphics mode, like loadable
  fonts, will be disabled.
```
I have tried it some time ago and I am even not sure for what reason. I just remembered this option. May be it helps. Other sections describe how to select a different font. In a different thread not long ago, somebody recommended gallant. This could be a different solution.

EDIT: I have just tried the line below.

```
kern.vt.fb.default_mode="640x480"
```
It changes the resolution as expected. On my system it ends up with bigger letters. May be this is more close to an old fashioned screen. Please see https://wiki.freebsd.org/action/show/Newcons?action=show&redirect=VT for additional information.


----------



## Bill Evans at Mariposa (Oct 15, 2015)

The trick is to get into X, move to a virtual console, and still expect to see exactly 25 lines on the screen.

I tried all seven combinations of at least one of: specifying font `vgarom-8x16`; setting `hw.vga.textmode=1`; and setting `kern.vt.fb.default_mode="640x480"`. (And yes, I didn't forget the word "`set`" at the loader command prompt, but that would not have been a silly question.)  Nothing works so far.


----------



## Bill Evans at Mariposa (Oct 16, 2015)

I've found a workaround.  I still use kern.vty=vt, of course, but none of the rest of it.  Remember that the font I was using was vgarom-8x16.

What I did was to create a new font, slightly taller than vgarom-8x16.  One new font is all I needed, but I created several, in the spirit of exploration.

I downloaded the source code for the base release, and went to /usr/src/share/vt/fonts:

```
cecil-root:/usr/src/share/vt/fonts# ls -l
total 96
-rw------- 1 root wheel   411 2015-08-25 14:05:44 Makefile
-rw------- 1 root wheel 11762 2015-08-25 14:05:56 gallant.fnt.uu
-rw------- 1 root wheel 19834 2015-08-25 14:05:45 vgarom-8x14.hex
-rw------- 1 root wheel 22306 2015-08-25 14:05:44 vgarom-8x16.hex
-rw------- 1 root wheel 12850 2015-08-25 14:05:56 vgarom-8x8.hex
-rw------- 1 root wheel 11709 2015-08-25 14:05:44 vgarom-thin-8x16.hex
-rw------- 1 root wheel  5727 2015-08-25 14:05:45 vgarom-thin-8x8.hex
cecil-root:/usr/src/share/vt/fonts#
```
The beginning of file vgarom-8x16.hex looked like this:


```
cecil-root:/usr/src/share/vt/fonts# head vgarom-8x16.hex
# $FreeBSD: stable/10/share/vt/fonts/vgarom-8x16.hex 271333 2014-09-09 20:36:56Z emaste $
# Height: 16
# Width: 8
0000:00000000000000000000000000000000
0020:00000000000000000000000000000000
0021:0000183C3C3C18181800181800000000
0022:00666666240000000000000000000000
0023:0000006C6CFE6C6C6CFE6C6C00000000
0024:18187CC6C2C07C060686C67C18180000
0025:00000000C2C60C183060C68600000000
cecil-root:/usr/src/share/vt/fonts#
```
If you're familiar with the ASCII character set, you know that the space character is hex 20, the dollar sign is hex 24, and so on.  Let's take the line beginning with `0024:`, break it down, and look at the binary equivalent of each pair of hex digits.  For legibility, I've substituted periods for zeros:


```
18 ...11...
18 ...11...
7C .11111..
C6 11...11.
C2 11....1.
C0 11......
7C .11111..
06 .....11.
06 .....11.
86 1....11.
C6 11...11.
7C .11111..
18 ...11...
18 ...11...
00 ........
00 ........
```
  So you see that each pair of hex digits in the .hex data specifies a line of a character in the font.  If I wanted to add a line at the bottom of the character, I would just add another pair of hex digits.  Since I wanted a blank line (one the same color as the background), I would add 00.

First, for documentation, I changed the second line in the file.  Before and after:


```
# Height: 16
# Height: 17
```
Then for each data line in the file, I added two zeros.  Before and after:


```
0024:18187CC6C2C07C060686C67C18180000
0024:18187CC6C2C07C060686C67C1818000000
```
There are many, many lines to do this to, but vi (and, I would guess, emacs) makes this easy.  Then, staying in that same directory, I looked at the Makefile.  I added a new line to show the name of the new file:


```
# $FreeBSD: stable/10/share/vt/fonts/Makefile 271333 2014-09-09 20:36:56Z emaste $

FILES=  gallant.fnt \
        vgarom-8x8.fnt \
        vgarom-8x14.fnt \
        vgarom-8x16.fnt \
        vgarom-8x17.fnt \
        vgarom-thin-8x8.fnt \
        vgarom-thin-8x16.fnt

CLEANFILES+= ${FILES}
```
I made sure that the new line began with a tab, not a space.  Makefiles are funny that way.  I also made sure that there wasn't anything after the new "\", not even a space.  Then I did the `make` command.  I saw new files in the current directory, including vgarom-8x17.fnt.  I copied that file to /usr/share/vt/fonts, and made its permissions be 444.

Then I added this line to /etc/rc.conf:


```
allscreens_flags="-f vgarom-8x17"
```
Then I rebooted.  I started X, and then went to a virtual console.  There were no longer 30 lines on the screen, as there had been with vgarom-8x16, but 28.  Progress.

I rinsed and repeated; vgarom-8x18 yielded 26 lines on the screen.
vgarom-8x19 yielded 25 lines.  Success!  vgarom-8x20 would have yielded 24 lines.

Whew!


----------



## Bill Evans at Mariposa (Oct 18, 2015)

I have edited the title to remove the "SOLVED". I've proposed a workaround, but I'd really like to know whether there's a way to restrict the screen to 80x25 without messing with font size.


----------



## protocelt (Oct 18, 2015)

For what it's worth, if I have hw.vga.textmode=1 set in /boot/loader.conf, I get an 80x25 console exactly when switching from X to the console with whatever the default font is. I should also probably mention however that I'm using an Nvidia graphics card so no KMS drivers are active if that makes a difference.


----------



## Bill Evans at Mariposa (Oct 18, 2015)

protocelt said:


> For what it's worth, if I have hw.vga.textmode=1 set in /boot/loader.conf, I get an 80x25 console exactly when switching from X to the console with whatever the default font is.


I wish that would have worked for me. *:*(


----------



## wblock@ (Oct 18, 2015)

It does work, until X starts, anyway.  It lets vt(4) use the normal text mode, but starting X switches it to a graphics mode.  Presumably the ROM fonts could be copied out somewhere and converted to a usable format.  The card would still be in graphics mode, so the scrolling might be slower.  But it would look the same.


----------



## Bill Evans at Mariposa (Oct 18, 2015)

wblock@ said:


> until X starts



Aye, that's my problem. *:*(


----------

