You can use XMLHttpRequest to get font file and then convert it to base64. Here is code example:
index.tsx
functionloadFontAsBase64(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
if (this.status == 200) {
var uInt8Array = newUint8Array(this.response);
var i = uInt8Array.length;
var binaryString = newArray(i);
while (i--)
{
binaryString[i] = String.fromCharCode(uInt8Array[i]);
}
var data = binaryString.join('');
var base64 = window.btoa(data);
callback(base64);
}
};
xhr.send();
}
loadFontAsBase64('font.ttf', function(base64){
console.log(base64); // font file as base64 string});