|
|
@@ -18,7 +18,7 @@
|
|
|
* along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
-/* global window, addEventListener, dispatchEvent, CustomEvent, document, HTMLDocument */
|
|
|
+/* global window, addEventListener, dispatchEvent, CustomEvent, document, HTMLDocument, FileReader, Blob */
|
|
|
|
|
|
this.hooksFrame = this.hooksFrame || (() => {
|
|
|
|
|
|
@@ -64,11 +64,20 @@ this.hooksFrame = this.hooksFrame || (() => {
|
|
|
if (descriptors) {
|
|
|
Object.keys(descriptors).forEach(descriptor => {
|
|
|
if (FONT_STYLE_PROPERTIES[descriptor]) {
|
|
|
- detail[FONT_STYLE_PROPERTIES[descriptor]] = descriptors[descriptor]
|
|
|
+ detail[FONT_STYLE_PROPERTIES[descriptor]] = descriptors[descriptor];
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
+ if (detail.src instanceof ArrayBuffer) {
|
|
|
+ const reader = new FileReader();
|
|
|
+ reader.readAsDataURL(new Blob([detail.src]));
|
|
|
+ reader.addEventListener("load", () => {
|
|
|
+ detail.src = "url(" + reader.result + ")";
|
|
|
+ dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ dispatchEvent(new CustomEvent(NEW_FONT_FACE_EVENT, { detail }));
|
|
|
+ }
|
|
|
return new FontFace(...argumentsList);
|
|
|
}
|
|
|
}));
|