Results 1 to 1 of 1
Thread: typeface font family precedence
- 01-04-2017, 10:59 PM #1
Member
- Join Date
- Jan 2017
- Posts
- 1
- Rep Power
- 0
typeface font family precedence
I'm hitting some font/tofu problems using the POI library to render a PNG image from XSLFSlide, and it looks to be a latin/ea/cs precedence issue (or lack thereof). Specifically, it appears as though POI 3.15 in the XSLFTextRun.getFontFamily() method is *ONLY* looking for the <latin typeface="foo"> elements, and ignoring the <ea> and <cs> typeface elements. This is a problem for some PPTX files I'm converting, which have 'ambiguous' typeface declarations.
To wit, a pptx slide (from the pptx zip archive: ppt/slides/slide1.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:cSld>
...yadda...
<p:txBody>
<a:p>
<a:pPr>
<a:lnSpc>
<a:spcPct val="100000"/>
</a:lnSpc>
</a:pPr>
<a:r>
<a:rPr lang="en-US" sz="2800">
<a:solidFill>
<a:srgbClr val="44546a"/>
</a:solidFill>
<a:latin typeface="Comic Sans MS"/>
<a:ea typeface="宋体"/>
</a:rPr>
<a:t>B</a:t>
</a:r>
<a:r>
<a:rPr lang="en-US" sz="2800">
<a:solidFill>
<a:srgbClr val="44546a"/>
</a:solidFill>
<a:latin typeface="Comic Sans MS"/>
<a:ea typeface="宋体"/>
</a:rPr>
<a:t>.书对桌面的压力与桌面对书的支持力</a:t>
</a:r>
<a:endParaRPr/>
</a:p>
</p:txBody>
...etc...
for completeness, i'm using the POI library to render the png essentially like this:
org.apache.poi.xslf.usermodel.XSLFSlide slide = ...
java.awt.BufferedImage image = new java.awt.BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
java.awt.Graphics2D graphics2D = image.createGraphics();
slide.draw(graphics2D);
javax.imageio.ImageIO.write(image, "PNG", new File("/tmp/sad_panda"));
which eventually states:
>>I guess this is the question. How do you figure out weither it's latin/ea/cs from the characers? Is it just looking for a particular set of codepages based on all the text, some of the text, or something else? Is it mulitple codepages?
...We use UNICODE sub ranges + some Windows APIs to decide this....
perhaps reading too much into that msdn post, but it definitely reads to me like there needs to be more logic around the POI 'XSLFTextRun.getFontFamily()' call. At a minimum it needs to look for the 'ea' or 'cs' elements if 'latin' is not present, but preferable there should be some sort of java.awt.Font.canDisplay() or java.awt.Font.canDisplayUpTo() call to ensure the text run text can be rendering using a specified font.
To throw some gas on the fire, the pptx file renders correctly (ie, sans tofu) in libre office, but I haven't gone digging through that codebase to determine how they are determining the correct font.
rfc
Similar Threads
-
Program that takes in family members calculate family's average age and prints out ai
By bennzk4 in forum New To JavaReplies: 18Last Post: 03-10-2014, 03:09 AM -
Please help, the combo content is not rendering into the font family type!
By willemjav in forum AWT / SwingReplies: 6Last Post: 02-12-2014, 07:34 PM -
Set Font Color, Font Style & Font Family While Replacing Text
By sherazam in forum Java SoftwareReplies: 0Last Post: 08-18-2010, 11:31 AM -
How to change font/ font color etc in a graphic object using JCombobox?
By JavaInLove in forum AWT / SwingReplies: 5Last Post: 04-25-2009, 09:00 PM -
Dialog typeface outside Java
By Dreen in forum New To JavaReplies: 1Last Post: 11-19-2007, 08:35 AM
Bookmarks