Integration of Font-Awesome

Hi all


I know, we can include additional Fonts specifying the font by adding the otf file:
  • txtFragment.TextState.Font = FontRepository.OpenFont(dataDir + “FontAwesome.otf”);

My question is, if there exists a way to integrate Font-Awesome in a Aspose Pdf Project (HtmlFragment / TextFragment)?

pdfDocument = new Document();
Page page = pdfDocument.Pages.Add();

TextFragment fragment = new TextFragment("\f005"); // fa-star
fragment.TextState.Font = FontRepository.OpenFont(dataDir + “FontAwesome.otf”);
fragment.TextState.Font.IsEmbedded = true;

page.Paragraphs.Add(fragment);

Thank you in advance…

All the best
David

Hi David,


Thanks for contacting support.

I am afraid currently it is not supported. However, I have logged an enhancement request PDFNET-42494 in our issue tracking system for further investigation and implementation. We will further look into the details of this enhancement and will keep you updated on the status of its implementation within this forum thread. Please be patient and spare us little time. We are sorry for the inconvenience.

Best Regards,

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; -webkit-text-stroke: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; -webkit-text-stroke: #000000; min-height: 15.0px}
span.s1 {font-kerning: none}
span.s2 {text-decoration: underline ; font-kerning: none; color: #9e4b2f; -webkit-text-stroke: 0px #9e4b2f}
Hi again..

I was now able to add Font Awesome in a TextFragment, just by adding the unicode:

Document pdfDocument = new Document();
Page page = pdfDocument.Pages.Add();

char unicode = '\uf005'; // star
TextFragment fragment = new TextFragment(unicode.ToString());
fragment.TextState.Font = FontRepository.OpenFont(dataDir + "FontAwesome.otf");
fragment.TextState.Font.IsEmbedded = true;

page.Paragraphs.Add(fragment);

Best regards
David

1 Like

Hi David,


Thanks for sharing your findings. I am glad to know you are able to use font awesome in TextFragment. Please keep using our API’s.

Best Regards,

Hi David,

Can you tell me how you created otf file.

Best Regards
Sandeep