Powershell script to create Font XML's.

Who likes scripts?

Created this script to create basic font xml’s for fonts to be used within lumberyard.

You can drop it into the root of your game folder and run it and it will create them without overwriting existing xmls or you can use the parameters to overwrite them if you’d like.

	param (
[string] $path = "./Fonts",
[Int] $width = 512,
[Int] $height = 256,
[string[]] $extensions = (".otf", ".ttf", ".ttc"),
[switch] $overwrite = $False
)
$files = Get-ChildItem -Recurse -Path $path | Where-Object {($extensions -contains $_.Extension)}
Foreach ($file IN $files)
{
$xmlPath = -join($file.DirectoryName,"\",$file.BaseName,".xml")
If(((Test-Path $xmlPath) -eq $True) -and ($overwrite -eq $False)){
Write-Host "Skipping: " $xmlPath
continue
} Else {
Write-Host "Creating Font XML: " $xmlPath
"<fontshader>" | Out-File $xmlPath
$font = -join("	<font path=""",$file.Name,""" w=""",$width,""" h=""",$height,""" />")
$font | Out-File $xmlPath -Append
"	<effect name=""default"">" | Out-File $xmlPath -Append
" <pass>" | Out-File $xmlPath -Append
# " <color r=""1"" g=""1"" b=""1"" a=""1"" />" | Out-File $xmlPath -Append
# " <pos x=""0"" y=""0"" />" | Out-File $xmlPath -Append
" </pass>" | Out-File $xmlPath -Append
"	</effect>" | Out-File $xmlPath -Append
"</fontshader>" | Out-File $xmlPath -Append
}
}

Parameters:

-path : where to look for fonts, defaults to "./Fonts".
-width : what width to use for the xml, defaults to 512.
-height : what height to use for the xml, defaults to 256.
-extensions : what extensions to look for, defaults to (".otf", ".ttf", ".ttc").
-overwrite : whether or not to overwrite existing xmls, defaults to false, to enable just tack it on without true/false on it.

Enjoy!