Skip to contentSkip to conversation

Converter for the new font engine

PATCH In review Bean 4 participants 11 messages Jan 6, 2009 – Jan 13, 2009 Kbuild

lore
Share & tools
lore

Bean

author
#0 lore raw

PATCH 1/1 Converter for the new font engine

Hi,

This patch converts existing font to pf2. It uses the freetype2 library, so it can support most common file format, like bdf, pcf.gz, ttf, etc.

Usage: grub-mkfont [OPTIONS] FONT_FILES

Options:

  -o, --output=FILE_NAME    set output file name
  -i, --index=N             set font index
  -n, --name=S              set font name
  -s, --size=N              set font size
  -d, --desc=N              set font descent
  -b, --bold                convert to bold font
  -a, --auto-hint           enable autohint
  --no-bitmap               don't use bitmap glyth
  -h, --help                display this message and exit
  -V, --version             print version information and exit
  -v, --verbose             print verbose message

2008-01-06 Bean <[email protected]>

* Makefile.in (freetype_cflags): New macro. (freetype_libs): New macro.

* common.rmk (bin_UTILITIES): Add grub-mkfont. (grub_mkfont_SOURCES): New macro. (grub_mkfont_CFLAGS): New macro. (grub_mkfont_LDFLAGS): New macro.

* configure.ac (FREETYPE): New test for freetype. (freetype_cflags): New macro. (freetype_libs): New macro.

* util/grub-mkfont.c: New file.

Signature · 1 line
Bean
DISTLIST +1 -0
index 22be10b..521aec4 100644
@@ -424,6 +424,7 @@ util/grub-fstest.c
 util/grub-mkconfig.in
 util/grub-mkconfig_lib.in
 util/grub-mkdevicemap.c
+util/grub-mkfont.c
 util/grub-pe2elf.c
 util/grub-probe.c
 util/hostdisk.c
Makefile.in +2 -0
index 8cc0f1a..d411b64 100644
@@ -95,6 +95,8 @@ enable_grub_emu = @enable_grub_emu@
 enable_grub_fstest = @enable_grub_fstest@
 enable_grub_pe2elf = @enable_grub_pe2elf@
 enable_lzo = @enable_lzo@
+freetype_cflags = @freetype_cflags@
+freetype_libs = @freetype_libs@
 
 ### General variables.
 
conf/common.rmk +6 -0
index 78a7dc5..45bf7a5 100644
@@ -45,6 +45,12 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c 	\
 	disk/mdraid_linux.c disk/dmraid_nvidia.c 			\
 	grub_fstest_init.c
 
+# For grub-mkfont.
+bin_UTILITIES += grub-mkfont
+grub_mkfont_SOURCES = util/grub-mkfont.c util/misc.c
+grub_mkfont_CFLAGS = $(freetype_cflags)
+grub_mkfont_LDFLAGS = $(freetype_libs)
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: normal/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
configure.ac +10 -0
index ad6429f..3248ece 100644
@@ -127,6 +127,16 @@ if test "x$YACC" = x; then
   AC_MSG_ERROR([bison is not found])
 fi
 
+AC_CHECK_PROGS([FREETYPE], [freetype-config])
+if test "x$FREETYPE" = x; then
+  AC_MSG_ERROR([freetype-config is not found])
+fi
+
+freetype_cflags=`freetype-config --cflags`
+freetype_libs=`freetype-config --libs`
+AC_SUBST([freetype_cflags])
+AC_SUBST([freetype_libs])
+
 for file in /usr/src/unifont.bdf ; do
   if test -e $file ; then
     AC_SUBST([UNIFONT_BDF], [$file])
util/grub-mkfont.c new file +450 -0

450 lines not on this page · raw message

#1 lore raw
Quoted 9 lines · Bean

Hi,

This patch converts existing font to pf2. It uses the freetype2 library, so it can support most common file format, like bdf, pcf.gz, ttf, etc.

Usage: grub-mkfont [OPTIONS] FONT_FILES

Options:

