Text to .bmp
Text to .bmp
I'm trying to produce a .bmp file with glyphs for the ascii characters 32 to 255. This needs to be for a specific font and pointsize. I have a file "characters.txt" containing the 224 characters. Using IM 6.9.1-9 on Windows 7 I've tried several variations along this line:
convert -font \windows\fonts\cour.ttf -pointsize 12 text:characters.txt courier12.bmp
This produces only two glyphs which resemble ascii 255 and 254. What am I doing wrong?
- Dan
convert -font \windows\fonts\cour.ttf -pointsize 12 text:characters.txt courier12.bmp
This produces only two glyphs which resemble ascii 255 and 254. What am I doing wrong?
- Dan
Re: Text to .bmp
I would try something like:
Code: Select all
convert xc:white -font \windows\fonts\cour.ttf -pointsize 12 label:@characters.txt courier12.bmp
Re: Text to .bmp
Interesting... this produces two files:Bonzo wrote:I would try something like:Code: Select all
convert xc:white -font \windows\fonts\cour.ttf -pointsize 12 label:@characters.txt courier12.bmp
courier12-0.bmp containing a white square
courier12-1.bmp containing the two glyphs for ascii 255 and 254
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Text to .bmp
I think it needs be -background white rather than xc:white. You also need a colon after label as label:@characters.txt
You might have to put quotes around @characters.txt, but try first without.
Code: Select all
convert -background white -font \windows\fonts\cour.ttf -pointsize 12 label:@characters.txt courier12.bmp
Re: Text to .bmp
fmw42:
That produces:
courier12.bmp 23x15 with glyphs for ascii 255, 254, and blank
Quotes make no diff.
That produces:
courier12.bmp 23x15 with glyphs for ascii 255, 254, and blank
Quotes make no diff.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Text to .bmp
There may be something funny in your text file. With a file that contains ASCII 32 to 256, plus a new-line every 32 characters (file http://snibgo.com/imforums/ALPHABET.TXT ), I get:
Code: Select all
convert -font Courier-new -pointsize 20 label:@ALPHABET.TXT alphabet.png
snibgo's IM pages: im.snibgo.com
Re: Text to .bmp
snibgo:
In the following, "couriershort.txt" contains only the digits 0-9:
convert -font \windows\fonts\cour.ttf -pointsize 12 label:@couriershort.txt courier12.png
courier12.png is 23x15 and contains ascii 255, 254, and 48 = '0'
So, it must not be the input and .png seems to be the same as .bmp.
In the following, "couriershort.txt" contains only the digits 0-9:
convert -font \windows\fonts\cour.ttf -pointsize 12 label:@couriershort.txt courier12.png
courier12.png is 23x15 and contains ascii 255, 254, and 48 = '0'
So, it must not be the input and .png seems to be the same as .bmp.
Re: Text to .bmp
If you save text as UTF-8 everything should work fine.
I guess your text is UTF-16 LE or something like.
I guess your text is UTF-16 LE or something like.
Re: Text to .bmp
246246:
Yes! That's real progress. There seems to be something prepended but I can deal with that.
Thank you and everyone else who tried to help.
- Dan
Yes! That's real progress. There seems to be something prepended but I can deal with that.
Thank you and everyone else who tried to help.
- Dan
Re: Text to .bmp
It must be BOM. Try to save the text UTF-8 without BOM.dnorton wrote:There seems to be something prepended but I can deal with that.
Re: Text to .bmp
246246:
Tried successively removing characters at the front until I lopped off the blank (ascii 32) but the prepended thing stubbornly remains. My Form class>>fromBinaryStream: has firstByte = 66.
Tried successively removing characters at the front until I lopped off the blank (ascii 32) but the prepended thing stubbornly remains. My Form class>>fromBinaryStream: has firstByte = 66.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Text to .bmp
I'm not sure what you are trying to achieve. You say "ascii characters 32 to 255", but you are saving a file as UTF, not ASCII? And ASCII only goes up to 127.
snibgo's IM pages: im.snibgo.com
Re: Text to .bmp
I'm building a strike font to include not only ascii 32 to 127 but also extended ascii 128 to 155. These are printable characters (maybe not all in courier) but in some other monospaced font. I need the glyphs for these characters. The technique will be applied to other fonts beside courier.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Text to .bmp
Have you tried my command above, with ALPHABET.TXT that I linked to? What result do you get?
snibgo's IM pages: im.snibgo.com
Re: Text to .bmp
Downloaded your ALPHABET.TXT, ran your convert and got the same thing that you show.
Took the new lines out, saved it from NotePad with encoding: UTF-8, ran your convert and got the same prepended string of characters as I discuss above.
Took the new lines out, saved it from NotePad with encoding: ANSI, ran your convert and got what appears to be the desired glyphs, that is *without* anything prepended. Now I'll try to make a strike font out of it.
Took the new lines out, saved it from NotePad with encoding: UTF-8, ran your convert and got the same prepended string of characters as I discuss above.
Took the new lines out, saved it from NotePad with encoding: ANSI, ran your convert and got what appears to be the desired glyphs, that is *without* anything prepended. Now I'll try to make a strike font out of it.