<!-- chapterName "Lesson 4: First steps in styling fixed and flowing text" -->

<codesnippet language="xml" style="code"><![CDATA[
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_04.pdf">

    <template> 
        <pageTemplate id="main">
            <pageGraphics>
                <fill color="red"/>
                <setFont name="Times-Roman" size="24"/>
                <drawString x="100" y="700">
                    Different types of Text Styling
                </drawString>
            </pageGraphics>
            <frame id="first" x1="100" y1="400" width="150" height="200"/>
            <frame id="second" x1="300" y1="400" width="150" height="200"/>
        </pageTemplate>
    </template>

    <stylesheet>
        <paraStyle name="textstyle1" fontName="Helvetica" fontSize="9" leading="10"/>
    </stylesheet>

    <story> 
        <para>
             Welcome to RML.  This paragraph has not been styled.
        </para>
        <para style="textstyle1">
            This paragraph HAS been styled, using a style defined in the
            &lt;stylesheet&gt; section.
        </para>
        <para style="textstyle1" fontSize="12">
            This paragraph uses the same style as the first paragraph, but the 
            fontsize has been overridden.  paraStyles can inherit from each other.
            You can also use html-style <b>bold</b> and <i>italic</i> tags.
        </para>
        <para textColor="blue">
             This paragraph has been styled, but not using the stylesheet.  
             It just uses style attributes inside it's own &lt;para&gt; tag.
        </para>
    </story>
</document>

]]></codesnippet>


<para>The new tags in the &lt;pageGraphics&gt; section demonstrate how to change the font and its colour for fixed elements, using &lt;setFont&gt; and &lt;fill&gt; tags.  The code demonstrates an important new concept: the pageGraphics section acts like a 'state machine' when you start changing the style of the text.  This means that you set the 'pen' to draw in a particular way, and it stays in that state until you change it.</para>

<para>The other new section is the &lt;paraStyle&gt; tag in the &lt;stylesheet&gt; section.  Styles are defined here, and then used in the &lt;para&gt; tags in the &lt;story&gt; section.  Any element of a &lt;paraStyle&gt; tag can be overridden inside the &lt;para&gt; tag itself.  You can also style a paragraph by just adding to it's &lt;para&gt; tag, as in paragraph four.</para>

<para>Note also that although the style has been changed in the &lt;pageGraphics&gt; section, the changes we made to the font there do not affect the style of the text in the story, which begins, unstyled, with the default font and text size, until you change it.</para>

<para>Now you know how to style fixed and flowable text.</para>
