Merge "Support bodyFont, monospaceFont, and localFontPath properties to make pdf fonts configurable."

This commit is contained in:
Jenkins
2014-03-21 15:45:34 +00:00
committed by Gerrit Code Review
4 changed files with 104 additions and 17 deletions

View File

@@ -228,12 +228,25 @@ public abstract class PDFMojo extends AbstractFoMojo {
private String draftStatus;
/**
*
*
* @parameter expression="${generate-webhelp.draft.status}" default-value=""
* @parameter expression="${generate-pdf.statusBarText}"
*/
private String statusBarText;
/**
* @parameter expression="${generate-pdf.bodyFont}"
*/
private String bodyFont;
/**
* @parameter expression="${generate-pdf.monospaceFont}"
*/
private String monospaceFont;
/**
* @parameter expression="${generate-pdf.localFontPath}"
*/
private String localFontPath;
protected void setImageDirectory (File imageDirectory) {
this.imageDirectory = imageDirectory;
}
@@ -365,7 +378,7 @@ public abstract class PDFMojo extends AbstractFoMojo {
protected Configuration loadFOPConfig() throws MojoExecutionException {
System.out.println ("At load config");
File fontPath = new File(getTargetDirectory().getParentFile(), "fonts");
File fontPath = (null != localFontPath && localFontPath != "")?new File(localFontPath):new File(getTargetDirectory().getParentFile(), "fonts");
StringTemplateGroup templateGroup = new StringTemplateGroup("fonts", fontPath.getAbsolutePath());
StringTemplate template = templateGroup.getInstanceOf("fontconfig");
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
@@ -435,7 +448,15 @@ public abstract class PDFMojo extends AbstractFoMojo {
if(null!=sysStatusBarText && !sysStatusBarText.isEmpty()){
statusBarText=sysStatusBarText;
}
transformer.setParameter("statusBarText", statusBarText);
if(statusBarText != null){
transformer.setParameter("statusBarText", statusBarText);
}
if(bodyFont != null){
transformer.setParameter("bodyFont", bodyFont);
}
if(monospaceFont != null){
transformer.setParameter("monospaceFont", monospaceFont);
}
transformer.setParameter("project.build.directory", projectBuildDirectory.toURI().toString());
@@ -561,6 +582,8 @@ public abstract class PDFMojo extends AbstractFoMojo {
map.put("outputType", "pdf");
map.put("strictImageValidation", String.valueOf(this.strictImageValidation));
map.put("status.bar.text", getProperty("statusBarText"));
map.put("bodyFont", getProperty("bodyFont"));
map.put("monospaceFont", getProperty("monospaceFont"));
map.put("draft.status", getProperty("draftStatus"));
// Profiling attrs:

View File

@@ -412,6 +412,23 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
*/
private String statusBarText;
/**
*
* @parameter expression="${generate-webhelp.bodyFont}"
*/
private String bodyFont;
/**
*
* @parameter expression="${generate-webhelp.monospaceFont}"
*/
private String monospaceFont;
/**
*
* @parameter expression="${generate-webhelp.localFontPath}"
*/
private String localFontPath;
/**
* DOCUMENT ME!
@@ -520,7 +537,6 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
transformer.setParameter("legal.notice.url", legalNoticeUrl);
}
String sysWebhelpWar=System.getProperty("webhelp.war");
if(null!=sysWebhelpWar && !sysWebhelpWar.isEmpty()){
webhelpWar=sysWebhelpWar;
@@ -548,6 +564,13 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
if(null != statusBarText){
transformer.setParameter("status.bar.text", statusBarText);
}
if(null != bodyFont){
transformer.setParameter("bodyFont", bodyFont);
}
if(null != monospaceFont){
transformer.setParameter("monospaceFont", monospaceFont);
}
if(canonicalUrlBase != null){
transformer.setParameter("canonical.url.base",canonicalUrlBase);
@@ -795,6 +818,8 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
map.put("strictImageValidation", String.valueOf(this.strictImageValidation));
map.put("trim.wadl.uri.count", this.trimWadlUriCount);
map.put("status.bar.text", getProperty("statusBarText"));
map.put("bodyFont", getProperty("bodyFont"));
map.put("monospaceFont", getProperty("monospaceFont"));
map.put("draft.status", getProperty("draftStatus"));
// Profiling attrs:
@@ -903,6 +928,9 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
pdfBuilder.setSecurity(security);
pdfBuilder.setDraftStatus(draftStatus);
pdfBuilder.setStatusBarText(statusBarText);
pdfBuilder.setBodyFont(bodyFont);
pdfBuilder.setMonospaceFont(monospaceFont);
pdfBuilder.setLocalFontPath(localFontPath);
pdfBuilder.setTrimWadlUriCount(trimWadlUriCount);
pdfBuilder.setComputeWadlPathFromDocbookPath(computeWadlPathFromDocbookPath);

View File

@@ -126,6 +126,9 @@ public class PDFBuilder {
private String draftStatus;
private String statusBarText;
private String bodyFont;
private String monospaceFont;
private String localFontPath;
private String trimWadlUriCount;
private String computeWadlPathFromDocbookPath;
private String pdfFilenameBase;
@@ -427,6 +430,13 @@ public class PDFBuilder {
if(null != statusBarText){
transformer.setParameter("status.bar.text", statusBarText);
}
if(null != bodyFont){
transformer.setParameter("bodyFont", bodyFont);
}
if(null != monospaceFont){
transformer.setParameter("monospaceFont", monospaceFont);
}
if(trimWadlUriCount != null){
transformer.setParameter("trim.wadl.uri.count",trimWadlUriCount);
}
@@ -506,7 +516,7 @@ public class PDFBuilder {
}
protected Configuration loadFOPConfig() throws MojoExecutionException {
String fontPath = (new File(getAutopdfTargetDirectory().getParentFile(), "fonts")).getAbsolutePath();
String fontPath = (null != localFontPath && localFontPath != "") ? localFontPath : (new File(getAutopdfTargetDirectory().getParentFile(), "fonts")).getAbsolutePath();
StringTemplateGroup templateGroup = new StringTemplateGroup("fonts", fontPath);
StringTemplate template = templateGroup.getInstanceOf("fontconfig");
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
@@ -764,6 +774,29 @@ public class PDFBuilder {
this.statusBarText = statusBarText;
}
public void setBodyFont(String bodyFont) {
this.bodyFont = bodyFont;
}
public String getBodyFont() {
return bodyFont;
}
public void setMonospaceFont(String monospaceFont) {
this.monospaceFont = monospaceFont;
}
public String getMonospaceFont() {
return monospaceFont;
}
public void setLocalFontPath(String localFontPath) {
this.localFontPath = localFontPath;
}
public String getLocalFontPath() {
return localFontPath;
}
public String getTrimWadlUriCount() {
return trimWadlUriCount;

View File

@@ -28,7 +28,9 @@
<xsl:variable name="profiled-nodes" select="exslt:node-set($profiled-content)"/>
<xsl:param name="rackspace.font">
<xsl:param name="monospaceFont"/>
<xsl:param name="bodyFont">
<xsl:choose>
<xsl:when test="starts-with(/*/@xml:lang, 'zh')">AR-PL-New-Sung</xsl:when>
<xsl:when test="starts-with(/*/@xml:lang, 'ja')">TakaoGothic</xsl:when>
@@ -38,6 +40,7 @@
<xsl:param name="monospace.font.family">
<xsl:choose>
<xsl:when test="$monospaceFont != ''"><xsl:value-of select="$monospaceFont"/></xsl:when>
<xsl:when test="starts-with(/*/@xml:lang, 'zh')">AR-PL-New-Sung</xsl:when>
<xsl:when test="starts-with(/*/@xml:lang, 'ja')">TakaoGothic</xsl:when>
<xsl:otherwise>monospace</xsl:otherwise>
@@ -183,7 +186,7 @@ set toc,title
<xsl:param name="use.extensions" select="1"/>
<xsl:param name="callouts.extension" select="1"/>
<xsl:param name="textinsert.extension" select="1"/>
<xsl:param name="title.fontset" select="$rackspace.font"/>
<xsl:param name="title.fontset" select="$bodyFont"/>
<!--
Don't use dingbats for things like the copyright symbol. Assume
our font already has it.
@@ -210,37 +213,37 @@ set toc,title
<!-- Root Text Properties -->
<xsl:attribute-set name="root.properties">
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
<xsl:attribute name="font-size">10.5pt</xsl:attribute>
</xsl:attribute-set>
<!-- Title Properties (Sections/Components) -->
<xsl:attribute-set name="component.title.properties">
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
<xsl:attribute name="color">rgb(196,0,34)</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="section.title.properties">
<xsl:attribute name="color">rgb(196,0,34)</xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="header.content.properties">
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="footer.content.properties">
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="formal.title.properties">
<xsl:attribute name="color">rgb(176,0,14)</xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="admonition.title.properties">
<xsl:attribute name="color">rgb(196,0,34)</xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$rackspace.font"/></xsl:attribute>
<xsl:attribute name="font-family"><xsl:value-of select="$bodyFont"/></xsl:attribute>
</xsl:attribute-set>