We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF for java - how to set font fallback

1.If it is not possible to express with the set font-family when expressing in multiple languages, is it possible to set the font-family for a specific language?
ex) 안녕하세요abcdefg - text, Arial - font-famliy
When the font-family of the above string is set to Arial, Korean cannot be expressed in Arial. I want to set Korean font fallback.

@kkr3606

You can set the font-family for a specific language using Aspose.PDF. Could you please share the input and problematic PDF files along with code example that you are using to reproduce the same issue at our end?

Test Code :
Document pdfDocument = new Document();
Page pdfPage = (Page)pdfDocument.getPages().add();
TextFragment textFragment = new TextFragment(“안녕하세요abcdefg”);
textFragment.setPosition (new Position(100, 600));
Font font = FontRepository.findFont(“Arial”);
font.setEmbedded(false);
font.setSubset(false);
textFragment.getTextState().setFontSize(20);
textFragment.getTextState().setHorizontalAlignment(HorizontalAlignment.Center);
textFragment.getTextState().setFont(font);
TextBuilder textBuilder = new TextBuilder(pdfPage);
textBuilder.appendText(textFragment);
pdfDocument.save(“aspose_sample.pdf”);
pdfDocument.close();

I Set input text “안녕하세요abcdefg” and set font family “Arial”.
as result, “안녕하세요” is expressed font “ArialUniCodeMS” and “abcdefg” is is expressed font “Arial”.
I want to set korean language font fallback by “Batang”.
When font-family cannot express characters, How do I set font fallback each language?

@kkr3606

If you set the font name of text ‘안녕하세요’ as Arial using Adobe writer, the font name is changed.

There is no fallback settings for a single text fragment. Aspose.PDF does not choose separate fonts on the basis of characters in a single text fragment. You can only apply font at a text fragment or text segment level.

Could you please share your expected output PDF? We will then log this issue in our issue tracking system.