Page 1 of 1

Converting Syriac to an image.

Posted: 2015-07-11T17:08:51-07:00
by sepoto

Code: Select all

				$sOutputDir = "C:\Users\erics_000\Desktop\Output"

				$sCharsDir = "$sOutputDir\Chars"

				$sCombDir = "$sOutputDir\Comb"

				$sImageMagickHome = "C:\ImageMagick"

				$sImageMagickConv = "$sImageMagickHome\convert.exe"

				New-Item -ItemType Directory -Force -Path $sOutputDir

				New-Item -ItemType Directory -Force -Path $sCharsDir

				New-Item -ItemType Directory -Force -Path $sCombDir

				Function outputPNG( $begin, $end, $font )
				{
					for ( $i = $begin; $i -le $end; $i++ )
					{
						$sCurChar = [char]::ConvertFromUtf32($i)
						
						If($sCurLabel -contains " ")
						{
						
						}
						ElseIf($sCurLabel -contains "")
						{
						
						}
						Else
						{
							If( Test-Path mychar.txt )
							{
								Remove-Item mychar.txt
							}
							
							Add-Content -Encoding UTF8 mychar.txt $sCurChar
							
							$sCurFileName = [string]"{0:X0000}" -f $i+".png"
							
							$sImageMagickArgs = @('-background', 'transparent', 
										'-fill', 'hsb(0,0,0)', 
										'-font', "$font",
										'-density','90',
										'-pointsize', '18',
										'-gravity', 'center',
										'label:@mychar.txt',
										"$sCharsDir\$sCurFileName")
											
							Write-Host $sImageMagickConv $sImageMagickArgs
							
							& $sImageMagickConv $sImageMagickArgs
						}
					}
				}

				outputPNG 0x0700 0x074F  "Unifont"  	#Syriac

I am trying to convert this Unicode range to images using this PowerShell script. I have tried a variety of different fonts and always for some reason there is an unwanted character coming out in the image which is output by the convert command. Sometimes this unwanted image is a ? which is placed directly to the left of the converting character which I can see very cleary. Sometimes this unwanted extra character is some form of background image that is coming in. I am attaching screenshot images.

https://onedrive.live.com/redir?resid=D ... =folder%2c

Thank you...

Re: Converting Syriac to an image.

Posted: 2015-07-11T17:25:25-07:00
by snibgo
Does it work for low values of $begin and $end, eg 0 to 255?

You might try a hex dump of mychar.txt to ensure it contains valid UTF-8 characters, then check that your font has symbols for those characters.

Re: Converting Syriac to an image.

Posted: 2015-07-11T17:31:02-07:00
by sepoto
I have checked that the contents of the file used by the label parameter is correct and contains only one character by way of the PowerShell ISE. The fonts I have chosen from Wikipedia's Unicode font page as fonts supporting Syriac. I've noticed that this unwanted character is a persistent font issue with my script and if the font is not chosen perfectly then this unwanted character crops in. The project is available:

https://github.com/sepoto/powershell_font_to_texturemap

for anyone who wishes to try for themselves and currently I have not found a way to output a correct image for Syriac if this is known how to be done with ImageMagick.

Thank you...

Re: Converting Syriac to an image.

Posted: 2015-07-11T21:58:12-07:00
by sepoto
The noto font kit from Google does the best job I can find with Syriac.