Page 1 of 2

Text to .bmp

Posted: 2015-07-23T13:31:26-07:00
by dnorton
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

Re: Text to .bmp

Posted: 2015-07-23T13:51:39-07:00
by Bonzo
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

Posted: 2015-07-23T14:18:05-07:00
by dnorton
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
Interesting... this produces two files:

courier12-0.bmp containing a white square
courier12-1.bmp containing the two glyphs for ascii 255 and 254

Re: Text to .bmp

Posted: 2015-07-23T15:12:18-07:00
by fmw42
I think it needs be -background white rather than xc:white. You also need a colon after label as label:@characters.txt

Code: Select all

convert -background white -font \windows\fonts\cour.ttf -pointsize 12 label:@characters.txt courier12.bmp
You might have to put quotes around @characters.txt, but try first without.

Re: Text to .bmp

Posted: 2015-07-23T15:41:26-07:00
by dnorton
fmw42:

That produces:

courier12.bmp 23x15 with glyphs for ascii 255, 254, and blank

Quotes make no diff.

Re: Text to .bmp

Posted: 2015-07-23T16:06:17-07:00
by snibgo
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
Image

Re: Text to .bmp

Posted: 2015-07-23T17:20:23-07:00
by dnorton
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.

Re: Text to .bmp

Posted: 2015-07-23T17:30:05-07:00
by 246246
If you save text as UTF-8 everything should work fine.
I guess your text is UTF-16 LE or something like.

Re: Text to .bmp

Posted: 2015-07-23T17:43:28-07:00
by dnorton
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

Re: Text to .bmp

Posted: 2015-07-23T18:02:29-07:00
by 246246
dnorton wrote:There seems to be something prepended but I can deal with that.
It must be BOM. Try to save the text UTF-8 without BOM.

Re: Text to .bmp

Posted: 2015-07-24T13:32:53-07:00
by dnorton
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.

Re: Text to .bmp

Posted: 2015-07-24T13:58:38-07:00
by snibgo
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.

Re: Text to .bmp

Posted: 2015-07-24T14:59:55-07:00
by dnorton
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.

Re: Text to .bmp

Posted: 2015-07-24T16:08:34-07:00
by snibgo
Have you tried my command above, with ALPHABET.TXT that I linked to? What result do you get?

Re: Text to .bmp

Posted: 2015-07-24T17:32:42-07:00
by dnorton
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.