Tool to "thin" out a font to only include used characters?

Edit

Just remembered how to do this in Haskell:

import Data.List

strings = ["hello", "world", "Arduboy", "123"]

main = print $ nub $ foldl1 (++) strings

(Try online here.)

Shame Haskell sucks for interacting with the command line :P


C# doesn’t do too badly either:

using System;
using System.Collections.Generic;

namespace Thinner
{
    class Program
    {
        static void Main(string[] args)
        {
            var set = new HashSet<char>();

            string[] strings =
            {                
                "hello",
                "world",
                "Arduboy",
                "123"
            };

            foreach (var s in strings)
                foreach (var c in s)
                    set.Add(c);

            foreach (var c in set)
                Console.Write(c);
        }
    }
}

Or if you’re not adverse to a bit of Linq:

using System;
using System.Collections.Generic;
using System.Linq;

namespace Thinner
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strings =
            {                
                "hello",
                "world",
                "Arduboy",
                "123"
            };

            var chars = strings.Cast<IEnumerable<char>>().Aggregate((a, b) => a.Concat(b)).Distinct();
            
            foreach (var c in chars)
                Console.Write(c);
        }
    }
}
1 Like

That almost certainly won’t work, macros are just text substitution - they aren’t stateful.

There might be a way to do it with templates, but it would probably be terrifyingly ugly.
Uglier than this.

you can loose the 190 ones that are not the following:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,.!?
in almost all cases.