You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2023/11/13 18:54:15 UTC

[Bug 68137] New: PPTX2PNG doesn't use fonts supplied via -fontdir

https://bz.apache.org/bugzilla/show_bug.cgi?id=68137

            Bug ID: 68137
           Summary: PPTX2PNG doesn't use fonts supplied via -fontdir
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: jkellyinsf@hotmail.com
  Target Milestone: ---

The experience:

1. Install a distinctive TTF font into Windows. I used Agbalumo from
fonts.google.com.
2. Using PowerPoint app, create a PPTX that uses it.
3. Uninstall the font from Windows.
4. Use PPTX2PNG to render the PPTX as a PDF, providing -fontdir option to .ttf
file.
5. PDF gets rendered using Arial or similar default sans-serif font.

I've confirmed in the debugger that PDFFontMapper is indeed finding and reading
the font, but it doesn't end up getting used.  DrawTextParagraph calls this
code in DrawFontManagerDefault:

   @Override
    public Font createAWTFont(Graphics2D graphics, FontInfo fontInfo, double
fontSize, boolean bold, boolean italic) {
        int style = (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0);
        Font font = new Font(fontInfo.getTypeface(), style, 12);
        if (Font.DIALOG.equals(font.getFamily())) {
            // SansSerif is a better choice than Dialog
            font = new Font(Font.SANS_SERIF, style, 12);
        }
        return font.deriveFont((float)fontSize);
    }

Things go south during the call to font.getFamily(), which causes a call to
SunFontManager.findFont2D that initializes the system fonts, doesn't find our
special one, and returns a composite font from the DIALOG family.

Seems to me this could work if PDFFontMapper.registerFonts actually registered
the fonts with SunFontManager, but it doesn't; it just populates its own
internal map. How is -fontdir resolution supposed to work?

I've also tried embedding the font within the PPTX file, which doesn't work
either, though I haven't tracked down whether it goes wrong for the same
reason.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 68137] PPTX2PNG doesn't use fonts supplied via -fontdir

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=68137

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org