\startenvironment env_balsa.tex
%\definefonthandling [quality] [hz,pure]
%\setupfontsynonym [sans] [handling=quality]
%\setupfonthandling [hz] [min=25,max=25,step=5]
%\setupalign[hz,hanging]

% DEBUG {{{
    % uncomment those 2 lines to show the layout and the grid
    %\showframe 
    %\showgrid
% }}}}

% UTF-8 {{{
    \enableregime[utf-8]              % Enters unicode 
    %\setupencoding[default=uc]       % Uses unicode fonts only
% }}}

% LANGUAGE {{{
    \setuplanguage[fr][
        leftquote=\upperleftdoublesixquote,
        rightquote=\upperrightdoublesixquote,
    ]
    \mainlanguage[fr]
    \setcharacterspacing [frenchpunctuation]
% }}}
%
% LOAD FONTS {{{
    \starttypescript [sans] [umepgothicbalsa] 
        \definefontsynonym [Sans]            [name:umepgothicbalsa] [handling=pure]
    \stoptypescript
    \starttypescript [sans] [umepgothicvertical] 
        \definefontsynonym [Sans]            [name:umepgothicvertical] [handling=pure]
    \stoptypescript
    \starttypescript [sans] [umepgothicrings] 
        \definefontsynonym [Sans]            [name:umepgothicrings]
    \stoptypescript
    \starttypescript [mono] [umeminchobalsa] 
        \definefontsynonym [Mono]            [name:umeminchobalsa] [handling=pure]
    \stoptypescript
    \starttypescript [mono] [umepmincho] 
        \definefontsynonym [Mono]            [name:umepmincho] [handling=pure]
    \stoptypescript

    \definetypeface [umepgothicbalsa] [ss] [sans] [umepgothicbalsa]
    \definetypeface [umepgothicvertical]    [ss] [sans]  [umepgothicvertical]
    \definetypeface [umepgothicrings]    [ss] [sans]  [umepgothicrings]
    \definetypeface [umeminchobalsa]    [tt] [mono]  [umeminchobalsa]
    \definetypeface [umepmincho]    [tt] [mono]  [umepmincho]

% }}}

% LAYOUT {{{
% General layout
    %\setuppapersize[A6][A4, landscape] 
    %\setuparranging[2*8] % imposition cahier de 16 pages
    %\setuparranging[2SIDE] % vue en planche
   \definepapersize[dudu][A6, landscape]
   \setuppapersize[dudu]

    \setuplayout[
        %marking=on,
        %location={middle,middle},
          backspace=6.5mm,
          topspace=5mm,
          width=132mm,
          height=90mm,
          columns=2,
    %       leftmargin=20mm,
    %       rightmargin=0mm,
          header=7mm,
          footer=0mm, 
          %lines=21,
          grid=yes, % activates baseline grid
    ]
    \definepagebreak[emptyodd][yes,header,footer, odd]
    \definepagebreak[emptyeven][yes,header,footer, even]

    % Indented block
    \setupnarrower[left=3mm, right=0mm, middle=8mm]
    % Folio
%    \setuppagenumber[number=3]
    %\setuppagenumbering[location=header, alternative=doublesided, style={\tf \setupbodyfont[umepgothicvertical, 6pt]}] 
    \setupheadertexts
        [{\getmarking[title]}]       [{\pagenumber}]  
        [{\getmarking[titlenl]}]     [{\pagenumber}]     
    \setuppagenumbering[location=] 
    \setupheader[text][
        style={\color[Pantone] \tf \setupbodyfont[umepgothicbalsa, 5pt]},
    ]
% }}}


% COLORS {{{
    \setupcolors[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]
    \definecolor[blackos][c=0,m=0,y=0,k=1] 
    \definespotcolor[Pantone][blackos][p=1] 
    \setupinteraction[state=start, color=Pantone] % activate links
% }}}


% TYPOGRAPHY {{{
    \setupbodyfont[umepgothicvertical, ss, 8pt]
    \definebodyfontenvironment[default][x=0.5, a=1.5, b=1.75, c=2,d=3.4, e=6] % defines higher sizes of fonts 
    \setupinterlinespace[11pt] 
% }}}

% JUSTIFICATION {{{
    \setuptolerance[verytolerant] % justification settings
    %\interlinepenalty=8000 % tries to avoid widows
    %\widowpenalty=8000 % tries to avoid widows
    %\clubpenalty=8000 % tries to avoid widows
    %\doublehyphendemerits=1000000 % tries to avoid consecutive hyphenations
    %\setupalign[hanging]



%\startfonthandling [pure]
%\defineprotrudefactor , 0 1
%\defineprotrudefactor . 0 1 
%\defineprotrudefactor : 0 1
%\defineprotrudefactor; 0 1
%\defineprotrudefactor - 0 1
%\defineprotrudefactor hyphen 0 1
%\defineprotrudefactor endash 0 .5
%\defineprotrudefactor emdash 0 .33 % .5
%\stopfonthandling

 

% }}}

