Skip to content

Commit

Permalink
Add script to preview/validate Nerd Fonts (o2sh#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack authored Dec 19, 2024
1 parent 39bd88b commit 2e85d5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ indent_style = tab
[*.json]
indent_style = space
indent_size = 2

[*.rb]
indent_style = space
indent_size = 2
15 changes: 15 additions & 0 deletions scripts/nf-preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
require "yaml"

LANGUAGES_FILE = File.expand_path("../../languages.yaml", __FILE__)

languages = YAML.safe_load_file(ARGV[0] || LANGUAGES_FILE, symbolize_names: true)

languages.each do |language, attributes|
icon = attributes[:icon]
next if icon.nil?
match = /\A\\u\{([A-F0-9]{4,})\}\z/i.match(icon)
raise "Icon for #{language} is not in the correct format: `#{icon}`" unless match
glyph = match.captures[0].hex.chr("UTF-8")
puts "#{language}: #{glyph}"
end

0 comments on commit 2e85d5a

Please sign in to comment.