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

Free Support Forum - aspose.com

How to install fonts in linux

i have tested in local machine which is Microsoft windows OS. aspose words is working fine and font also automatically loaded with out load fonts through code in windows machine. same code i have deployed the war file in tomact linux. font is not loaded correctly.

Options i am planning to try

  1. load the .tttf files /usr/share/fonts/
    2, install microsoft core fonts into linux os.

Please adivse at earliest

@vinayajo,

Thanks for your inquiry. Please refer to the following article.
How to Install True Type Fonts on Linux

You can also copy fonts from Windows and put them into a folder and use these fonts while importing document. Please check the following code example.

FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolder("/user/tahir/fonts", true);
LoadOptions loadOptions  = new LoadOptions();
loadOptions.setFontSettings(fontSettings);
Document doc = new Document(MyDir + "input.docx", loadOptions);

thanks. is it possible load from project eclipse ie from resources folder

@vinayajo,

Thanks for your inquiry. Yes, you can put the fonts into resource folder, get the path of resource folder, and use the fonts’ path in FontSettings.setFontsFolder method.

FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolder("...font folder...", true);

it is not working instead i have tried these below load the requirred fonts(ie. font1.ttf, font2.ttf) as byte array. it worked

ArrayList fontSources = new ArrayList(Arrays.asList(FontSettings.getFontsSources()));
// Add your custom font to the list.

MemoryFontSource memoryFontSource = new MemoryFontSource(your byte[] font data here);

fontSources.add(memoryFontSource);

// Convert the Arraylist of source back into a primitive array of FontSource objects.

FontSourceBase[] updatedFontSources = (FontSourceBase[]) fontSources.toArray(new FontSourceBase[fontSources.size()]);

// Apply the new set of font sources to use.

FontSettings.setFontsSources(updatedFontSources);

@vinayajo,

Thanks for your feedback. Yes, you can use MemoryFontSource to achieve your requirement. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

FontSettings fontSettings = new FontSettings();
fontSettings.setFontsFolder("…font folder…", true);

i have tried, there is no error but fonts are not loaded. do you have any idead? just to know

@vinayajo,

Thanks for your inquiry. Please make sure that you are passing correct path to FontSettings.setFontsFolder.

If you still face problem, please share the following detail for testing.

  • Your input Word document.
  • Please attach the output document file that shows the undesired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.