-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BIPM: add transparency/white text behind/above math object in Apache FOP Intermediate Format (IF) #90
Comments
Similar to color 'white', for hidden text we have to set the font family (same as for math object, for example 'STIX Two Math' ). And after math object we need to restore the font family to default (for normal text, for example 'Times New Roman'). <xsl:template match="mathml:math">
...
<fo:inline xsl:use-attribute-sets="mathml-style">
<xsl:if test="$namespace = 'bipm'">
<fo:inline color="white">​</fo:inline> <!-- zero width space -->
</xsl:if>
...
<fo:instream-foreign-object fox:alt-text="Math">
... then in intermediate xml format we get preceding and following elements <font family="STIX Two Math" color="#ffffff"/>
<image x="257301" y="2321" width="45962" height="10115" foi:struct-ref="6b">
<math
...
</image>
<font family="Times New Roman" color="#000000"/> so, no need to put the elements |
Issue occurred: FOP generates non-correct intermediate format xml with surrogate pairs. <mtext>𝖳</mtext> IF: <mtext>��</mtext> This issue was fixed in the main processing (XML->XSLT->XSL-FO->PDF) by setting UTF-16 encoding for transformer (on stage XSLT->XSL-FO):
but for (XML->XSLT->XSL-FO->IF->PDF) on stage 'XSL-FO->IF' has not effect. Need to be investigate. |
Fixed.
Fixed. |
It seems there is the issue with the font 'STIX Two Math' for text. <fo:block font-family="Arial">Arial: αβγ</fo:block>
<fo:block font-family="Times New Roman">Times New Roman: αβγ</fo:block>
<fo:block font-family="STIX Two Math">STIX Two Math: αβγ</fo:block>
<fo:block font-family="Source Han Sans">Source Han Sans: αβγ</fo:block> Rendered PDF (note: greek characters displayed as text, not vector image): Then select all text in Acrobat, copy and paste into 'Notepad++' (it allows to display non-standard chars): I.e.
Similar issue mentioned here: https://superuser.com/questions/92615/cannot-copy-non-latin-characters-from-pdf-document Information about embedded fonts: Note: STIXTwoMath font has Encoding: Custom vs. 'Identity-H' for another fonts. To do:
|
@Intelligent2013 for this issue can you report to https://github.com/stipub/stixfonts linking back to this issue? |
@ronaldtse it seems this issue relates to OTF font. There are OTF (https://github.com/stipub/stixfonts/tree/master/fonts/static_otf) and TTF (https://github.com/stipub/stixfonts/tree/master/fonts/static_ttf) versions of STIX Two Math. XSL-FO: <fo:block font-family="Arial">Arial: αβγ</fo:block>
<fo:block font-family="Times New Roman">Times New Roman: αβγ</fo:block>
<fo:block font-family="STIX Two Math OTF">STIX Two Math OTF: αβγ</fo:block>
<fo:block font-family="STIX Two Math TTF">STIX Two Math TTF: αβγ</fo:block>
<fo:block font-family="Source Han Sans">Source Han Sans: αβγ</fo:block> FOP font config: <font embed-url="file:/D:/Metanorma/fonts/STIXTwov2.13b171/STIXTwoMath-Regular.otf" kerning="yes">
<font-triplet name="STIX Two Math OTF" style="normal" weight="normal"/>
</font>
<font embed-url="file:/D:/Metanorma/fonts/STIXTwov2.13b171/STIXTwoMath-Regular.ttf" kerning="yes">
<font-triplet name="STIX Two Math TTF" style="normal" weight="normal"/>
</font> I don't sure yet that this issue relates to STIX Two Math OTF directly. May be Apache FOP can't works normally with OTF fonts. I'll check it. |
Some investigations results:
I've set it to 'full' and the copied text is correct: So looks like Apache FOP has the issue with OTF subset embedding. Therefore we have alternatives:
|
Here is first resulted PDF with hidden text (white color, transparency is not supported by FOP): For testing purposes, hidden text is just the sequence of chars from mathml (not xml). Later, it will be replaced on the ASCII math markup (from commented text inside mathml). |
@Intelligent2013 this is amazing. It mostly works. I think this is a winner! |
(Time for that blog post!) |
All done.
|
metanorma/bipm-si-brochure#118
<fo:instream-foreign-object
with the attribute@fox:actual-text
Example:
@foi:struct-id
and@fox:actual-text
image
with the attribute@foi:struct-ref
=fo:instream-foreign-object/@foi:struct-id
Example:
x
=image/@x
,y
=image/@height + @y
fo:instream-foreign-object/@fox:actual-text
- calculate font-size (font name see in the first preceding elementfont/@family
(example:<font family="Times New Roman"
) to bounding box with sizes@width
and@height
(need to be investigated how to do it)font
with the attribute@color
and get the value of@color
Example:
font
, then default value is#000000
(black color)image
:<font color="#FFFFFF"/>
(set white color for text, because there isn't information yet how to create transparent text)<text x="257301" y="12436" word-spacing="1166" foi:struct-ref="6b">...</text>
<font color="..."/>
(restore the value of text color to previous state, for example<font color="#000000"/>
)Need investigate how to:
The text was updated successfully, but these errors were encountered: