Skip to content

Commit da4e141

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Font.Glyph.get_PathData ( Fixes #19 )
1 parent e4be38c commit da4e141

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

Font.types.ps1xml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@
1919
</ScriptProperty>
2020
</Members>
2121
</Type>
22+
<Type>
23+
<Name>Font.Glyph</Name>
24+
<Members>
25+
<ScriptProperty>
26+
<Name>PathData</Name>
27+
<GetScriptBlock>
28+
&lt;#
29+
.SYNOPSIS
30+
Gets the glyph path data
31+
.DESCRIPTION
32+
Gets the glyph path data.
33+
34+
Glyph paths are drawn upside down by default.
35+
#&gt;
36+
$this.d
37+
</GetScriptBlock>
38+
</ScriptProperty>
39+
</Members>
40+
</Type>
2241
<Type>
2342
<Name>Font.svg</Name>
2443
<Members>
@@ -41,10 +60,21 @@
4160
[PSObject]$value
4261
)
4362

63+
filter toGlyph {
64+
$_.Node.pstypenames.add('Font.glyph')
65+
$_.Node
66+
}
4467
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
68+
$escapedValue = $($value -replace "'","''")
69+
$this.XML |
70+
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph[@unicode='$escapedValue'] | //s:glyph[@glyph-name='$escapedValue']" |
71+
toGlyph
72+
}
73+
74+
if ($null -eq $value) {
75+
$this.XML |
76+
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph" |
77+
toGlyph
4878
}
4979

5080
</Script>

0 commit comments

Comments
 (0)