function y = make_font_data (imgname)
    % filename must be a greyscale image with a height of 8 pixels.

    % some constants (feel free to edit these)
    columns_per_char = 5;         % number of columns each character consists of
    start = 32;                   % code of first character
    prefix = '\t';                % prefix and postfix strings for every line
    postfix = '\t// frame %d';
    file_in  = [imgname '.bmp']; % input filename
    file_out = ['../Hacklace Rev. B/' imgname '.h'];   % output filename
    header = ['const unsigned char ' imgname '[] PROGMEM = {'];
    endmark = 'END_OF_DATA';
    footer = '};';
    
    % read image data into matrix A
    [A,map,alpha] = imread(file_in);

    % remove all colums that contain colors other than 0 or 255 from data.
    [r, c] = find(A>0&A<255);
    c = unique(c);
    A(:,c) = [];
    
    % for debugging use only the first 10 characters
    % A = A(:, 1:columns_per_char*10);

    % transform black pixels (= 0) to ones and white pixels (= 255) to zeros
    A = (A == 0);
    
    % calculate byte value of each column
    p = 2 .^ (0:7);
    b = A' * p';

    % put all values for a single character in one row
    M = reshape (b, columns_per_char, length(b) / columns_per_char);
    M = M';

    % format result and write it to file
    format = [prefix, '%s', postfix, '\n'];
    format_last = [prefix, '%s0x%02X', postfix, '\n'];
    fileID = fopen(file_out, 'wt');
    fprintf(fileID, '%s\n', header);
    for n = 1:size(M, 1)
        fprintf(fileID, format, sprintf('0x%02X, ', M(n, :)), n);
    end
    fprintf(fileID, [prefix, '%s\n'], endmark);
    fprintf(fileID, '%s\n', footer);
    fclose(fileID);
    
    