Jump to content

Create font files for Bootloader GUI's


blackosx
 Share

126 posts in this topic

Recommended Posts

Hi Slice

 

I didn't make any changes to the script as I still think there's a problem with your ImageMagick.

Plus, the script doesn't do much error checking.

 

What does the following command give you?

convert -debug annotate  xc: -font PATH/TO/FONT -pointsize 24 -annotate 0 "A" null

This is what I see here:

$ convert -debug annotate  xc: -font /Users/nick/Library/Fonts/Futura\ ADOBE/Futur -pointsize 24 -annotate 0 "A" null
2015-06-03T09:34:04+01:00 0:00.000 0.000u 6.9.0 Annotate convert[17024]: annotate.c/RenderFreetype/1253/Annotate
  Font /Users/nick/Library/Fonts/Futura ADOBE/Futur; font-encoding none; text-encoding none; pointsize 24
2015-06-03T09:34:04+01:00 0:00.000 0.000u 6.9.0 Annotate convert[17024]: annotate.c/GetTypeMetrics/824/Annotate
  Metrics: text: A; width: 19.1875; height: 31; ascent: 25; descent: -7; max advance: 27; bounds: -0.1875,0  17.0938,19.7344; origin: 17,0; pixels per em: 24,24; underline position: -2.34375; underline thickness: 1.17188
2015-06-03T09:34:04+01:00 0:00.000 0.000u 6.9.0 Annotate convert[17024]: annotate.c/RenderFreetype/1253/Annotate
  Font /Users/nick/Library/Fonts/Futura ADOBE/Futur; font-encoding none; text-encoding none; pointsize 24
convert: no encode delegate for this image format `XC' @ error/constitute.c/WriteImage/1164.
Link to comment
Share on other sites

I created new ImageMagick compiling from sources

./configure --prefix=/opt/local --with-quantum-depth=16 \
	--with-apple-font-dir=/System/Library/Fonts \
	--without-magick-plus-plus \
	--with-windows-font-dir=/WinFonts --with-rsvg --with-png --with-jpeg --with-openjp2 --with-openexr --with-tiff --with-wmf\
	--enable-zero-configuration --disable-assert --without-threads \
      --disable-dependency-tracking --with-x=yes \
      --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib/ \
      --without-perl CC=clang CFLAGS="-Wno-attributes"

and now I have some success: I created an image without chars.

And your test

Sergeys-iMac:createFont_v0.78 slice$ convert -debug annotate  xc: -font ./arial.ttf -pointsize 24 -annotate 0 "A" null
2015-06-03T14:24:50+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87602]: annotate.c/RenderFreetype/1253/Annotate
  Font ./arial.ttf; font-encoding none; text-encoding none; pointsize 24
2015-06-03T14:24:50+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87602]: annotate.c/GetTypeMetrics/824/Annotate
  Metrics: text: A; width: 18.0312; height: 28; ascent: 22; descent: -5; max advance: 48; bounds: -0.03125,0  16.0469,18; origin: 16,0; pixels per em: 24,24; underline position: -4.5625; underline thickness: 2.34375
2015-06-03T14:24:50+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87602]: annotate.c/RenderFreetype/1253/Annotate
  Font ./arial.ttf; font-encoding none; text-encoding none; pointsize 24
convert: no encode delegate for this image format `XC' @ error/constitute.c/WriteImage/1167.
Sergeys-iMac:createFont_v0.78 slice$ 

and with file name

Sergeys-iMac:createFont_v0.78 slice$ convert -debug annotate  xc: -font ./arial.ttf -pointsize 24 -annotate 0 "A" probe.png
2015-06-03T14:27:20+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87621]: annotate.c/RenderFreetype/1253/Annotate
  Font ./arial.ttf; font-encoding none; text-encoding none; pointsize 24
2015-06-03T14:27:20+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87621]: annotate.c/GetTypeMetrics/824/Annotate
  Metrics: text: A; width: 18.0312; height: 28; ascent: 22; descent: -5; max advance: 48; bounds: -0.03125,0  16.0469,18; origin: 16,0; pixels per em: 24,24; underline position: -4.5625; underline thickness: 2.34375
2015-06-03T14:27:20+03:00 0:00.000 0.000u 6.9.1 Annotate convert[87621]: annotate.c/RenderFreetype/1253/Annotate
  Font ./arial.ttf; font-encoding none; text-encoding none; pointsize 24
Sergeys-iMac:createFont_v0.78 slice$ 

output is empty png file.


Wow! I have success!

Sergeys-iMac:createFont_v0.78 slice$ convert -size 320x100 xc:black -font Arial -pointsize 70 \
>           -fill white   -annotate +5+70 'Anthony' \
>           -gamma 2  +level 0,1000 -white-threshold 999 \
>           -morphology Distance Chebyshev:1,1000 -auto-level \
>           -shade 135x30 -auto-level +level 10,90% font_chebyshev.png
Sergeys-iMac:createFont_v0.78 slice$ 

font_chebyshev.png


Checking script 0.79


