How does aspose support google noto font?

Hi,

Thanks for your inquiry. We are in coordination with our product team to get answer pertaining to your queries. Soon you will be updated with the required information.

Best regards,

Hi,

I think, the FontSubstitutes API (see FontSettings.AddFontSubstitutes and FontSettings.SetFontSubstitutes methods) should work for you. By default it already contains mapping from windows fonts to some of commonly used Linux fonts. However, you are free to add your own mappings. Or as an alternative you could change the fonts in the document model i.e. loop through the Run nodes collection and assign an appropriate Font to it.

Best regards,

Thanks a lot for the information.

I tried to use *FontSettings.AddFontSubstitutes and FontSettings.SetFontSubstitutes, but I am still seeing font not found warning.

Do I miss anything?

Here is my sample code:

static void test1(String name) throws Exception {
    System.out.println("Processing " + name);
    FontSettings.setFontsFolder(
            "fonts/",
            false);
    FontSettings.addFontSubstitutes("Cambria", new String[]{"Noto Sans CJK SC"});
    FontSettings.setFontSubstitutes("Cambria", new String[]{"Noto Sans CJK SC"});
    Document doc = new Document(name);
    PdfSaveOptions saveOptions = new PdfSaveOptions();
    HandleDocumentWarnings callback = new HandleDocumentWarnings();
    doc.setWarningCallback(callback);

    doc.save("/tmp/asianFonts.pdf", saveOptions);
}

static class HandleDocumentWarnings implements IWarningCallback
{
    public void warning(WarningInfo info)
    {
        System.out.println(info.getDescription());
        // We are only interested in fonts being substituted.
    }
}

I am still seeing warning:

Font ‘Cambria’ has not been found. Using ‘Times New Roman’ font instead.*

Hi,

Thanks for your inquiry. I tested the scenario with Aspose.Words 15.8.0 and was unable to reproduce this issue on my side. Both AddFontSubstitutes and SetFontSubstitutes methods are working fine on my end. Please make sure that 1) path you mentioned in setFontsFolder is correct and 2) substitute font name you specified in SetFontSubstitutes method is correct (right click on font file, select properties, go to details tab and their you’ll find “Title”).

Best regards,

Thanks for the information.

I am afraid that it worked for you because you are running in Microsoft/Mac environment where Microsoft fonts are installed.

Would you mind to run it in some Linux environment where there is no Microsoft fonts installed?

Thanks

I tried with Aspose.Words 15.8.0. I am still seeing the same warning message.

Then I tried to use FontForge to change font name to “Cambria” and created a new font file, for some reason, it is still not found. I am wondering which naming field Aspose is looking at.

About the font folder, I tested, it is correct folder. If I copied Microsoft fonts in that folder, program runs without problem; If I removed Microsoft fonts from that folder, warning message is showing up.

Thanks for the helping.

Hi,

Thanks for your inquiry. Please provide complete steps to reproduce this issue on Linux environment on my side.

Best regards,

In a unix machine where there is no microsoft fonts installed, please
extract the asianFonts.zip, compile and run A.java. asianFonts.pdf will
be generated, and you will see warning about fonts.

Thanks.

Hi,

Thanks for your inquiry. I was still unable to reproduce this issue on my side. I have performed the following steps for testing.

1- Downloaded and extracted ‘asianFonts.zip’ from your previous post at ‘Desktop’ of Linux
2- Executed the following code with absolute paths:

Document doc = new Document(getMyDir() + "/home/awais/Desktop/asianFonts/asianFonts.docx");
FontSettings.setFontsFolder("/home/awais/Desktop/asianFonts/fonts", false);
FontSettings.setFontSubstitutes("Cambria", new String[] { "Noto Sans CJK SC Regular" });
HandleDocumentWarnings handle = new HandleDocumentWarnings();

doc.setWarningCallback(handle);

doc.save("/home/awais/Desktop/asianFonts/15.8.0.pdf");

Best regards,

Very strange, I changed every path to absolute path. I am still seeing the warning message and the asian font is still not showing up.

I am using 15.8.0-jdk16.jar file

java -classpath lib/aspose-words-15.8.0-jdk16.jar:. A $@

If I copy microsoft fonts in the fonts folder, everything just worked. So I am stuck with no-microsoft fonts requirement.

Any suggestion to move forward?

Thanks.

Hi,

santi3santi3santi3:
If I copy microsoft fonts in the fonts folder, everything just worked.

By “fonts folder”, do you mean your custom fonts directory e.g.

  • /home/awais/Desktop/asianFonts/fonts

or the default fonts directories e.g.

  • /usr/share/fonts
  • /usr/local/share/fonts
  • /usr/X11R6/lib/X11/fonts

Please confirm.

PS: I didn’t place any MS font in my custom fonts folder and the scenario worked without warnings.

Best regards,

We put all the necessary font ttf/otf files under custom fonts folder. Assume I have no font file (especially easten asian fonts) installed in the default fonts directory.

Thanks.

Hi,

Thanks for your inquiry. It is not an issue with Aspose.Words for Java according to the tests we have performed so far on our end. We were able to setup font substitutes from Cambria to Noto font. It may be that something is wrong with your sets up . For example, in your code sample you use “Noto Sans CJK SC” font family name which is actually not a valid family name. It should be “Noto Sans CJK SC Regular” as mentioned in the code sample shared here.

Best regards,

Thanks for the information. The font can be replaced.

Thanks.

Thanks again for the information.

I noticed that after switch to Noto Sans’ font, I am seeing some truncated character at the end of words.

FontSettings.setFontSubstitutes("黑体", new String[]{"Noto Sans CJK TC Regular"});
FontSettings.setFontSubstitutes("MS 明朝", new String[]{"Noto Sans CJK SC Regular"});

In Chinese/Japanese output, The last character in each word are truncated. Please check the attachment.

Any suggestion?

Thanks.

Hi,

Thanks for your inquiry. Could you please create comparison screenshot which shows the problematic areas in Aspose.Words generated PDF and attach it here for our reference. We will investigate the issue on our end and provide you more information.

Best regards,

Thanks for taking look at the problem. Please check two png files, one is with google font using FontSettings.setFontSubstitutes() like what’s in the sample code, another is using microsoft fonts without FontSettings.setFontSubstitutes().

What I meant using google fonts or microsoft fonts is copy font otf/ttf files under my fonts folder.

You will see that the one with google font has trancated last characters, while the one with Microsoft fonts has problem.

Any suggestion?

Thanks

Hi,

Thanks for your inquiry. It may be that the problem occurs because the font(s) you are using on your side do not contain glyphs for particular Chinese/Japanese characters.

Best regards,