Page 1 of 1

Font for use with Hangul Jamo.

Posted: 2015-07-12T15:41:20-07:00
by sepoto
I am using ImageMagick in conjunction with this script:
https://github.com/sepoto/powershell_font_to_texturemap

The script works very well as long as the font is carefully chosen. For Hangul Jamo:

0x1100 - 0x11FF

I have not yet been able to find a font that will output this range. I have tried so far a lot of choices from the noto font kit, Code2000, Batang, Malgun-Gothic. In every case I am getting a '?' character. In some cases I get a Hangul Jamo character and a '?' to come out together in the same image. Is there some choice of font for Hangul Jamo that is known I can use in conjunction with ImageMagick?

Thank you...

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T15:46:17-07:00
by fmw42
try typing your font in a UTF8 compatible text file, then use the command line with label:@file and see if that works. Then if so, check your other script. (Start with the simplest command to see if the font works)

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:07:57-07:00
by sepoto
Then I must post a completely non script example to display that there is a problem occurring outside of the script:

This is my text file mychar.txt as with a Hangul Jamo character inside (Screenshot:)
http://imagebin.ca/v/28QRdnQcl1yA

This is the command that is used:

C:\Users\erics_000\Documents\GitHub\powershell_font_to_texturemap>C:\ImageMagick\convert.exe -background transparent -fill hsb(0,0,0) -font Batang -density 90 -
pointsize 18 -gravity center label:@mychar.txt C:\Users\erics_000\Desktop\Output\Chars\1110.png

The output comes out looking like this:

http://imagebin.ca/v/28QSOJhNn3du


I've manually removed an extra carriage return and trimmed all leading and trailing spaces from my Hangul Jamo character in my text file. Still the output comes out with a '?' in the image. Is it known why this may be occuring?

Thank you...

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:17:48-07:00
by fmw42
Are you sure that your text file is UTF8 compatible? Otherwise, I have no idea why it does not work other than the characters are not UTF8 characters. What text editor tool did you use? I do not know if notepad is UTF8 compatible, but I believe that WordPad can be set to be compatible. What version of IM are you using?

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:22:50-07:00
by sepoto
http://imagebin.ca/v/28QXCnUEjdlC

The screenshot above shows that Notepad++ sees the mychar.txt file as UTF-8 encoded.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:25:13-07:00
by fmw42
Did you try the option about UTF8 without BOM? Just exploring all possibilities.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:26:32-07:00
by fmw42
If that does not work, then can you find another source for the font. Perhaps it is corrupt or malformed.

What version of IM?

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:28:04-07:00
by fmw42
Have you tried using -annotate to render it and to get the font metrics? See http://www.imagemagick.org/Usage/text/#font_info

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:29:17-07:00
by fmw42
Post a link to your font file and I can test on my Mac and see if it fails there, also.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T16:34:51-07:00
by sepoto
Font File (Batang TTF): http://filebin.ca/28QaqWyNFumC/batang.ttc

Also: (How to place any unicode character of your choosing inside a Unicode encoded text file.)

Code: Select all

$sCurChar = [char]::ConvertFromUtf32(0x1110)
		

If( Test-Path mychar.txt )
{
	Remove-Item mychar.txt
}

Add-Content -Encoding UTF8 mychar.txt $sCurChar
To answer your question about -annotate 0 when I use that parameter I get a no image defined yet when I remove that parameter the image is output with a good looking Jamo character and also a '?' to the left of it.

***The thing about BOM seems to be the problem however I have not yet been able to write to a text file without BOM correctly yet from the PowerShell.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T17:26:25-07:00
by fmw42
What key combination produces the character you are testing?

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T17:27:53-07:00
by snibgo
The problem is in your file mychar.txt. When I execute the Powershell commands ...

Code: Select all

$sCurChar = [char]::ConvertFromUtf32(0x1110)
Add-Content -Encoding UTF8 mychar.txt $sCurChar
... I get 8 bytes in the file:

Code: Select all

{ef}{bb}{bf}{e1}{84}{90}\r\n
This is four characters: BOM, something else, carriage-return, line-feed.

Your font probably shows BOM as "?".

I don't know Powershell, and don't know how to do this correctly.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T17:30:24-07:00
by sepoto
That's OK because now that the problem is exposed I can go about solving it. I was out of my depth in terms of the actual hidden contents of the text file which you have so graciously shed light upon for me. Thank you very much I think I can handle things from here then.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T17:42:27-07:00
by fmw42
I downloaded your font file and type E into my BBEdit text editor set to UTF8 (no BOM) and this command worked fine.

Text File:
http://www.fmwconcepts.com/misc_tests/b ... batang.txt

Screensnap of BBEdit save dialog:
Image

Command line:

Code: Select all

convert -background white -fill black -font /Library/Fonts/batang.ttc -gravity center -pointsize 24 label:@batang.txt batang_E.png
Resulting Image:
Image


Note your font file is labeled with suffix .ttc Is that IM compatible? It seemed to work with no messages, but it could have not recognized it and used a default font. I am not an expert at fonts and those compatible with IM.

Re: Font for use with Hangul Jamo.

Posted: 2015-07-12T17:51:28-07:00
by sepoto
My system sees the file as a True Type Font collection and for some reason TrueTypes seem to have different extensions all the time such as .fon .ttf and .ttc. This version of Batang is a font that is installed with Microsoft Office. It's available from Microsoft in stand alone form as well.
http://imagebin.ca/v/28QxGDHyWkMd

I have some code prepared that is supposed to strip of a BOM and I will be making a new push to my git repository once all this is done

Code: Select all

			(Get-Content $sMyPath) | 
			Foreach-Object {$_ -replace "\xEF\xBB\xBF", ""} | 
			Set-Content $sMyPath
You've been an amazing person. Thank you for helping.