Sergeys-iMac:createFont_v0.79 slice$ ./createFont.sh -t2 -s14 -f./arial.ttf -b 150,100,4 -o
./createFont.sh: line 40: printf: 13.0625: invalid number
./createFont.sh: line 40: printf: 14.8281: invalid number
Canvas=0x256 | Char cell=0x16
Building ImageMagick code sequence
./createFont.sh: line 40: printf: 4.5: invalid number
./createFont.sh: line 40: printf: 2.67188: invalid number
 

...
./createFont.sh: line 40: printf: 7.09375: invalid number ./createFont.sh: line 40: printf: 6.625: invalid number ./createFont.sh: line 40: printf: 7.67188: invalid number ./createFont.sh: line 40: printf: 9.9375: invalid number ./createFont.sh: line 40: printf: 10.0625: invalid number ./createFont.sh: line 40: printf: 6.64062: invalid number ./createFont.sh: line 40: printf: 7.78125: invalid number Running ImageMagick to create image Optimising /Users/slice/Downloads/createFont_v0.79/type2_arial_14pt_Cell_0x16.png Opening /Users/slice/Downloads/createFont_v0.79/type2_arial_14pt_Cell_0x16.png Sergeys-iMac:createFont_v0.79 slice$

Screen Shot 2015-06-03 at 14.37.01.png

Link to comment
Share on other sites

Hi Slice

 

Good progress :D

 

Just need to figure out why the script has problems with rounding the numbers on your system.

Here I see

$ printf %0.f 13.0625
13

what version of bash are you using?

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.

Please try:

$ LC_NUMERIC="en_US.UTF-8" printf %0.f 13.0625
Link to comment
Share on other sites

Sergeys-iMac:createFont_v0.79 slice$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
Copyright (C) 2007 Free Software Foundation, Inc.
Sergeys-iMac:createFont_v0.79 slice$ 
Sergeys-iMac:createFont_v0.79 slice$ LC_NUMERIC="en_US.UTF-8" printf %0.f 13.0625
-bash: printf: 13.0625: invalid number
0Sergeys-iMac:createFont_v0.79 slice$ 

:(

My bash doesn't know floating numbers... Is there any other way to round values?

Link to comment
Share on other sites

 

It must do...How about this?

LC_ALL=C printf %0.f 13.0625

or this:

LC_ALL=C /usr/bin/printf "%0.f" 13.0625

or this:

echo "13.0625" | awk '{printf("%d\n",$1)}'
Sergeys-iMac:createFont_v0.79 slice$ LC_ALL=C printf %0.f 13.0625
-bash: printf: 13.0625: invalid number
0Sergeys-iMac:createFont_v0.79 slice$ LC_ALL=C /usr/bin/printf "%0.f" 13.0625
13Sergeys-iMac:createFont_v0.79 slice$ echo "13.0625" | awk '{printf("%d\n",$1)}'
13
Sergeys-iMac:createFont_v0.79 slice$ echo "13.79" | awk '{printf("%d\n",$1)}'
13
Sergeys-iMac:createFont_v0.79 slice$ 

Link to comment
Share on other sites

Great.

Please try this version of the script.

 

attachicon.gifcreateFont_v0.80.zip

Almost great

Sergeys-iMac:createFont_v0.80 slice$ ./createFont.sh -t2 -s22 -fCambria -b 100,150,24 -c 254,254,254 -o
Canvas=352x416 | Char cell=22x26
Building ImageMagick code sequence
Running ImageMagick to create image
Optimising /Users/slice/Downloads/createFont_v0.80/type2_Cambria_22pt_Cell_22x26.png
Opening /Users/slice/Downloads/createFont_v0.80/type2_Cambria_22pt_Cell_22x26.png
Sergeys-iMac:createFont_v0.80 slice$ 

type2_Cambria_22pt_Cell_22x26.png  

Link to comment
Share on other sites

This test made me empty file

#!/bin/bash

convert -size 352x416 -background "RGBA(100,150,24,1)" -font Cambria -pointsize 24 -fill "RGBA(254,254,254,1)" -draw "text 8,19 'W'" \
label:"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                " "/Users/slice/Downloads/createFont_v0.80/type2_Cambria_22pt_test.png"
Link to comment
Share on other sites

hmm.

Here I get a W

convert -size 352x416 -background "RGBA(100,150,24,1)" -font showguide.TTF -pointsize 24 -fill "RGBA(254,254,254,1)" -draw "text 8,19 'W'" \
label:"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                " "test.png"

post-331032-0-75941700-1433339709_thumb.png

Try a different font?

Link to comment
Share on other sites

I have a success when I disabled rm "$imageMagickCommandFile"

 

and then manually edit the file: remove -fill "...."

type2_Cambria_18pt_Cell_18x21.png


background also wrong

Link to comment
Share on other sites

Okay. So there's an issue with interpreting "RGBA(n,n,n,n)"

I wonder why it works here and not with you?

different ImageMagick.

 

I can say additionally that png obtained from "convert" is not understandable by Clover. We MUST optimize it by pngquant  :yes:

Then the result

Screen Shot 2015-06-03 at 17.31.48.png

 

Using this script I have to say that Clover interprets first pixel as transparent so doesn't matter what is background color.

Seems "grey" will be enough.

But fill color should be tunable...

Link to comment
Share on other sites

Thanks for your time and testing Slice.

Good to see you have managed to create a file and get it working in Clover.

 

I'll change the script so the optimise option is enabled by default.

But I'm not sure what's required for your version of ImageMagick to correctly draw text fill colour with user chosen RGB values. I know it works fine here.

 

I'll do some research :)

Link to comment
Share on other sites

Updated to v0.81

- Optimisation using pngquant is now enabled by default.

- Fix assigning colour to text and background by using RGB and not RGBA by default.  Use -a option to set text transparency (if your ImageMagick install can do it).

Link to comment
Share on other sites

For me instead of

        f) # FONT -  Check the arguments
            if [ ! -f "$OPTARG" ]; then
                echo "Font $1 not found"
                echo "exiting"
                exit 1
            else
                gFontToUse=$OPTARG
            fi
            ;;