% GRAPHIC ELEMENTS {{{
    % make custom underline, otherwise holes between words!
    \definebar[underline][
        order=background, % foreground to put line in front
        rulethickness=0.05, 
        offset=-0.15, 
        continue=yes, 
        color=black,
        ]
   \defineframed[bold][
        location=low,
        %height=0pt,
        offset=1.2pt,
        topframeoffset=-1pt,
        ]
    % put a frame around a word
    \definetextbackground[inbox][
            framecolor=black,
            background=,
        ]


\setupexternalfigures[directory={../hichem/genese/recadrages,.}]
% }}}

% TABLE OF CONTENTS {{{
    \setupcombinedlist[content][interaction=all, color=black] % makes it clickable
    \setuplist[section][width=0mm] % sets indentation for section level
    \setuplist[subsection][width=1em] % sets indentation for subsection level
% }}}

% SECTIONS AND HEADINGS {{{
    % function to put titles in the margin
        \def\InMargin#1#2{\inleftmargin{#1 #2}}
    %
    % NUMBERED SECTIONS // used for table of contents
        \setuphead[section][
            number=no,
            align={nothyphenated, verytolerant, center},
            page=yes,
            after=\nowhitespace,
            style={\tfd \cap \setupbodyfont[umeminchobalsa]},
            %distance=0pt, alternative=text, command=\InMargin, % calls function to put in margin
            ]
    % UNNUMBERED SECTIONS // not used in table of contents
        % GENERAL STYLING OF HEADINGS
        \setuphead[title, subject][
            align={nothyphenated, verytolerant, center},
            %aligntitle=float,
            page=,
            style=\tf,
            before=\nowhitespace,
            after=\nowhitespace,
            ]
        % TITLE NL
        \definehead[titlenl][subject]
        \setuphead[titlenl][
            align={nothyphenated, verytolerant, center},
            %aligntitle=float,
            page=,
            style=\tf,
            before=\nowhitespace,
            after=\nowhitespace,
            ]
        % DAY
        \definehead[day][subject]
        \setuphead[day][
            align={nothyphenated, verytolerant, center},
            before=\nowhitespace,
            after=\nowhitespace,
            style={\tfd \setupbodyfont[umeminchobalsa]},
            ]
        % ARTIST
        \definehead[artist][subject]
        \setuphead[artist][
            align={nothyphenated, verytolerant, center},
            before=\nowhitespace,
            after=\nowhitespace,
            style={\tfa \cap \setupbodyfont[umepgothicvertical]},
            ]
        % SUBTITLE [INFOS PRATIQUES]
        \definehead[subtitle][subject]
        \setuphead[subtitle][
            before=\blank\noindentation,
            after=\blank,
            style={\tf \setupbodyfont[umeminchobalsa]},
        ]
% }}}

% PARAGRAPHS {{{
    \setupwhitespace[none]           % no empty line after a paragraph

    % INDENTATION
    \setupindenting[yes, medium, next] % activates medium indentation, not on 1st paragraph
    \define[1]\realpar{\blank[nowhite]\noindentation} % make new paragraph: blank line
    \define[1]\subpar{\blank[nowhite]\indentation} % make sub paragraph: indent

    % DROP CAPITAL
    \setupinitial[state=start, n=1, distance=0mm, font=umepgothicrings]

    % BLOCKQUOTE
    \setupdelimitedtext[blockquote][1][
        left={\symbol[leftquotation]},
        right={\symbol[rightquotation]},
        before={
            \blank
            \noindentation
            \startalignment[flushleft]
            \setupalign[nothyphenated]
        },
        after={
            \stopalignment
            \indenting[yes]
        }
    ]
    \setupdelimitedtext[blockquote][2][
        left={\symbol[leftquote]},
        right={\symbol[rightquote]},
        before={
            \blank
            \setupbodyfont[umeminchobalsa, 9pt]
            \setupinterlinespace[11pt]
            \startnarrower[left, right]
            \noindentation
        },
        after={
            \stopnarrower
            \blank
            \indenting[yes]
        }
    ]
    \definestartstop[fr][
        before={
            \blank[nowhite]\noindentation\startalignment[middle]\setupbodyfont[umepgothicrings, 8pt]FR\stopalignment
            \setupbodyfont[umepgothicvertical, 8pt]
    \language[fr]
        },
    ]
    \definestartstop[nl][
        before={
            \blank[nowhite]\noindentation\startalignment[middle]\setupbodyfont[umepgothicrings, 8pt]NL\stopalignment
            \setupbodyfont[umepmincho, 9pt]
    \language[nl]
        },
    ]

    % BLOCKQUOTE SIGNATURE
    \definestartstop[signature][
        before={
            \noindentation
            },
        after={
            \indenting[yes]
            \blank
            },
        style={\switchtobodyfont[6pt]},
    ]
    % BLOCK PRODUCTION
    \definestartstop[prod][ 
        style=\tfx,
        after=\nowhitespace,
        ] 
    %
% }}}

% DEFINITION LISTS {{{
% such as "Production: Théâtre de la balsamine"

    \definestartstop[staff][
        style={\setupbodyfont[umepgothicbalsa, 6pt]},
        before={
            \blank
            \startalignment[center]
            %\startnarrower[left, right]
            \noindentation
        },
        after={
            %\stopnarrower
            \stopalignment
            \blank
            \indenting[yes]
        }
    ]
% }}}


\stopenvironment
