Glimmr Drawing Commands

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Part - Provide indices for each glyph in a bitmap font

    The file of Font Table is called "FontTable".

    To get/set blank/-- indices for (typeface - a bitmap font), silently, verifying glyph map, and/or writing table to disk:
        sort the font table of the typeface in index order;
        let actual-index be 1;
        let next-advance be 0;
        unless silently:
            say "Checking the font table for [typeface]. Will attempt to add any missing index values. There are [number of rows in the font table of typeface] rows in the table.[paragraph break]";
        repeat with N running from 1 to the number of rows in the font table of the typeface:
            choose row N in the font table of the typeface;
            if there is an index entry:
                unless index entry is (actual-index plus next-advance):
                    say "***Index numbers for the font table of [typeface] MAY be incorrect. Check glyph '[char-code char entry]' (char [char entry]), or the index position before it. The problem may also be that the height or width is incorrectly specified.";
                let actual-index be index entry;
            otherwise:
                next;
            if verifying glyph map:
                if the char entry is entry (index entry) of the glyph map of the typeface:
                    unless silently:
                        say "Glyph '[char-code char entry]' ([char entry]) appears to be correctly matched to the glyph map.";
                otherwise:
                    say "***The index entry for glyph [char-code char entry] ([char entry]) does not seem to correctly match the glyph map. Continuing, if possible...";
            if there is a width entry and there is a height entry:
                let next-advance be (width entry * height entry) + 1;
            otherwise:
                say "***Glyph '[char-code char entry]' ([char entry]) in the font table of [typeface] is missing bitmap dimensions. Repair font table.";
                break;
        if verifying glyph map:
            if silently:
                add indices to the typeface starting from (index entry + next-advance), silently, verifying glyph map;
            otherwise:
                add indices to the typeface starting from (index entry + next-advance), verifying glyph map;
        otherwise if silently:
            add indices to the typeface starting from (index entry + next-advance), silently;
        otherwise:
            add indices to the typeface starting from (index entry + next-advance);
        if writing table to disk:
            write font table to disk for the typeface.

    To add indices to (typeface - a bitmap font) starting from (N - a number), silently and/or verifying glyph map:
        let calculated-index be N;
        repeat through the font table of typeface:
            if there is an index entry:
                next;
            now index entry is calculated-index;
            if calculated-index is greater than 0:
                unless silently:
                    say "Changed index entry for glyph '[char-code char entry]' (char [char entry]) to [index entry].";
            otherwise:
                say "***Could not provide an index entry for the font table of [typeface]: Check glyph '[char-code char entry]' (char [char entry]) first.";
                break;
            let calculated-index be calculated-index plus ( width entry * height entry) + 1;
            if verifying glyph map:
                if the char entry is entry (index entry) of the glyph map of the typeface:
                    unless silently:
                        say "Glyph '[char-code char entry]' ([char entry]) appears to be correctly matched to the glyph map.";
                otherwise:
                    say "***The index entry for glyph [char-code char entry] ([char entry]) does not seem to correctly match the glyph map. Continuing, if possible...";

    To write font table to disk for (typeface - a bitmap font):
        write "[font table of typeface][line break]" to the file of Font Table;
        append "glyph[direct-character placement tab]char[direct-character placement tab]index[direct-character placement tab]width[direct-character placement tab]height[direct-character placement tab]yoffset[direct-character placement tab]advance[line break]" to the file of Font Table;
        repeat with N running from 1 to the number of rows in the font table of the typeface:
            choose row N in the font table of the typeface;
            append "'[glyph entry]'[direct-character placement tab][char entry][direct-character placement tab][index entry][direct-character placement tab][width entry][direct-character placement tab][height entry][direct-character placement tab][yoffset entry][direct-character placement tab][advance entry][line break]" to the file of Font Table.

    To say direct-character placement tab:
        (- glk_put_char_uni(9); -)