koron / bdf2ttf

Convert BDF font file to TTF (embed bitmap as is, not conver to vector)
MIT License
56 stars 12 forks source link

invalid PostScript font name #1

Closed sunaku closed 8 years ago

sunaku commented 8 years ago

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: :disappointed:

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. :sweat_smile:

koron commented 8 years ago

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.

sunaku commented 8 years ago

Thanks! :+1: Your generated fonts worked successfully in Linux FontForge and Windows 7. :100:

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. :bug:

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 8 years ago

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 8 years ago

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

koron commented 8 years ago

I have fixed for gcc.

@sunaku please try again with recent version.

sunaku commented 8 years ago

Thanks @koron! :bow: I tried the fix but the problem still occurs. :disappointed: I will try to debug it further. :construction_worker:

sunaku commented 8 years ago

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 :disappointed: but at least the embedded bitmap fonts appear correctly now :relieved: (previously FontForge rendered them as empty, red boxes). :construction_worker: Next idea...

koron commented 8 years ago

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.

sunaku commented 8 years ago

:sweat_smile: Fair enough, thanks for your help! :bow: