Glulx Text Effects

version 3 by Emily Short

  • Home page
  • Complete text



  • Version 3 of Glulx Text Effects (for Glulx only) by Emily Short begins here.

    "Glulx Text Effects provides an easy way to set up special text effects for Glulx."

    Glulx color value is a kind of value. Some glulx color values are defined by the Table of Common Color Values.

    Table of Common Color Values
    glulx color value  assigned number  
    g-black  0  
    g-dark-grey  4473924  
    g-medium-grey  8947848  
    g-light-grey  14540253  
    g-white  16777215  


    text-justification is a kind of value. The text-justifications are left-justified, left-right-justified, center-justified, and right-justified.

    special-style is a kind of value. The special-styles are special-style-1 and special-style-2.

    boldness is a kind of value. The boldnesses are light-weight, regular-weight, and bold-weight.

    obliquity is a kind of value. The obliquities are no-obliquity and italic-obliquity.

    fixity is a kind of value. The fixities are fixed-width-font and proportional-font.

    Before starting the virtual machine:
        initialize user styles.
        
    Table of User Styles
    style name  justification  obliquity  indentation  first-line indentation  boldness  fixed width  relative size  glulx color  
    a special-style  a text-justification  an obliquity  a number  a number  a boldness  a fixity  a number  a glulx color value  


    To initialize user styles:
        repeat through the Table of User Styles
        begin;
            if there is a justification entry, apply justification of (justification entry) to (style name entry);
            if there is an obliquity entry, apply obliquity (obliquity entry) to (style name entry);
            if there is an indentation entry, apply (indentation entry) indentation to (style name entry);
            if there is a first-line indentation entry, apply (first-line indentation entry) first-line indentation to (style name entry);
            if there is a boldness entry, apply (boldness entry) boldness to (style name entry);
            if there is a fixed width entry, apply fixed-width-ness (fixed width entry) to (style name entry);
            if there is a relative size entry, apply (relative size entry) size-change to (style name entry);
            if there is a glulx color entry, apply (assigned number of glulx color entry) color to (style name entry);
        end repeat.
        
    To apply (color change - a number) color to (chosen style - a special-style):
        (- SetColor({chosen style}, {color change}); -)
        
    To apply (relative size change - a number) size-change to (chosen style - a special-style):
        (- SetSize({chosen style}, {relative size change}); -)
        
    To apply (chosen boldness - a boldness) boldness to (chosen style - a special-style):
        (- BoldnessSet({chosen style}, {chosen boldness}); -)
        
    To apply (indentation amount - a number) indentation to (chosen style - a special-style):
        (- Indent({chosen style}, {indentation amount}); -)
        
    To apply (indentation amount - a number) first-line indentation to (chosen style - a special-style):
        (- ParaIndent({chosen style}, {indentation amount}); -)

    To apply justification of (justify - a text-justification) to (chosen style - a special-style):
        (- Justification({justify}, {chosen style}); -)
        
    To apply fixed-width-ness (chosen fixity - a fixity) to (chosen style - a special-style):
        (- FixitySet({chosen style}, {chosen fixity}); -)
        
    To apply obliquity (chosen obliquity - an obliquity) to (chosen style - a special-style):
        (- Obliquify({chosen style}, {chosen obliquity}); -)
        
    Include (-

    [ SetColor S N;
        S=S+8;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_TextColor, N);
    ];

    [ FixitySet S N;
        S=S+8;
        N--;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Proportional, N);
    ];

    [ SetSize S N;
        S=S+8;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Size, N);
    ];

    [ BoldnessSet S N;
        S=S+8;
        N = N-2;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Weight, N);
    ];

    [ ParaIndent S N;
        S=S+8;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_ParaIndentation, N);
    ];

    [ Indent S N;
        S=S+8;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Indentation, N);
    ];

    [ Justification N S;
        N--; S=S+8;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Justification, N);
    ];

    [ Obliquify S N;
        S=S+8;
        N--;
        glk_stylehint_set(wintype_TextBuffer, S, stylehint_Oblique, N);
    ];

    -)
        

    To say first custom style:
        (- glk_set_style(style_User1); -)

    To say second custom style:
        (- glk_set_style(style_User2); -)


    Glulx Text Effects ends here.