Pages: 1
Print
Author Topic: Plugin and RenderX: how to make them communicate?  (Read 204 times)
Fa
Member

Posts: 22


« on: September 20, 2017, 01:16:26 AM »

Hi!

I am having a very hard time figuring out how to deal with fonts. From my previous experience on XMetaL 6 with DITA-OT 1.3, it was quite straightforward: you would set the font in e.g. commons-attr.xsl to logical font (e.g. Serif), then you would tell in font-mappings what that logical font corresponds to (according to the language, if not specified it reverts to default), e.g. default is "DefaultFont", Simplified Chinese is "CNFont", etc. and then in XEP you would give the font data.

E.g. if I wanted DefaultFont to be Arial, then

Code:
     
      <font-family name="Arial">
        <font>
          <font-data ttf="BAUHS93.TTF"/>
        </font>
        <font style="oblique">
          <font-data ttf="ariali.ttf"/>
        </font>
        <font weight="bold">
          <font-data ttf="arialbd.ttf"/>
        </font>
        <font weight="bold" style="oblique">
          <font-data ttf="arialbi.ttf"/>
        </font>
      </font-family>


And then when the text was translated into Chinese, and I wanted CNFont to be e.g. SimSun, I'd have

Code:
 
      <font-family name="CNFont" embed="true">
        <font><font-data ttc="Simsun.ttc"/></font>
      </font-family>

But I find that much has changed between 1.3 and 2.4, and there has probably has been much development in RenderX as well.

