Here is an even simpler approach that does not use an external program,
… nor need to write an external font list file:
module SomeAuthor
module Fonts
require 'win32/registry'
extend self
MACHINE ||= Win32::Registry::HKEY_LOCAL_MACHINE
FONTKEY ||= 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
def get_fonts
MACHINE.open(FONTKEY) do |fontkey|
fontlist = []
fontkey.each_value { |name, type, data|
name.delete_suffix!(' (TrueType)')
fontlist << name
}
fontlist
end
end ###
end # submodule Fonts
end # toplevel namespace