koron/bdf2ttf

invalid PostScript font name

Closed this issue ยท 9 comments

Hello,

I tried using bdf2ttf to transform the Tamzen font into TTF, but when I double-click on the resulting TTF file under Windows 7, an error dialog appears saying "Windows Font Viewer: The requested file ... is not a valid font file.". Similarly, I'm getting an error message when opening the resulting TTF file in FontForge under Linux: ๐Ÿ˜ž

FontForge error

In the above screenshot, that "|0003|" Unicode glyph at the end of the font name is suspicious. :suspect:

Steps to reproduce the bug

$ mkdir -p ~/.fonts/tamzen-font

$ git clone https://github.com/sunaku/tamzen-font ~/.fonts/tamzen-font

$ cd ~/.fonts/tamzen-font

$ git checkout bdf2ttf

$ cat ttf/TamzenForPowerline.ini
Fontname = TamzenForPowerline
Version = 1.11.5
Copyright = Copyright
Trademark = Trademark

$ bdf2ttf ttf/TamzenForPowerline-regular.ttf ttf/TamzenForPowerline.ini bdf/TamzenForPowerline*r.bdf
Input files:
  bdf/TamzenForPowerline5x9r.bdf
  bdf/TamzenForPowerline6x12r.bdf
  bdf/TamzenForPowerline7x13r.bdf
  bdf/TamzenForPowerline7x14r.bdf
  bdf/TamzenForPowerline8x15r.bdf
  bdf/TamzenForPowerline8x16r.bdf
  bdf/TamzenForPowerline10x20r.bdf

$ bdf2ttf -b ttf/TamzenForPowerline-bold.ttf ttf/TamzenForPowerline.ini bdf/TamzenForPowerline*b.bdf
Input files:
  bdf/TamzenForPowerline5x9b.bdf
  bdf/TamzenForPowerline6x12b.bdf
  bdf/TamzenForPowerline7x13b.bdf
  bdf/TamzenForPowerline7x14b.bdf
  bdf/TamzenForPowerline8x15b.bdf
  bdf/TamzenForPowerline8x16b.bdf
  bdf/TamzenForPowerline10x20b.bdf

$ fontforge ttf/TamzenForPowerline-regular.ttf
... now observe the error shown in the screenshot above ...

Thanks for your consideration. ๐Ÿ˜…

koron commented

I can't reproduce your problem, but get font files attached. Please check this.
TamzenForPowerline.zip
It seems correct font files for me.

I have compiled bdf2ttf by MSVC10's 32bit compiler on WIndows 10,
converted and checked result TTF files on same machine.

Thanks! ๐Ÿ‘ Your generated fonts worked successfully in Linux FontForge and Windows 7. ๐Ÿ’ฏ

I should have mentioned that I compiled and ran bdf2ttf under Linux, using make gcc target.
So there appears to be some functional difference between the results of MSVC and GCC. ๐Ÿ›

For your reference, here is my GCC information and compilation output:

$ gcc --version
gcc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make gcc-clean
make -f compile/Make_gcc.mak clean
make[1]: Entering directory '/home/sunny/lab/bdf2ttf'
rm -f ./src/bdf.o ./src/bdf2ttf.o ./src/main.o ./src/rcfile.o ./src/table.o ./src/ucsconv.o
make[1]: Leaving directory '/home/sunny/lab/bdf2ttf'

$ make gcc
make -f compile/Make_gcc.mak
make[1]: Entering directory '/home/sunny/lab/bdf2ttf'
cc    -c -o src/bdf.o src/bdf.c
g++      -c -o src/bdf2ttf.o src/bdf2ttf.cpp
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 };
 ^
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:71:1: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
src/bdf2ttf.cpp:90:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 static char* STYLE_REGULAR = "Regular";
                              ^
src/bdf2ttf.cpp:91:28: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 static char* STYLE_BOLD  = "Bold";
                            ^
src/bdf2ttf.cpp:92:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 static char* STYLE_ITALIC = "Italic";
                             ^
src/bdf2ttf.cpp:93:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 static char* STYLE_BOLDITALIC = "Bold Italic";
                                 ^
In file included from src/bdf2ttf.cpp:11:0:
src/version.h:12:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 #define COPYRIGHT "(C) 2003 KaoriYa";
                   ^
src/bdf2ttf.cpp:95:21: note: in expansion of macro 'COPYRIGHT'
 char *g_copyright = COPYRIGHT;
                     ^
src/version.h:13:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 #define VERSION  "2.0"
                  ^
src/bdf2ttf.cpp:100:20: note: in expansion of macro 'VERSION'
 char *g_version  = VERSION;
                    ^
src/version.h:14:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
 #define TRADEMARK "KaoriYa"
                   ^
src/bdf2ttf.cpp:102:21: note: in expansion of macro 'TRADEMARK'
 char *g_trademark = TRADEMARK;
                     ^
src/bdf2ttf.cpp: In function 'void generate_OS2_PREP(bdf2_t*)':
src/bdf2ttf.cpp:831:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     os2->array::addString(VENDORID); // achVendID
                                   ^
cc    -c -o src/main.o src/main.c
cc    -c -o src/rcfile.o src/rcfile.c
g++      -c -o src/table.o src/table.cpp
cc    -c -o src/ucsconv.o src/ucsconv.c
g++ -o bdf2ttf  src/bdf.o src/bdf2ttf.o src/main.o src/rcfile.o src/table.o src/ucsconv.o
make[1]: Leaving directory '/home/sunny/lab/bdf2ttf'
koron commented

There seems be bad assumption of bdf2ttf.

bdf2ttf consider unsigned long is 32bit. But most of gcc treat it as 64bit.
It will cause some problems.

koron commented

It would be better that use size aware types uint32_t or so.
But I don't have time to do that.

koron commented

I have fixed for gcc.

@sunaku please try again with recent version.

Thanks @koron! ๐Ÿ™‡ I tried the fix but the problem still occurs. ๐Ÿ˜ž I will try to debug it further. ๐Ÿ‘ท

I tried rebuilding bdf2ttf for 32-bit architecture (my system is 64-bit):

$ make gcc CFLAGS=-m32 LDFLAGS=-m32
make -f compile/Make_gcc.mak
make[1]: Entering directory '/home/sunny/lab/bdf2ttf'
cc -m32   -c -o src/bdf.o src/bdf.c
g++  -m32    -c -o src/bdf2ttf.o src/bdf2ttf.cpp
cc -m32   -c -o src/main.o src/main.c
cc -m32   -c -o src/rcfile.o src/rcfile.c
g++  -m32    -c -o src/table.o src/table.cpp
cc -m32   -c -o src/ucsconv.o src/ucsconv.c
g++ -o bdf2ttf  src/bdf.o src/bdf2ttf.o src/main.o src/rcfile.o src/table.o src/ucsconv.o -m32
make[1]: Leaving directory '/home/sunny/lab/bdf2ttf'

I still get the "Postscript font name" error in FontForge ๐Ÿ˜ž but at least the embedded bitmap fonts appear correctly now ๐Ÿ˜Œ (previously FontForge rendered them as empty, red boxes). ๐Ÿ‘ท Next idea...

koron commented

I still get the "Postscript font name" error in FontForge

I won'f fix about this.
Because it is not in bdf2ttf's scope.
But welcome to receive patches.

๐Ÿ˜… Fair enough, thanks for your help! ๐Ÿ™‡