Quoted 11 lines
  -o, --output=FILE_NAME    set output file name
  -i, --index=N             set font index
  -n, --name=S              set font name
  -s, --size=N              set font size
  -d, --desc=N              set font descent
  -b, --bold                convert to bold font
  -a, --auto-hint           enable autohint
  --no-bitmap               don't use bitmap glyth
  -h, --help                display this message and exit
  -V, --version             print version information and exit
  -v, --verbose             print verbose message

Whoa... that was fast. I hope Colin didn't start yet with his implementation.

Anyway. I think there needs to be support to specify ranges to font files do not bloat unneededly.

Perhaps --range=0x1234-0x2345 ? (and allowing multiple of those)

Btw. what does --no-bitmap do here?

author
#2 lore raw
Quoted 1 line · Vesa Jääskeläinen

Perhaps --range=0x1234-0x2345 ? (and allowing multiple of those)

Yeah, looks good.

Quoted 1 line

Btw. what does --no-bitmap do here?

Some outline font contain bitmap strike as well, this option tell freetype to ignore bitmap font when outline font exists.

Signature · 1 line
Bean
author
#3 lore raw
Quoted 9 lines · Bean
Quoted 1 line · Vesa Jääskeläinen

Perhaps --range=0x1234-0x2345 ? (and allowing multiple of those)

Yeah, looks good.

Quoted 1 line

Btw. what does --no-bitmap do here?

Some outline font contain bitmap strike as well, this option tell freetype to ignore bitmap font when outline font exists.

Hi,

This new patch add --range parameter, for example:

grub-mkfont -r 0x20-0x7f -o aa.pf2 h16.bdf

Signature · 1 line
Bean
DISTLIST +1 -0
index 22be10b..521aec4 100644
@@ -424,6 +424,7 @@ util/grub-fstest.c
 util/grub-mkconfig.in
 util/grub-mkconfig_lib.in
 util/grub-mkdevicemap.c
+util/grub-mkfont.c
 util/grub-pe2elf.c
 util/grub-probe.c
 util/hostdisk.c
Makefile.in +2 -0
index 8cc0f1a..d411b64 100644
@@ -95,6 +95,8 @@ enable_grub_emu = @enable_grub_emu@
 enable_grub_fstest = @enable_grub_fstest@
 enable_grub_pe2elf = @enable_grub_pe2elf@
 enable_lzo = @enable_lzo@
+freetype_cflags = @freetype_cflags@
+freetype_libs = @freetype_libs@
 
 ### General variables.
 
conf/common.rmk +6 -0
index 78a7dc5..45bf7a5 100644
@@ -45,6 +45,12 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c 	\
 	disk/mdraid_linux.c disk/dmraid_nvidia.c 			\
 	grub_fstest_init.c
 
+# For grub-mkfont.
+bin_UTILITIES += grub-mkfont
+grub_mkfont_SOURCES = util/grub-mkfont.c util/misc.c
+grub_mkfont_CFLAGS = $(freetype_cflags)
+grub_mkfont_LDFLAGS = $(freetype_libs)
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: normal/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
configure.ac +10 -0
index ad6429f..3248ece 100644
@@ -127,6 +127,16 @@ if test "x$YACC" = x; then
   AC_MSG_ERROR([bison is not found])
 fi
 
+AC_CHECK_PROGS([FREETYPE], [freetype-config])
+if test "x$FREETYPE" = x; then
+  AC_MSG_ERROR([freetype-config is not found])
+fi
+
+freetype_cflags=`freetype-config --cflags`
+freetype_libs=`freetype-config --libs`
+AC_SUBST([freetype_cflags])
+AC_SUBST([freetype_libs])
+
 for file in /usr/src/unifont.bdf ; do
   if test -e $file ; then
     AC_SUBST([UNIFONT_BDF], [$file])
util/grub-mkfont.c new file +496 -0

496 lines not on this page · raw message

#4 lore raw
In reply to Vesa Jääskeläinen
Quoted 6 lines · On Tue, 06 Jan 2009 16:18:15 +0200 Vesa Jääskeläinen <[email protected]> wrote:
Quoted 5 lines · Bean

