-2

How to load a font file( ttf and otf) in angular using httpclient as a binary file to process with opentype.js. I have to extract svg paths from the font files loaded using angular http module. what should be the type i should mention in the service for the file like array buffer etc.

  • Don't make your site unnecessarily difficult to load for your users by using uncompressed, universal system OpenType formats. [Use the webfont versions (woff2/woff) instead](https://stackoverflow.com/questions/36105194/are-eot-ttf-and-svg-still-necessary-in-the-font-face-declaration/36110385#36110385) so that your fonts are smaller both due to built in compress, and due to throwing away all the data a universal system font needs to contain that is *entirely meaningless* for web use. – Mike 'Pomax' Kamermans Jul 01 '19 at 18:19
  • Opentype.js cant parse other types of fonts other than otf and ttf. – Jeeban Kishore Mohanty Jul 05 '19 at 09:56
  • That is a factually incorrect claim. OpenType.js has supported woff for over 2 years now. – Mike 'Pomax' Kamermans Jul 05 '19 at 15:29

1 Answers1

0

Set the appropriate responseType in GET request. https://angular.io/api/common/http/HttpRequest#responseType

this._http
    .get(url, { responseType: 'blob' }) // or 'arraybuffer'
    .subscribe(
        res => {
            // pass reaponse to opentype.js
        }
    );
Dimanoid
  • 6,999
  • 4
  • 40
  • 55