Skip to content

Commit 34edc9a

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Font.svg.get_SVG ( Fixes #17 )
1 parent 3268fbe commit 34edc9a

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

Font.types.ps1xml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
<ScriptMethod>
3838
<Name>GetGlyph</Name>
3939
<Script>
40-
param([string]$value)
41-
$this |
42-
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph[@unicode='$($value -replace "'", "''")']" |
43-
Select-Object -ExpandProperty Node
40+
param(
41+
[PSObject]$value
42+
)
43+
44+
if ($value -is [string] -and $value.Length -le 2) {
45+
$this.SVG |
46+
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph[@unicode='$($value -replace "'", "''")']" |
47+
Select-Object -ExpandProperty Node
48+
}
49+
4450
</Script>
4551
</ScriptMethod>
4652
<ScriptProperty>
@@ -64,36 +70,41 @@ $this |
6470
<ScriptProperty>
6571
<Name>FamilyName</Name>
6672
<GetScriptBlock>
67-
$this |
68-
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath //s:font-face |
69-
Select-Object -ExpandProperty Node |
70-
Select-Object -ExpandProperty font-family
73+
$this.FontFace.'font-family'
7174
</GetScriptBlock>
7275
</ScriptProperty>
7376
<ScriptProperty>
7477
<Name>FontFace</Name>
7578
<GetScriptBlock>
76-
$this |
79+
$this.SVG |
7780
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath //s:font-face |
7881
Select-Object -ExpandProperty Node
7982
</GetScriptBlock>
8083
</ScriptProperty>
8184
<ScriptProperty>
8285
<Name>FontStyle</Name>
8386
<GetScriptBlock>
84-
$this |
85-
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath //s:font-face |
86-
Select-Object -ExpandProperty Node |
87-
Select-Object -ExpandProperty font-style
87+
$this.FontFace.'font-style'
8888
</GetScriptBlock>
8989
</ScriptProperty>
9090
<ScriptProperty>
9191
<Name>FontWeight</Name>
9292
<GetScriptBlock>
93-
$this |
94-
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath //s:font-face |
95-
Select-Object -ExpandProperty Node |
96-
Select-Object -ExpandProperty font-weight
93+
$this.FontFace.'font-weight'
94+
</GetScriptBlock>
95+
</ScriptProperty>
96+
<ScriptProperty>
97+
<Name>SVG</Name>
98+
<GetScriptBlock>
99+
if (-not $this.'#SVG') {
100+
if ($this -is [IO.FileInfo] -and $this.Extension -eq '.svg') {
101+
$svgXml = (Get-Content -LiteralPath $this.FullName -Raw) -as [xml]
102+
if ($svgXml) {
103+
$this | Add-Member NoteProperty '#SVG' $svgXml -Force
104+
}
105+
}
106+
}
107+
return $this.'#SVG'
97108
</GetScriptBlock>
98109
</ScriptProperty>
99110
<ScriptProperty>

0 commit comments

Comments
 (0)