Hi,

This patch converts existing font to pf2. It uses the freetype2 library, so it can support most common file format, like bdf, pcf.gz, ttf, etc.

Wow! Thanks, Bean. That is great!

Quoted 15 lines
Quoted 14 lines

Usage: grub-mkfont [OPTIONS] FONT_FILES

Options:

  -o, --output=FILE_NAME    set output file name
  -i, --index=N             set font index
  -n, --name=S              set font name
  -s, --size=N              set font size
  -d, --desc=N              set font descent
  -b, --bold                convert to bold font
  -a, --auto-hint           enable autohint
  --no-bitmap               don't use bitmap glyth
  -h, --help                display this message and exit
  -V, --version             print version information and exit
  -v, --verbose             print verbose message
Quoted 2 lines

Whoa... that was fast. I hope Colin didn't start yet with his implementation.

Nope, I didn't. And I guess I won't bother making the Java converter build with gcj in the GRUB makefile.

Regards,
Colin

author
#5 lore raw
Quoted 27 lines · Colin D Bennett
Quoted 6 lines · On Tue, 06 Jan 2009 16:18:15 +0200 Vesa Jääskeläinen <[email protected]> wrote:
Quoted 5 lines · Bean

Hi,

This patch converts existing font to pf2. It uses the freetype2 library, so it can support most common file format, like bdf, pcf.gz, ttf, etc.

Wow! Thanks, Bean. That is great!

Quoted 15 lines
Quoted 14 lines

Usage: grub-mkfont [OPTIONS] FONT_FILES

Options:

  -o, --output=FILE_NAME    set output file name
  -i, --index=N             set font index
  -n, --name=S              set font name
  -s, --size=N              set font size
  -d, --desc=N              set font descent
  -b, --bold                convert to bold font
  -a, --auto-hint           enable autohint
  --no-bitmap               don't use bitmap glyth
  -h, --help                display this message and exit
  -V, --version             print version information and exit
  -v, --verbose             print verbose message
Quoted 5 lines
Quoted 2 lines

Whoa... that was fast. I hope Colin didn't start yet with his implementation.

Nope, I didn't. And I guess I won't bother making the Java converter build with gcj in the GRUB makefile.

Hi Colin,

BTW, there seems to be some new tags in the pf2 file created by java converter, perhaps you can update the wiki page sometime ?

The new patch contains small bug fix for the device_width variable.

Signature · 1 line
Bean
DISTLIST +1 -0
index 22be10b..521aec4 100644
@@ -424,6 +424,7 @@ util/grub-fstest.c
 util/grub-mkconfig.in
 util/grub-mkconfig_lib.in
 util/grub-mkdevicemap.c
+util/grub-mkfont.c
 util/grub-pe2elf.c
 util/grub-probe.c
 util/hostdisk.c
Makefile.in +2 -0
index 8cc0f1a..d411b64 100644
@@ -95,6 +95,8 @@ enable_grub_emu = @enable_grub_emu@
 enable_grub_fstest = @enable_grub_fstest@
 enable_grub_pe2elf = @enable_grub_pe2elf@
 enable_lzo = @enable_lzo@
+freetype_cflags = @freetype_cflags@
+freetype_libs = @freetype_libs@
 
 ### General variables.
 
conf/common.rmk +6 -0
index 78a7dc5..45bf7a5 100644
@@ -45,6 +45,12 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c 	\
 	disk/mdraid_linux.c disk/dmraid_nvidia.c 			\
 	grub_fstest_init.c
 
+# For grub-mkfont.
+bin_UTILITIES += grub-mkfont
+grub_mkfont_SOURCES = util/grub-mkfont.c util/misc.c
+grub_mkfont_CFLAGS = $(freetype_cflags)
+grub_mkfont_LDFLAGS = $(freetype_libs)
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: normal/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
configure.ac +10 -0
index ad6429f..3248ece 100644
@@ -127,6 +127,16 @@ if test "x$YACC" = x; then
   AC_MSG_ERROR([bison is not found])
 fi
 
