From 76b1bfe3a911a7c5e92b30d5992ebf1d5cf02df5 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Thu, 19 Dec 2024 12:44:39 -0500 Subject: [PATCH] Add script to preview/validate Nerd Fonts --- .editorconfig | 4 ++++ scripts/nf-preview.rb | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 scripts/nf-preview.rb diff --git a/.editorconfig b/.editorconfig index 7d715a8a0..e33929dbf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,3 +17,7 @@ indent_style = tab [*.json] indent_style = space indent_size = 2 + +[*.rb] +indent_style = space +indent_size = 2 diff --git a/scripts/nf-preview.rb b/scripts/nf-preview.rb new file mode 100755 index 000000000..b4e0bd385 --- /dev/null +++ b/scripts/nf-preview.rb @@ -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