write

        f) # FONT -  Check the arguments
                gFontToUse=$OPTARG
            ;;

because there is name of font, not a file. The font will be found in system.

 

Color format can be

-fill blue
-fill "#ddddff"
-fill "rgb(255,255,255)"

http://www.imagemagick.org/script/command-line-options.php?#fill

I see no RGBA ?


Binary download from imagemagick.org doesn't know png, jpeg, etc... so users can't use it.

Link to comment
Share on other sites

Hi Slice

 

because there is name of font, not a file. The font will be found in system.

 

I prefer to point the script to a font file as I don't wish to install a font to my system every time I create a PNG file.

 

 

I see no RGBA ?

 

The first sentence from that link you posted reads:

This option accepts a color name, a hex color, or a numerical RGB, RGBA, HSL, HSLA, CMYK, or CMYKA specification. See Color Names for a description of how to properly specify the color argument.

 

 

Binary download from imagemagick.org doesn't know png, jpeg, etc... so users can't use it.

My opening post states to use Homebrew.

I've found this to be the best way to install ImageMagick and it installs all necessary delegates required for this script.

 

I've just installed on a 10.7 system and it works first time. Same for 10.6.8  ;)

$ brew install imagemagick
==> Installing dependencies for imagemagick: xz, libtool, pkg-config, jpeg, libpng, libtiff, freetype
....
Link to comment
Share on other sites

I already have macport with a plenty of libraries and I can't mix it with Homebrew.

Let other users decide how they get ImageMagick but I see no way to get binary package. I'll try to make it including vital dylibs.

 

 

 

I prefer to point the script to a font file as I don't wish to install a font to my system every time I create a PNG file.

It doesn't exclude both way.

Link to comment
Share on other sites

Hi blackosx,
let compare our ImageMagick

Sergeys-iMac:~ slice$ convert -version
Version: ImageMagick 6.9.1-4 Q16 x86_64 2015-06-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features:  Cipher
Delegates (built-in): bzlib cairo fontconfig freetype jp2 lzma openexr pangocairo png rsvg x xml zlib

Sergeys-iMac:~ slice$ 

I think this is full archive.

To use follow instructions here

http://www.imagemagick.org/script/binary-releases.php

ImageMagick-6.9.1.tar.lzma.zip

Link to comment
Share on other sites

I already have macport with a plenty of libraries and I can't mix it with Homebrew.

Let other users decide how they get ImageMagick but I see no way to get binary package. I'll try to make it including vital dylibs.

 

Okay. Fair point.
 

It doesn't exclude both way.

I look at updating the script to look for both font file and in system if file not exist.

Link to comment
Share on other sites

Hi blackosx,

let compare our ImageMagick

Sergeys-iMac:~ slice$ convert -version
Version: ImageMagick 6.9.1-4 Q16 x86_64 2015-06-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features:  Cipher
Delegates (built-in): bzlib cairo fontconfig freetype jp2 lzma openexr pangocairo png rsvg x xml zlib

Sergeys-iMac:~ slice$ 

I think this is full archive.

To use follow instructions here

http://www.imagemagick.org/script/binary-releases.php

attachicon.gifImageMagick-6.9.1.tar.lzma.zip

 

Your package looks good.

The only difference I see initially, just by looking at the directory structure is in both my installs (10.10 and 10.6) I have a modules-Q16 directory under /lib/ImageMagick-6

post-331032-0-41802700-1433411989_thumb.png

 

From my 10.10 - ImageMagick v6.9.0-3

$ convert -version
Version: ImageMagick 6.9.0-3 Q16 x86_64 2015-01-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png xml zlib
 

I'll run more tests during the day when I get time.

Some good results. To use rescale it and recolor.

Great :D

I found disabling anti aliasing useful when using thin fonts or they won't be readable when used in Clover.

Link to comment
Share on other sites

 Share

×
×
  • Create New...