Monday 1 August 2022

Make 6x13 -Misc-Fixed font working on Ubuntu 22.04

This post is about installing and using the X windows font 6x13 -Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1 on Ubuntu 20.04

 In Ubuntu 22.04 jammy a new problem appeared, Pango insert a 2 pixels space between the lines, making the terminal windows height increase of 48 pixels (24 lines). I don't know if it is a problem in Pango  or a problem in the font definition. Anyway I was lucky to found a workaround, here it is.

The procedure is close to the one I found for Ubuntu 20.04 at https://super-unix.com/ubuntu/ubuntu-how-to-activate-bitmap-fonts-on-20-04/ that worked great for 18.04 and 20.04 but showed this 2pixel gap in 22.04.

At that time we had to enable bitmap font and convert the font into OpenType Bitmap (otb) format. For 22.04 we must also tweak the font definition by moving all the characters 2 pixels up, at the level of the baseline. There is no more part of the character, like for the letter "g" below the baseline. This could be a problem when mixing the font with other fonts, but this is never happening in a terminal!

First enable the bitmap font in Ubuntu:

sudo rm /etc/fonts/conf.d/70-no-bitmaps.conf
sudo ln -s ../conf.avail/70-force-bitmaps.conf /etc/fonts/conf.d/
sudo dpkg-reconfigure fontconfig-config
sudo dpkg-reconfigure fontconfig

Download the font in BDF format :

wget https://opensource.apple.com/source/X11fonts/X11fonts-14/font-misc-misc/font-misc-misc-1.1.2/6x13.bdf

Then you must tweak the font, first by modifying its font name and then by moving character above the baseline.

sed -i 's/FAMILY_NAME.*/FAMILY_NAME "MyFixedTwo"/' 6x13.bdf
sed -i 's/FONT_DESCENT 2/FONT_DESCENT 0/g' 6x13.bdf
sed -i 's/FONT_ASCENT 11/FONT_ASCENT 13/g' 6x13.bdf
sed -i 's/FONTBOUNDINGBOX 6 13 0 -2/FONTBOUNDINGBOX 6 13 0 0/g' 6x13.bdf
sed -i 's/BBX 6 13 0 -2/BBX 6 13 0 0/g' 6x13.bdf

Finally we must convert the BDF font into the OTB format using fonttosfnt. Unfortunately the version provided with Ubuntu 22.04 is buggy, we need to install the last version from github and compile it.

sudo apt-get install build-essential xfonts-utils pkg-config libfreetype-dev libfontenc-dev x11proto-core-dev
git clone https://gitlab.freedesktop.org/xorg/app/fonttosfnt.git
cd fonttosfnt
./autogen.sh
./configure
make
cd ..
fonttosfnt/fonttosfnt -b -c -g 2 -m 2 -o myfixedtwo.otb 6x13.bdf

Install the new otb font:

sudo cp myfixedtwo.otb /usr/local/share/fonts
sudo dpkg-reconfigure fontconfig-config
sudo dpkg-reconfigure fontconfig
fc-list | grep otb


Start app, choose font, search for "myfixedtwo".

Monday 20 June 2022

Make your Viewranger last on android

 The last version of Viewranger 10.11.72 force you to move to Outdoor Active.

