Skip to content

Commit 9677907

Browse files
feat: Font.svg.GetGlyph() ( Fixes #15 )
Looking for unicode or name, and defaulting to finding everything if no value is passed
1 parent cecc19a commit 9677907

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

Types/Font.svg/GetGlyph.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@ param(
22
[PSObject]$value
33
)
44

5+
filter toGlyph {
6+
$_.Node.pstypenames.add('Font.glyph')
7+
$_.Node
8+
}
59
if ($value -is [string] -and $value.Length -le 2) {
6-
$this.SVG |
7-
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph[@unicode='$($value -replace "'", "''")']" |
8-
Select-Object -ExpandProperty Node
10+
$escapedValue = $($value -replace "'","''")
11+
$this.XML |
12+
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph[@unicode='$escapedValue'] | //s:glyph[@glyph-name='$escapedValue']" |
13+
toGlyph
14+
}
15+
16+
if ($null -eq $value) {
17+
$this.XML |
18+
Select-Xml -Namespace @{s='http://www.w3.org/2000/svg'} -XPath "//s:glyph" |
19+
toGlyph
920
}

0 commit comments

Comments
 (0)