+AC_CHECK_PROGS([FREETYPE], [freetype-config])
+if test "x$FREETYPE" = x; then
+  AC_MSG_ERROR([freetype-config is not found])
+fi
+
+freetype_cflags=`freetype-config --cflags`
+freetype_libs=`freetype-config --libs`
+AC_SUBST([freetype_cflags])
+AC_SUBST([freetype_libs])
+
 for file in /usr/src/unifont.bdf ; do
   if test -e $file ; then
     AC_SUBST([UNIFONT_BDF], [$file])
util/grub-mkfont.c new file +497 -0

497 lines not on this page · raw message

#6 lore raw
Quoted 4 lines · On Wed, 7 Jan 2009 01:33:42 +0800 Bean <[email protected]> wrote:

Hi Colin,

BTW, there seems to be some new tags in the pf2 file created by java converter, perhaps you can update the wiki page sometime ?

Hi Bean,

I have updated the font format document [1]. The following are the main changes I made:

* Added information on sections FAMI, WEIG, SLAN, PTSZ. These are used to do intelligent font substitution, and later may be used to programmatically request the bold version of a font, or a larger size of the same font, etc.

* Fixed incorrect statement of font metric value data types: The document previously stated uint32be, when in fact they are stored as 16-bit values (uint16be).

* Added a comment to the effect that grub-mkfont will take the place of the Java font converter.

Regards,
Colin

[1] http://grub.enbug.org/FontFormat

author
#7 lore raw
Quoted 18 lines · Colin D Bennett
Quoted 4 lines · On Wed, 7 Jan 2009 01:33:42 +0800 Bean <[email protected]> wrote:

Hi Colin,

BTW, there seems to be some new tags in the pf2 file created by java converter, perhaps you can update the wiki page sometime ?

Hi Bean,

I have updated the font format document [1]. The following are the main changes I made:

* Added information on sections FAMI, WEIG, SLAN, PTSZ. These are used to do intelligent font substitution, and later may be used to programmatically request the bold version of a font, or a larger size of the same font, etc.

Quoted 6 lines

* Fixed incorrect statement of font metric value data types: The document previously stated uint32be, when in fact they are stored as 16-bit values (uint16be).

* Added a comment to the effect that grub-mkfont will take the place of the Java font converter.

Hi,

Thanks Colin. I've updated grub-mkfont, main changes are:

* Include new tags FAMI, WEIG, SLAN, PTSZ
* Calculate font descent automatically. You can also overwrite it with --desc option.
* Add option --force--autohint and --no-hinting
* Print font information in verbose mode.

level = 1 (-v): Print basic information, for example:
Font name: Arial Regular 16
Max width: 16
Max height: 15
Font ascent: 13
Font descent: 3
Number of glyph: 96

level >1 (-vv): Print basic information and ascii representation of glyphs, for example:
Glyph #43, U+004b
Width 11, Height 12, X offset 0, Y offset 0, Device width 10
+.........*
_#_____##__
_#____##___
_#___##____
_#__##_____
_#__#______
_#_###_____
_##_##_____
_#___##____
_#____##___
_#____##___
_#_____##__
_#______##_
+.........*
+.........*
+.........*

#: 1 in the bitmap
_: 0 in the bitmap
+: x, y axis
.: empty space inside (0, -desc, device_width, asce) *: empty space outside (0, -desc, device_width, asce)

If there is no objection, I'd commit this patch in a few days.

2009-01-10 Bean <[email protected]>

* Makefile.in (freetype_cflags): New macro. (freetype_libs): New macro.

* common.rmk (bin_UTILITIES): Add grub-mkfont. (grub_mkfont_SOURCES): New macro. (grub_mkfont_CFLAGS): New macro. (grub_mkfont_LDFLAGS): New macro.

* configure.ac (FREETYPE): New test for freetype. (freetype_cflags): New macro. (freetype_libs): New macro.

* util/grub-mkfont.c: New file.