It is possible to continue to use a bit longer your Viewranger account and maybe use your offline stuff forever.

  • First uninstall Viewranger (don't remove your data)
  • Install a older version of Viewranger. Look on google for "apkmirror viewranger 10.11.50" and try do download the 14.54 MB apk file. You have to agree with some warning ....
  • Install the apk. If you have some problem maybe the apkmirror app could help you
  • Don't start viewranger yet!
  • Open Google play store, search for viewanger, when you are on the page of viewranger, you must click on the viewranger icon on the left to go deeper in the viewranger page and get the menu button (the 3 dots) on the right. Click on it and disable automatic update.
After that I was able to start viewranger, sign in and does everything as before.
I expect to not be able to sign-in anymore in the future .


Friday 14 November 2014

iwlist helper

This script filter helpful output from iwlist.
Use it this way:

# show-wifi wlan0 VOO_HOMESPOT last

#!/bin/sh

device=${1-wlan0}
essid=${2-}
last=${3}

filter()
{
    if [ -n "$essid" ] ; then
        grep -B 3 $essid | grep -v ^--
    else
        cat
    fi
}

iwlist $device scanning $last | egrep "ESSID:|Address:|Quality=|Channel:" | filter


linux: Autologin VOO_HOMESPOT free wifi


The goal is to connect to the VOO_HOMESPOT wifi network without login into the web browser.VOO_HOMESPOT the is the wifree wireless network of VOO in Belgium.

This should work with any linux using network-manager.

Just copy file below into /etc/NetworkManager/dispatcher.d/voo-homespot
make it executable and be sure root is the owner


chown root.root  /etc/NetworkManager/dispatcher.d/voo-homespot
chmod 700 /etc/NetworkManager/dispatcher.d/voo-homespot


Here is the script
#!/bin/sh

USERNAME=<YOUR VOO USERNAME>
PASSWORD=<YOUR VOO PASSWORD>

ESSID="VOO_HOMESPOT"
TARGET=http://www.google.com/
AUTH_URL=https://wifree.voo.be/authenticate.html

if iwconfig | grep -q $ESSID ; then
    wget -qO- --post-data="username=${USERNAME}&password=${PASSWORD}&rememberme=rememberme&accept=accept&target=${TARGET_URL}" $AUTH_URL | grep -q connected_success.png
   if [ $? -eq 0 ] ; then
       logger "connected to $ESSID "
   else
       logger "login to $ESSID failed"
   fi
else
   logger "not ${ESSID}, don't try to login"
fi

Tuesday 4 November 2014

Monospaced and fixed width fonts for programming and terminal

The best of all font ever for console and programming is the fixed size used in X windows :

  • 6x13 -Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1
Here is how I get it in my Ubuntu 14.04, following the greate article from pts.org  ( http://ptspts.blogspot.co.uk/2010/06/how-to-enable-bitmap-fonts-on-ubuntu.html )


$ wget -q -O - http://pts-mini-gpl.googlecode.com/svn/trunk/fonts/fixedsc.tgz |
       (cd / && sudo tar xzv)
$ sudo rm -f /etc/fonts/conf.d/70-{yes,no,force}-bitmaps.conf
$ if test -f /etc/fonts/conf.avail/70-force-bitmaps.conf
  then sudo ln -s {../conf.avail,/etc/fonts/conf.d}/70-force-bitmaps.conf
  else sudo ln -s {../conf.avail,/etc/fonts/conf.d}/70-yes-bitmaps.conf
  fi
$ sudo rm -f /var/cache/fontconfig/*
$ rm -rf "$HOME/.fontconfig"
$ sudo fc-cache
$ fc-cache

Then I select FixedSc size 10 for all my x-terminal. This works great with low res screen, but become more difficult to read with high definition one. Then I choose INCONSOLATA font for these displays. This font works well in all size, hinting and sub-pixel order. Other font looks better but then you have to tune the font rendering and maybe reduce

$ sudo apt-get install fonts-inconsolata

See some other fonts here :



Saturday 2 March 2013

create a vfat Grub2 boot floppy


Create a small Grub2 boot .iso using :


 grub-mkrescue --diet -o fd.iso

create some directories, names are important

mkdir -p mnt fdboot/boot /grub

mount the .iso and copy all files in /boot/grub/i386-pc into fdboot/boot /grub
Then create a fdboot/boot /grub/grub.cfg that match your need, for example :


set timeout=5
set default=0 # Set the default menu entry

menuentry "This is the floppy that will boot on first disk" {
   set root=(hd0)
   chainloader +1
   boot
}


If you want to create a real 1.44Mo floppy, you have to remove some file in fdboot/boot /grub.
I choose to create a 2.88Mo floppy, because VMware don't care about the size of the floppy :-)

Then cut&paste the script bellow adapt the 2880 and the -a to mach the size of your floppy and the version of your Grub2. 5760 means 2.88Mo, use 2880 for 1.44Mo floppy.

The run the scrip below. the scrip come from Robert at Re: [SOLVED] Re: Grub2 editable floppy?


#!/bin/sh
# Creates a vfat editable Grub2 boot floppy  (not a read-only ISO9660 one like grub-mkrescue)
#
# template folder ./fdboot/boot/grub  shall contain a grub2 tree like /boot/grub
#    including a grub.cfg,  stripped down to <= 1.4MB;
#    or a tree copy from a "grub-mkrescue [--diet] -o fd.iso" iso floppy
#       (and do "cd fdboot/boot/grub; mv i386-pc/* ." ! because the boot.img+bootdisk looks there)
#       ("--diet" unfortunately disappeared in v1.99)
#
# Note: used with Grub2 v1.98 and v1.99; v1.99 requires the "-a" flag in "grub-setup -a ..."

# output image filename
fdimg=fdb.fat

# script

umount mnt
losetup -d /dev/loop0

dd if=/dev/zero of=$fdimg count=5760
losetup /dev/loop0 $fdimg || exit 1
fdformat /dev/loop0
mkfs.vfat /dev/loop0 || exit 1
mount /dev/loop0 mnt || exit 1

##rm fdboot/boot/grub/i386-pc/efiemu.mod grcy_* ... strip off to 1.4MB  / create by "grub-mkrescue --diet ..."
cp -a fdboot/* mnt/  || exit 1
##cp /boot/grub/grub.cfg mnt/boot/grub/

cat > mnt/boot/grub/device.map <<EOF
EOF
##(fd0) /dev/fd0
##(hd0) /dev/sda
##(hd1) /dev/sdb

cp /boot/grub/boot.img mnt/boot/grub/ || exit 1

grub-mkimage -o mnt/boot/grub/core.img -O i386-pc biosdisk fat part_msdos || exit 1

# --force is needed to force blocklists (for core.img) on floppy:
##grub-setup --force -d mnt/boot/grub -m mnt/boot/grub/device.map /dev/loop0 || exit 1

# variant with -a required for Grub2 1.99+ :
grub-setup -a --force -d mnt/boot/grub -m mnt/boot/grub/device.map /dev/loop0 || exit 1

umount mnt
losetup -d /dev/loop0

# copy the image to virtual machine image folder
cp -a $fdimg /hptemp/boot/

echo Grub2 VFAT editable boot floppy image $fdimg created. Done.
echo TO MOUNT: mount -o loop $fdimg mnt
echo TO WRITE TO REAL FLOPPY: cp $fdimg /dev/fd0
##cp $fdimg /dev/fd0




Good luck, thanks Robert for this script.