So I guess my first question is: does it still work like this (it doesn't seem so), and if it doesn't, what has changed?

And before I go any further, I also want to make sure that my plugin uses RenderX. I was under the impression that that was the default renderer that XMetaL uses, but I am not sure. Is it? If it is not, where do I set the renderer to be RenderX? (Or alternatively, how do I solve my problem using FOP?)

I have tried modifying the font data in the xep.xml file, but it doesn't seem to have any effect on my plugin output, not even on the English. However, changing the base-font in, e.g. common-attrs lets me choose the font I want for the pdf content, and the same goes for toc-attrs to select fonts for the TOC, etc.


Any hint is welcome!

Thank you!
Fa
« Last Edit: September 20, 2017, 05:12:59 AM by Fa » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2502



WWW
« Reply #1 on: September 20, 2017, 11:02:25 AM »

Yes, it should still function basically the same. RenderX has not changed this functionality (at least not to any degree that would change this behaviour that I'm aware of). One thing that has changed is the values in these files. More fonts have been added to the list of Windows font paths and that section has been enabled (in older versions that section was commented out).

Though RenderX XEP is licensed and configured for use with the DITA OT included with XMetaL Author Enterprise I don't think you can say it is the default rendering because different deliverable types use different engines to create their output.

These deliverables use RenderX XEP:
Book via RenderX
Book via Structured FrameMaker
XMetal Enhanced PDF via RenderX XEP
XMetaL Enhanced PDF via RenderX XEP and Acrobat Distiller

This deliverable uses Apache FOP (also included):
PDF via FO with default processing

These deliverables use Antenna House XSL Formatter:
XMetaL Enhanced PDF via Antenna House XSL Formatter
Logged
Fa
Member

Posts: 22


« Reply #2 on: September 21, 2017, 05:34:50 AM »

Thank you for your answer, Derek.

I thought I had managed to get it to work, but I just tested and it's not working as I thought it should.

In my commons-attrs.xsl file, I have my base font set as:

Code:
<xsl:attribute-set name="base-font">
<xsl:attribute name="font-family">sans-serif</xsl:attribute>
  </xsl:attribute-set>


Then I have applied that base font throughout the file using an __fo__root attribute set.

Code:
<xsl:attribute-set name="__fo__root" use-attribute-sets="base-font">

Note that I had to use "sans-serif", while I thought that "Sans" would have been the obvious choice, but it did not work, although they are listed as aliases in my font-mappings.xml (and "Sans" works for my xmfo plugin!!!)

Code:
    <aliases>
      <alias name="sans-serif">Sans</alias>
    </aliases>


Using "Sans" reverts to using a serif font (I'm not sure which one and I have no idea where it gets it from).

Anyway, font-mappings.xml defines Sans (so sans-serif, too, if aliases work) as using Arial as default

Code:
    <logical-font name="Sans">
      <physical-font char-set="default">
        <font-face>Arial</font-face>
      </physical-font>
....
          </logical-font>

From what I understand (and I've been able to test that using the xmfo plugin XMetal Enhanced PDF via RenderX XEP), Arial here is only a "face", you then point to the font files in the xep.xml file. In xep, I have Arial defined as follows:

Code:
      <font-family name="Arial">
        <font>
          <font-data ttf="arial.ttf"/>
        </font>
        <font style="oblique">
          <font-data ttf="ariali.ttf"/>
        </font>
        <font weight="bold">
          <font-data ttf="arialbd.ttf"/>
        </font>
        <font weight="bold" style="oblique">
          <font-data ttf="arialbi.ttf"/>
        </font>
      </font-family>

and I replaced the first font file with a totally different font, which makes the change obvious in the output:

     
Code:
<font-family name="Arial">
        <font>
          <font-data ttf="BAUHS93.ttf"/>
        </font>
        <font style="oblique">
          <font-data ttf="ariali.ttf"/>
        </font>
        <font weight="bold">
          <font-data ttf="arialbd.ttf"/>
        </font>
        <font weight="bold" style="oblique">
          <font-data ttf="arialbi.ttf"/>
        </font>
      </font-family>

This works with the xmfo plugin, i.e. I see the Bauhaus font used wherever the regular sans (or sans-serif) font should be used when generating, but I see no change in my own plugin.

Another very odd thing is that, as stated above, in the xmfo plugin, I can use "Sans" and not "sans-serif", and it is recognized, but as I said, my own plugin only recognizes "sans-serif".

So to summarize, my plugin applies the correct font when I refer to "sans-serif", but when I use "Sans" (which works for xmfo), it just falls back to to a serif font, and I don't know what that fall back mechanism is, neither where the said serif font is defined. And this is very annoying, because before I figure that out for default (US English) documents, I won't be able to get my other languages to work with different fonts (Chinese at the moment only shows hashtags ## instead of the Chinese glyphs, although Sans and Serif are both mapped in Font Mappings and xep to Chinese fonts).

I'm kind of short of ideas about what to do or try next, so I'd really appreciate a small nudge in the right direction. Ideas anyone?

And by the way, is there a way to know for sure that my plugin uses renderX? Where is the pdf renderer defined?

Thanks!
Fa
« Last Edit: September 21, 2017, 05:36:33 AM by Fa » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2502



WWW
« Reply #3 on: September 22, 2017, 01:49:10 PM »

Quick answer before I try to start digging into the other stuff.

To test if whatever deliverable you are using uses RenderX I would just change the name of the RenderX folder. That will break output. Change it back and it will work. If not, then it is using another rendering engine (the only other one installed with XMetaL Author Enterprise is Apache FOP; Antenna House XSL Formatter needs to be purchased and installed by you).

As for "Sans" vs "sans-serif", those names are going to be used in the XSLFO (generated by the XSLT), so I think you should just search for them in the .xsl files inside the plug-in to see where they are called. Most likely "sans-serif" is used and "Sans" is not, in which case the "fallback" is going to be whatever default font family the PDF spec states is the default which will be one of Arial, Helvetica, Courier or Symbol (which make up the 14 default fonts that must be shipped with a PDF rendering engine, if it follows the PDF spec).
Logged
Fa
Member

Posts: 22


« Reply #4 on: September 25, 2017, 06:10:43 AM »

Thank you Derek!

As I suspected, my plugin is not using XEP, but FOP. Even with the RenderX folder renamed it produces the same layout.

This might explain why the xmfo plugin recognizes "Sans", and my custom plugin requires "sans-serif". My custom plugin only uses sans-serif, serif and monospaced, I have no reference to any font name, so the "fallback" fonts are probably those you cited, referenced in the pdf2 plugin.

I have tried changing throughout my plugin all fop references to xep references, but that breaks the output.

The files I have modified are:

xsl/fo/topic2fo_shell_fop.xsl renamed to xsl/fo/topic2fo_shell_xep.xsl (I have also modified the integrator.xml file reference to the file to reflect this name change) and modified as follows:

Code:
  <xsl:import href="plugin:org.dita.pdf2.fop:cfg/fo/attrs/commons-attr_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:cfg/fo/attrs/tables-attr_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:cfg/fo/attrs/toc-attr_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:xsl/fo/root-processing_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:xsl/fo/index_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:xsl/fo/tables_fop.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.fop:xsl/fo/flagging_fop.xsl" />

Changed to

Code:
   <xsl:import href="plugin:org.dita.pdf2.xep:cfg/fo/attrs/commons-attr_xep.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.xep:cfg/fo/attrs/layout-masters-attr_xep.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.xep:xsl/fo/root-processing_xep.xsl" />
  <xsl:import href="plugin:org.dita.pdf2.xep:xsl/fo/index_xep.xsl" />


In cfg/fo/attrs/basic-settings.xsl, I changed the line
Code:
  <xsl:param name="pdfFormatter" select="'fop'" />

to

Code:
  <xsl:param name="pdfFormatter" select="'xep'" />

Are there some files at a higher level (e.g. DITA_OT level) that would require editing for this to work, or is this the wrong approach?

Also, should I define another plugin under "require" in plugin.xml? Currently it is set to
Code:
  <require plugin="org.dita.pdf2" />

Thank you!

Logged
Pages: 1
Print
Jump to: