Added custom fontset

This commit is contained in:
Jan-Bulthuis 2025-02-12 00:40:12 +01:00
parent 5995d1ea37
commit 2374c19a0f
4 changed files with 347 additions and 69 deletions

View File

@ -4,13 +4,13 @@
let let
overlay = final: prev: { overlay = final: prev: {
dina-psf = prev.callPackage ./fonts/dina-psf.nix { }; dina-psf = prev.callPackage ./fonts/dina-psf/default.nix { };
ttf2psf = prev.callPackage ./fonts/ttf2psf.nix { }; ttf2psf = prev.callPackage ./fonts/ttf2psf.nix { };
wqy-zenhei = prev.callPackage ./fonts/wqy-zenhei.nix { }; wqy-zenhei = prev.callPackage ./fonts/wqy-zenhei.nix { };
wqy-microhei = prev.callPackage ./fonts/wqy-microhei.nix { }; wqy-microhei = prev.callPackage ./fonts/wqy-microhei.nix { };
wqy-bitmapsong = prev.callPackage ./fonts/wqy-bitmapsong.nix { }; wqy-bitmapsong = prev.callPackage ./fonts/wqy-bitmapsong.nix { };
ly = prev.callPackage ./programs/ly/default.nix { }; # ly = prev.callPackage ./programs/ly/default.nix { };
}; };
in in
{ {

View File

@ -1,67 +0,0 @@
{
pkgs,
...
}:
pkgs.stdenv.mkDerivation {
pname = "dina-psfu";
version = "1.0.0";
unpackPhase = ''
true
'';
buildInputs = with pkgs; [
bdf2psf
fontforge
kbd
];
buildPhase = ''
# Get the base Dina font
cp ${pkgs.dina-font.bdf}/share/fonts/misc/Dina_r400-9.bdf ./dina.bdf
# Set the AVERAGE_WIDTH property on the font
sed 's/STARTPROPERTIES 16/STARTPROPERTIES 17\
AVERAGE_WIDTH 70/' ./dina.bdf > ./dina-enc.bdf
# # Reencode the font from code page CP1252 (Windows) to unicode
# fontforge -lang=ff -c "Open(\"dina-mod.bdf\"); Reencode(\"win\", 1); Reencode(\"iso10646-1\"); Generate(\"dina-enc.bdf\")"
# mv dina-enc-*.bdf dina-enc.bdf
# Convert the bdf to psf
bdf2psf --fb ./dina-enc.bdf \
${pkgs.bdf2psf}/share/bdf2psf/standard.equivalents \
${pkgs.bdf2psf}/share/bdf2psf/fontsets/Uni3.512 \
512 ./dina-enc.psfu ./dina.sfm
# Get the font table
psfgettable ./dina-enc.psfu ./dina.table
# Add some entries to the font table
echo "0x0e U+2518" >> ./dina.table
echo "0x0f U+2514" >> ./dina.table
echo "0x10 U+250c" >> ./dina.table
echo "0x11 U+2510" >> ./dina.table
echo "0x12 U+2500" >> ./dina.table
echo "0x13 U+2502" >> ./dina.table
echo "0x14 U+2524" >> ./dina.table
echo "0x15 U+2534" >> ./dina.table
echo "0x16 U+251c" >> ./dina.table
echo "0x17 U+252c" >> ./dina.table
echo "0x18 U+253c" >> ./dina.table
echo "0x19 U+2592" >> ./dina.table
# Rebuild the font
psfstriptable ./dina-enc.psfu ./dina-stripped.psfu
psfaddtable ./dina-stripped.psfu ./dina.table ./dina.psfu
# For debugging, get the table again
psfgettable ./dina.psfu ./dina-final.table
'';
installPhase = ''
install -Dm644 -t $out/debug *
install -Dm644 -t $out/share/consolefonts dina.psfu
'';
}

View File

@ -0,0 +1,257 @@
# Created from the ascii2u table in bdf2psf
U+00A0
U+25A0
U+00B2
U+207F
U+221A
U+00B7
U+2219
U+00B0
U+2248
U+00F7
U+2321
U+2320
U+2264
U+2265
U+00B1
U+2261
U+2229
U+03B5
U+03C6
U+221E
U+03B4
U+03A9
U+0398
U+03A6
U+03C4
U+00B5
U+03C3
U+03A3
U+03C0
U+0393
U+00DF
U+03B1
U+2580
U+2590
U+258C
U+2584
U+2588
U+250C
U+2518
U+256A
U+256B
U+2553
U+2552
U+2558
U+2559
U+2565
U+2564
U+2568
U+2567
U+256C
U+2550
U+2560
U+2566
U+2569
U+2554
U+255A
U+255F
U+255E
U+253C
U+2500
U+251C
U+252C
U+2534
U+2514
U+2510
U+255B
U+255C
U+255D
U+2557
U+2551
U+2563
U+2555
U+2556
U+2562
U+2561
U+2524
U+2502
U+2593
U+2592
U+2591
U+00BB
U+00AB
U+00A1
U+00BC
U+00BD
U+00AC
U+2310
U+00BF
U+00BA
U+00AA
U+00D1
U+00F1
U+00FA
U+00F3
U+00ED
U+00E1
U+0192
U+20A7
U+00A5
U+00A3
U+00A2
U+00DC
U+00D6
U+00FF
U+00F9
U+00FB
U+00F2
U+00F6
U+00F4
U+00C6
U+00E6
U+00C9
U+00C5
U+00C4
U+00EC
U+00EE
U+00EF
U+00E8
U+00EB
U+00EA
U+00E7
U+00E5
U+00E0
U+00E4
U+00E2
U+00E9
U+00FC
U+00C7
U+007F
U+007E
U+007D
U+007C
U+007B
U+007A
U+0079
U+0078
U+0077
U+0076
U+0075
U+0074
U+0073
U+0072
U+0071
U+0070
U+006F
U+006E
U+006D
U+006C
U+006B
U+006A
U+0069
U+0068
U+0067
U+0066
U+0065
U+0064
U+0063
U+0062
U+0061
U+0060
U+005F
U+005E
U+005D
U+005C
U+005B
U+005A
U+0059
U+0058
U+0057
U+0056
U+0055
U+0054
U+0053
U+0052
U+0051
U+0050
U+004F
U+004E
U+004D
U+004C
U+004B
U+004A
U+0049
U+0048
U+0047
U+0046
U+0045
U+0044
U+0043
U+0042
U+0041
U+0040
U+003F
U+003E
U+003D
U+003C
U+003B
U+003A
U+0039
U+0038
U+0037
U+0036
U+0035
U+0034
U+0033
U+0032
U+0031
U+0030
U+002F
U+002E
U+002D
U+002C
U+002B
U+002A
U+0029
U+0028
U+0027
U+0026
U+0025
U+0024
U+0023
U+0022
U+0021
U+0020
U+25bc
U+25b2
U+2194
U+221f
U+2190
U+2192
U+2193
U+2191
U+21a8
U+25ac
U+00a7
U+00b6
U+203c
U+2195
U+25c4
U+25ba
U+263c
U+266b
U+266a
U+2640
U+2642
U+25d9
U+25cb
U+25d8
U+2022
U+2660
U+2663
U+2666
U+2665
U+263b
U+263a
U+fffd

View File

@ -0,0 +1,88 @@
{
pkgs,
...
}:
pkgs.stdenv.mkDerivation {
pname = "dina-psfu";
version = "1.0.0";
src = pkgs.fetchzip {
url = "https://www.dcmembers.com/jibsen/download/61/?wpdmdl=61";
hash = "sha256-JK+vnOyhAbwT825S+WKbQuWgRrfZZHfyhaMQ/6ljO8s=";
extension = "zip";
stripRoot = false;
};
buildInputs = with pkgs; [
bdf2psf
fontforge
kbd
];
buildPhase = ''
# Get the base Dina font
# cp ${pkgs.dina-font.bdf}/share/fonts/misc/Dina_r400-9.bdf ./dina.bdf
cp BDF/Dina_r400-9.bdf ./dina.bdf
# Set the AVERAGE_WIDTH property on the font
sed 's/STARTPROPERTIES 16/STARTPROPERTIES 17\
AVERAGE_WIDTH 70/' ./dina.bdf > ./dina-enc.bdf
# # Reencode the font from code page CP1252 (Windows) to unicode
# fontforge -lang=ff -c "Open(\"dina-mod.bdf\"); Reencode(\"win\", 1); Reencode(\"iso10646-1\"); Generate(\"dina-enc.bdf\")"
# mv dina-enc-*.bdf dina-enc.bdf
# Create the fontset
head -n 256 ${pkgs.bdf2psf}/share/bdf2psf/fontsets/Uni1.512 > Uni1.256
# Create the fontset
cp ${./PC437.256} PC437.256
# Create the equivalents file
touch empty.equivalents
# # Convert the bdf to psf
# bdf2psf --fb ./dina-enc.bdf \
# ${pkgs.bdf2psf}/share/bdf2psf/standard.equivalents \
# ${pkgs.bdf2psf}/share/bdf2psf/fontsets/Lat2.256 \
# 256 ./dina-enc.psfu ./dina.sfm
# Convert the bdf to psf
bdf2psf --fb ./dina-enc.bdf \
./empty.equivalents \
./Uni1.256 \
256 ./dina-enc.psfu ./dina.sfm
# Get the font table
psfgettable ./dina-enc.psfu ./dina.table
# Add some entries to the font table
# echo "0x0e U+2518" >> ./dina.table
# echo "0x0f U+2514" >> ./dina.table
# echo "0x10 U+250c" >> ./dina.table
# echo "0x11 U+2510" >> ./dina.table
# echo "0x12 U+2500" >> ./dina.table
# echo "0x13 U+2502" >> ./dina.table
# echo "0x14 U+2524" >> ./dina.table
# echo "0x15 U+2534" >> ./dina.table
# echo "0x16 U+251c" >> ./dina.table
# echo "0x17 U+252c" >> ./dina.table
# echo "0x18 U+253c" >> ./dina.table
# echo "0x19 U+2592" >> ./dina.table
# Rebuild the font
psfstriptable ./dina-enc.psfu ./dina-stripped.psfu
psfaddtable ./dina-stripped.psfu ./dina.table ./dina.psfu
# For debugging, get the table again
psfgettable ./dina.psfu ./dina-final.table
${pkgs.psftools}/bin/psf2bdf ./dina.psfu ./dina-final.bdf
'';
installPhase = ''
install -Dm644 -t $out/debug ./*.*
install -Dm644 -t $out/debug/BDF ./BDF/*.*
install -Dm644 -t $out/share/consolefonts dina.psfu
'';
}