Skip to content

Commit

Permalink
Added "Save XML" button, it works
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorp committed May 24, 2024
1 parent ebbb881 commit 6e7a42e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fencer.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ <h2>XML</h2>
<div class="content" style="height: 100%;">
<div class="extra">
<button id="toggle-xml">Toggle XML</button>
<button id="save-xml">Save XML</button>
<button class="zoom out">zoom_out</button>
<button class="zoom in">zoom_in</button>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/fencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,17 @@ function initFencer() {
Q(".mappings .xml").classList.toggle("hidden");
};

// save XML
Q("button#save-xml").onclick = e => {
//const uint8 = new Uint8Array(GLOBAL.fontBuffer.buffer);
const fauxLink = EL("a");
fauxLink.download = "fencer.xml";
fauxLink.href = "data:application/xml;charset=UTF-8," + encodeURIComponent(Q(".mappings .xml").value);
document.body.append(fauxLink); // needed for Firefox, not Chrome or Safari
fauxLink.click();
fauxLink.remove();
};

// load initial font
const filename = "SofiaSans-VF.ttf"; // or "RobotoA2-avar2-VF.ttf";
const filepath = "../fonts/" + filename;
Expand Down

0 comments on commit 6e7a42e

Please sign in to comment.