Created
April 21, 2024 05:20
-
-
Save AWtnb/183f76b10bf2f159a328a999afd43ba7 to your computer and use it in GitHub Desktop.
Check RTF font information inside clipboard with Windows Powreshell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ClipboardFontInfo { | |
Add-Type -AssemblyName System.Windows.Forms | |
$cb = [System.Windows.Forms.Clipboard]::GetData([System.Windows.Forms.DataFormats]::Rtf) | |
if (-not $cb) { | |
"フォント情報がコピーされていません……" | Write-Host | |
return | |
} | |
$rtb = [System.Windows.Forms.RichTextBox]::new() | |
$rtb.Rtf = $cb | |
$font = $null | |
for ($i = 0; $i -lt $rtb.Text.length; $i++) { | |
$rtb.Select($i, 1) | |
$t = $rtb.SelectedText | |
$u = [Convert]::ToInt32($t -as [char]).ToString("X4") | |
$font = $rtb.SelectionFont | |
[PSCustomObject]@{ | |
"Text" = $t; | |
"Codepoint" = $u; | |
"OriginalFontName" = $font.OriginalFontName; | |
"Size" = $font.SizeInPoints; | |
"Style" = $font.Style; | |
} | Write-Output | |
$font | Clear-Variable -ErrorAction SilentlyContinue | |
} | |
$rtb | Clear-Variable -ErrorAction SilentlyContinue | |
} | |
Get-ClipboardFontInfo | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment