#TTF To PNG #(c) Brett Paufler #2020-03-26 #WIN 10 POWERSHELL SCRIPT #Warning! #Hangs on Error! #So, it needs to be watched... #Walks Directory Tree in Input #If TTF File, Prints Sample PNG #For Quick Review of a Mass Font Repository #Gets list of all .ttf Objects in C:\alpha\input and all sub directories $all_ttfs = Get-ChildItem C:\alpha\input -Recurse ` | Where-Object {$_.Extension -in '.TTF','.ttf'} #$all_ttfs #The Main Loop #If Program Hangs, it's mostly likely because a .ttf file (the current, has no 24pt to Output ForEach ($ttf in $all_ttfs) { #Save Name - Hard Coded to My prefered Directories $save_name = $ttf.FullName.Substring(15) -replace '.ttf','.png' $save_name = $save_name -replace '\\','_' -replace '-','_' -replace ' ','_' $save_name = 'C:\alpha\output\' + $save_name.ToLower() #$save_name #This is what goes on the .png #Random Text, As One Desires #If_the_text_is_one_word_and_goes_off_the_image, the program will hang $image_text = '"' $image_text += $ttf.BaseName #Font Name $image_text += ' Brett-Paufler Tester-Module ' $image_text += ' ABCD EFGH IJKL MNOP QRST UVWX YZ ' $image_text += ' abcd efgh ijkl mnop qrst uvwx yz ' $image_text += ' 1234 5678 90 #-=! @#$% ^&* ()_+ ' $image_text += ' If you do not like this text, change it.' $image_text += ' Afterall, the entire purpose is to see what works.' $image_text += ' Though, I will warn. Making it too specific is a losing proposition. ' $image_text += ' As one never knows how the ttf is going to response sight unseen. ' $image_text += $ttf.BaseName $image_text += ' Brett Paufler ©"' #Graphics Magic Command $command = 'C:\alpha\graphicsmagick\gm.exe ' #Graphics Magick .exe #500x is image size, fill is letter color $command += 'convert -size 500x -background white -fill black -font ' $command += $ttf.FullName #The 24 Below is the font size $command += ' -pointsize 24 caption:' #Alternative Method is by file, but it did not solve the New Line Problem #So, I used a text variable, as being easier to modify #$command += '@C:\alpha\input\ttf.txt' #From File - Very Handy $command += $image_text $command += ' ' + $save_name $command Invoke-Expression $command } #This program choked +/- 6 Times on Google Fonts #MS WIN 10 Fonts sailed through #I can live with six failures