Newer
Older
XML / modules / fonts.xml
nstanger on 21 Sep 2011 4 KB - Updated a couple of comments.
<?xml version="1.0" encoding="utf-8"?>

<!--
	Font and typeface control.
-->

<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<!-- Typewriter (monospaced) type. -->
	<template name="typewriter" match="typewriter|monospace|tt">
		<common formats="/latex/xelatex/">\texttt{<xsl:apply-templates />}</common>
		<common formats="/html/xhtml/"><tt><xsl:apply-templates /></tt></common>
	</template>
	
	<!-- Sans serif type. -->
	<template name="sans-serif" match="sans-serif|sans|ss|sf">
		<common formats="/latex/xelatex/">\textsf{<xsl:apply-templates />}</common>
		<common formats="/html/xhtml/"><font face="sans-serif"><xsl:apply-templates /></font></common>
	</template>
	
	
	<!--
		Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines.
	-->
	<template name="tiny" match="tiny">
		<common formats="/latex/xelatex/">{\tiny <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<xsl:apply-templates />
			</span>
			</span>
			</span>
			</span>
		</common>
	</template>
	
	<template name="scriptsize" match="scriptsize">
		<common formats="/latex/xelatex/">{\scriptsize <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<xsl:apply-templates />
			</span>
			</span>
			</span>
		</common>
	</template>
	
	<template name="footnotesize" match="footnotesize">
		<common formats="/latex/xelatex/">{\footnotesize <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:smaller;">
			<span style="font-size:smaller;">
			<xsl:apply-templates />
			</span>
			</span>
		</common>
	</template>
	
	<template name="small" match="small">
		<common formats="/latex/xelatex/">{\small <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:smaller;">
			<xsl:apply-templates />
			</span>
		</common>
	</template>
	
	<template name="large" match="large">
		<common formats="/latex/xelatex/">{\large <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:larger;">
			<xsl:apply-templates />
			</span>
		</common>
	</template>
	
	<!-- Fortunately, XML is case-sensitive. -->
	<template name="Large" match="Large">
		<common formats="/latex/xelatex/">{\Large <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<xsl:apply-templates />
			</span>
			</span>
		</common>
	</template>
	
	<template name="LARGE" match="LARGE">
		<common formats="/latex/xelatex/">{\LARGE <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<xsl:apply-templates />
			</span>
			</span>
			</span>
		</common>
	</template>
	
	<template name="huge" match="huge">
		<common formats="/latex/xelatex/">{\huge <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<xsl:apply-templates />
			</span>
			</span>
			</span>
			</span>
		</common>
	</template>
	
	<template name="Huge" match="Huge">
		<common formats="/latex/xelatex/">{\Huge <xsl:apply-templates />}</common>
		<common formats="/html/xhtml/">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<span style="font-size:larger;">
			<xsl:apply-templates />
			</span>
			</span>
			</span>
			</span>
			</span>
		</common>
	</template>
	

	<!-- Non-maths super- and subscript. -->
	<template name="superscript" match="superscript">
		<common formats="/latex/xelatex/">\ensuremath{^{\mathrm{<xsl:apply-templates />}}}</common>
		<common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common>
	</template>
	
	<template name="subscript" match="subscript">
		<common formats="/latex/xelatex/">\ensuremath{_{\mathrm{<xsl:apply-templates />}}}</common>
		<common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common>
	</template>

</stylesheet>