Page 1 of 1
Converting TTF Fonts to PNG
Posted: 2015-01-12T15:07:07-07:00
by jpeni
I have found that the following DOS batch file works well for converting Symbol TTF fonts to PNG files, but I also want to convert ALL symbols in the Symbol Font. I cant find a way to include the lower case ALPHABETIC and NON-ALPHABETIC and NUMERIC characters in the CONVERT process. Can someone suggest a way to include the lower case ALPHABETIC characters and the NON-ALPHABETIC and NUMERIC characters in the convert batch file.
@ECHO OFF
set f=wingding.TTF
set ps=200
set bg=white
set ext=png
set s=250x250
set alpha=A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z
set num=0 1 2 3 4 5 6 7 8 9
For %%X in (%alpha% %num%) do (
convert -font %f% -pointsize %ps% -size %s% -background %bg% label:%%X %%X.%ext%)
pause
exit
Re: Converting TTF Fonts to PNG
Posted: 2015-01-13T07:58:28-07:00
by snibgo
Digits and lower-case are as easy as upper-case. Punctuation is messy, with all the escapes needed by the two language processors (Window's cmd, and IM's command parser). It's easier to read the label from a text file, which needs no escapes at all.
If a text file called alphabet.txt contains ...
Code: Select all
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ''""•–—˜™š›œžŸ
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
... then this command works:
Code: Select all
convert -font wingdings -pointsize 50 label:"@alphabet.txt" x.png
Re: Converting TTF Fonts to PNG
Posted: 2015-01-16T15:17:15-07:00
by jpeni
snibgo: Thanks. The alphabet.txt file works well for creating all symbols in ONE file.
Do you have any recommendations for converting all symbols in the TTF file to individual .PNG files?
Re: Converting TTF Fonts to PNG
Posted: 2015-01-16T16:28:13-07:00
by snibgo
Edit alphabet.txt, inserting a new line after every character. Suppose that file is named abc.txt. Use "for /F" to read every line of that file, and convert it. Don't use the character in the filename. Windows BAT syntax:
Code: Select all
set NUM=32
for /F %%C in (abc.txt) do (
echo NUM=!NUM!
%IM%convert -pointsize 20 label:%%C ch_!NUM!.png
set /A NUM+=1
)
Re: Converting TTF Fonts to PNG
Posted: 2015-01-17T18:20:51-07:00
by jpeni
snibgo: It did NOT work for me. I even replaced the %IM% with the actual file location of ImageMagick and I entered -font webding.ttf after the convert command. It gracefully goes through the symbols and new line entries, but only generates one file named ch_!NUM!.png. One thing I did notice is that a file that contains NEW LINES after each symbol is changed to CARRIAGE RETURN after each symbol when saved as a .txt file.
Re: Converting TTF Fonts to PNG
Posted: 2015-01-17T19:08:43-07:00
by snibgo
You don't need %IM%.
Insert the line "setlocal enabledelayedexpansion" at the top.
Re: Converting TTF Fonts to PNG
Posted: 2015-01-19T01:40:06-07:00
by snibgo
The same ways as Latin text. My page
http://im.snibgo.com/snutf8.htm shows some examples.