Signature · 1 line
Bean
DISTLIST +1 -0
index 22be10b..521aec4 100644
@@ -424,6 +424,7 @@ util/grub-fstest.c
 util/grub-mkconfig.in
 util/grub-mkconfig_lib.in
 util/grub-mkdevicemap.c
+util/grub-mkfont.c
 util/grub-pe2elf.c
 util/grub-probe.c
 util/hostdisk.c
Makefile.in +2 -0
index 8cc0f1a..d411b64 100644
@@ -95,6 +95,8 @@ enable_grub_emu = @enable_grub_emu@
 enable_grub_fstest = @enable_grub_fstest@
 enable_grub_pe2elf = @enable_grub_pe2elf@
 enable_lzo = @enable_lzo@
+freetype_cflags = @freetype_cflags@
+freetype_libs = @freetype_libs@
 
 ### General variables.
 
conf/common.rmk +6 -0
index 78a7dc5..45bf7a5 100644
@@ -45,6 +45,12 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c 	\
 	disk/mdraid_linux.c disk/dmraid_nvidia.c 			\
 	grub_fstest_init.c
 
+# For grub-mkfont.
+bin_UTILITIES += grub-mkfont
+grub_mkfont_SOURCES = util/grub-mkfont.c util/misc.c
+grub_mkfont_CFLAGS = $(freetype_cflags)
+grub_mkfont_LDFLAGS = $(freetype_libs)
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: normal/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
configure.ac +10 -0
index ad6429f..3248ece 100644
@@ -127,6 +127,16 @@ if test "x$YACC" = x; then
   AC_MSG_ERROR([bison is not found])
 fi
 
+AC_CHECK_PROGS([FREETYPE], [freetype-config])
+if test "x$FREETYPE" = x; then
+  AC_MSG_ERROR([freetype-config is not found])
+fi
+
+freetype_cflags=`freetype-config --cflags`
+freetype_libs=`freetype-config --libs`
+AC_SUBST([freetype_cflags])
+AC_SUBST([freetype_libs])
+
 for file in /usr/src/unifont.bdf ; do
   if test -e $file ; then
     AC_SUBST([UNIFONT_BDF], [$file])
util/grub-mkfont.c new file +625 -0

625 lines not on this page · raw message

author
#8 lore raw

Committed.

Signature · 1 line
Bean
#9 lore raw
In reply to Colin D Bennett

Collin does your java converter need to stay in the repo now that grub-mkfont is there? Any benefits to it over grub-mkfont?

Quoted 42 lines · Colin D Bennett
Quoted 6 lines · On Tue, 06 Jan 2009 16:18:15 +0200 Vesa Jääskeläinen <[email protected]> wrote:
Quoted 5 lines · Bean

Hi,

This patch converts existing font to pf2. It uses the freetype2 library, so it can support most common file format, like bdf, pcf.gz, ttf, etc.

Wow! Thanks, Bean. That is great!

Quoted 15 lines
Quoted 14 lines

Usage: grub-mkfont [OPTIONS] FONT_FILES

Options:

  -o, --output=FILE_NAME    set output file name
  -i, --index=N             set font index
  -n, --name=S              set font name
  -s, --size=N              set font size
  -d, --desc=N              set font descent
  -b, --bold                convert to bold font
  -a, --auto-hint           enable autohint
  --no-bitmap               don't use bitmap glyth
  -h, --help                display this message and exit
  -V, --version             print version information and exit
  -v, --verbose             print verbose message
Quoted 2 lines

Whoa... that was fast. I hope Colin didn't start yet with his implementation.

Nope, I didn't. And I guess I won't bother making the Java converter build with gcj in the GRUB makefile.

Regards,
Colin

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw
Quoted 2 lines · On Wed, 7 Jan 2009 20:56:25 -0600 "Jerone Young" <[email protected]> wrote:

Collin does your java converter need to stay in the repo now that grub-mkfont is there? Any benefits to it over grub-mkfont?

No, I don't think there is any reason to keep it if grub-mkfont has been shown to work. I haven't had a chance to test it myself yet. There are no intrinsic benefits to the Java converter over the C version.

Regards,
Colin