OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [docbook-apps] Specify FO output font size in xml element?


Thanks for the replies on this question, guys. Your suggestions helped me get to where I wanted to be. I ended up customizing some of the templates so I wouldn't have to change my XML source code (or retrain my fellow authors), although if I was starting from scratch I would use Bob's suggestion. I'm trying to move my team to an XSL-FO production environment, so the less they have to do, the better my buy-in rate will be. :)

I built a test to see if the role attribute for certain values had a value of 7pt,8pt,9pt... (you get the idea) and then if that returned true, I would create a variable with that value ($custom_font_size) and pass that variable to the fo:block so that the font size would work right. We use this technique for UNIX screen output in verbatim monospace sections (different template, same technique) and also for filenames in body text that would extend beyond the margins normally. Here is the code I used for the inline.monoseq template from inline.xsl:

	<xsl:template name="inline.monoseq">
		<xsl:param name="content">
			<xsl:call-template name="simple.xlink">
				<xsl:with-param name="content">
					<xsl:apply-templates/>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:param>
		
		<xsl:choose>
			<xsl:when test="@role = '6pt' or @role = '7pt' or @role = '8pt' or @role = '9pt' or @role = '10pt' or @role = '11pt' or @role = '12pt'">
				<xsl:variable name="custom_font_size">
					<xsl:value-of select="@role"/>
				</xsl:variable>
				<fo:inline xsl:use-attribute-sets="monospace.properties" keep-together.within-line="always" font-size="{$custom_font_size}">
					<xsl:if test="@dir">
						<xsl:attribute name="direction">
							<xsl:choose>
								<xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
								<xsl:otherwise>rtl</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
					</xsl:if>
					<xsl:copy-of select="$content"/>
				</fo:inline>
			</xsl:when>
			<xsl:otherwise>
				<fo:inline xsl:use-attribute-sets="monospace.properties" keep-together.within-line="always">
					<xsl:if test="@dir">
						<xsl:attribute name="direction">
							<xsl:choose>
								<xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
								<xsl:otherwise>rtl</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
					</xsl:if>
					<xsl:copy-of select="$content"/>
				</fo:inline>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

-----Original Message-----
From: Bob Stayton [mailto:bobs@sagehill.net] 
Sent: Saturday, April 06, 2013 8:01 AM
To: Eric Nordlund; Richard Hamilton
Cc: docbook-apps@lists.oasis-open.org
Subject: Re: [docbook-apps] Specify FO output font size in xml element?

Hi Eric,
The attribute-set approach can still be used, because an attribute-set is computed each time it is used. And a processing-instruction would be appropriate here to indicate font-size, since this is a formatting issue for FO output only.  Here is a customization that uses that.

You can set a default programlisting font size with a new parameter:

<xsl:param name="programlisting.fontsize">10pt</xsl:param>

and customize the attribute set this way:

<xsl:attribute-set name="monospace.verbatim.properties">
  <xsl:attribute name="font-size">
    <xsl:call-template name="programlisting.fontsize"/>
  </xsl:attribute>
</xsl:attribute-set>

It sets the attribute value with a template call each time it is used.  Then add this template to your customization to compute the font size in each
instance:

<xsl:template name="programlisting.fontsize">
  <xsl:variable name="font.size">
    <xsl:call-template name="dbfo-attribute">
      <xsl:with-param name="pis" select="processing-instruction('dbfo')"/>
      <xsl:with-param name="attribute">font-size</xsl:with-param>
    </xsl:call-template>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$font.size != ''">
      <xsl:value-of select="$font.size"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$programlisting.fontsize"/>
    </xsl:otherwise>
  </xsl:choose>

</xsl:template>


Then you can do something like this in your files to set a font-size for a given programlisting:

<programlisting><?dbfo font-size="8pt" ?>...

The processing instruction can be anywhere in the programlisting.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net

--------------------------------------------------
From: "Eric Nordlund" <nordlund@cray.com>
Sent: Friday, April 05, 2013 5:57 PM
To: "Richard Hamilton" <hamilton@xmlpress.net>
Cc: <docbook-apps@lists.oasis-open.org>
Subject: RE: [docbook-apps] Specify FO output font size in xml element?

> Thanks Richard. I have used the attribute sets for the entire 
> document, but some of my examples are too long to fit on the page and 
> I want to shrink the font size for only that instance so I can fit it 
> without compromising the rest of the verbatim blocks.
>
> In other words, I only want to apply these fine-grained customizations 
> on demand for individual instances, and not the entire document. The 
> reason I want to use the role="7pt" and width="0" is because our 
> entire document set uses these attributes for that purpose with our 
> FOSI publishing system. I'm trying to "port" our current system to 
> XSL-FO to make it more future-proof.
>
> Eric
>
> -----Original Message-----
> From: Richard Hamilton [mailto:hamilton@xmlpress.net]
> Sent: Friday, April 05, 2013 5:52 PM
> To: Eric Nordlund
> Cc: docbook-apps@lists.oasis-open.org
> Subject: Re: [docbook-apps] Specify FO output font size in xml element?
>
> Hi Eric,
>
> Take a look at the monospace.verbatim.properties attribute set. I know 
> you can set the font there. You may also be able to adjust the margins 
> (I haven't tried that in this context).
>
> Generally, I always look for attribute sets first when doing a 
> customization, because if you can get what you need done with the 
> attribute set, it will save you having to customize templates.
>
> Best Regards,
> Dick Hamilton
> -------
> XML Press
> XML for Technical Communicators
> http://xmlpress.net
> hamilton@xmlpress.net
>
>
>
> On Apr 5, 2013, at 5:35 PM, Eric Nordlund wrote:
>
>> Hi gang, I've had so much luck with this list this week. Thanks!
>>
>> I have some verbatim sections that I need to shrink the font size so 
>> the whole line fits on the page. I've modified the <xsl:template 
>> match="programlisting|screen|synopsis"> template in verbatim.xsl so 
>> that I can pass a width='1' attribute which sets the resulting 
>> fo:block to have 0pts indent left and right, which effectively opens my margins up.
>> Another thing I need to do is pass a role="8pt" or role="7pt" 
>> attribute that will shrink the font size down on those elements for 
>> the really long ones. Is that something anyone has done before that 
>> could share a sample with me?
>>
>> Am I even on the right track, or am I making things harder than they 
>> need to be?
>>
>> Thanks in advance!
>>
>> Eric Nordlund
>> Customer Documentation and Training
>> Cray Inc.
>> 901 5th Ave
>> Seattle, WA 98164
>> (206)701-2232
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
>> For additional commands, e-mail: 
>> docbook-apps-help@lists.oasis-open.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: 
> docbook-apps-help@lists.oasis-open.org
>
>
> 


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]