When processing the slideshow, I found that the recognized font is different from the font of the text in the source file. For example, in the source file I uploaded, the font of the text is Song Ti + Times New Roman, but I get the font when I get the font through the program The fonts are all Microsoft Yahei. What method should I use to obtain the correct font? The following is the method and process I currently use:font.7z (320.9 KB)
Presentation ppt = info.getPresentation();
ISlideCollection iSlides = ppt.getSlides();
for (int i = 0; i < iSlides.size(); i++) {
ISlide slide = iSlides.get_Item(i);
IShapeCollection shapes = slide.getShapes();
for (int j = 0; j < shapes.size(); j++) {
IShape shape = shapes.get_Item(j);
if (shape instanceof AutoShape) {
AutoShape autoShape = (AutoShape) shape;
ITextFrame textFrame = autoShape.getTextFrame();
IParagraphCollection paragraphs = textFrame.getParagraphs();
for (IParagraph paragraph : paragraphs) {
IPortionCollection portions = paragraph.getPortions();
for (IPortion portion : portions) {
IPortionFormat portionFormat = portion.getPortionFormat();
String fontName = "";
IFontData fontData = portionFormat.getEastAsianFont();
if (fontData != null) {
fontName = fontData.getFontName();
if (StringUtils.isEmpty(fontName) || "Arial".equalsIgnoreCase(fontName)) {
fontData = portionFormat.getLatinFont();
if (fontData != null) {
fontName = fontData.getFontName();
}
}
}
System.out.println("the font family of this portion is" + fontName);
}
}
}
}
}