Skip to content

Commit

Permalink
Only load the profile font
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Nov 16, 2023
1 parent 70217dc commit edd2821
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -18,4 +18,5 @@ DerivedData
node_modules
*.tgz
*.log
.DS_Store
.DS_Store
dist/
4 changes: 2 additions & 2 deletions Archipelago.xcodeproj/project.pbxproj
Expand Up @@ -193,19 +193,19 @@
011B143F2ADE1664000822F4 /* archipelago */ = {
isa = PBXGroup;
children = (
01847B972B055C5700BDB881 /* MenuItems */,
0166EE5D2AE625FF00061485 /* AboutController.swift */,
0195E7712AE9E5E1003EDDD2 /* App.swift */,
01847B922B02F6DC00BDB881 /* Font.swift */,
011B14402ADE1664000822F4 /* AppDelegate.swift */,
011B144C2ADE1665000822F4 /* archipelago.entitlements */,
0166EE592AE55B4C00061485 /* archipelagoRelease.entitlements */,
011B14462ADE1665000822F4 /* Assets.xcassets */,
0166EE792AE8AD1100061485 /* Config.swift */,
011B14442ADE1664000822F4 /* Document.swift */,
0166EE652AE73FC700061485 /* DraggingView.swift */,
01847B922B02F6DC00BDB881 /* Font.swift */,
011B144B2ADE1665000822F4 /* Info.plist */,
011B14762ADE1A7A000822F4 /* Main.storyboard */,
01847B972B055C5700BDB881 /* MenuItems */,
0166EE7B2AE9C16100061485 /* NSColor.swift */,
0166EE772AE8961D00061485 /* PreferenceFile.swift */,
01108D952AE4C23E00603FBF /* Pty.swift */,
Expand Down
14 changes: 9 additions & 5 deletions archipelago/ViewController.swift
Expand Up @@ -61,11 +61,15 @@ class ViewController: NSViewController, WKUIDelegate, NSWindowDelegate, BridgeDe
}

private func monospsaceFontStylesheet() -> String {
return """
document.addEventListener('DOMContentLoaded', () => {
window.fonts = \(App.fonts.map { $0.as_json() })
});
"""
if let font = App.fonts.first(where: { $0.name == App.preferenceFile.activeProfile().fontFamily }) {
return """
document.addEventListener('DOMContentLoaded', () => {
window.font = \(font.as_json())
});
"""
} else {
return ""
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions archipelago/WebView/application.min.js
Expand Up @@ -24847,7 +24847,9 @@ class terminal_controller_default extends BridgeComponent {
this.element.append(this._wrapperElement);
this.xterm.open(this._xtermElement);
this.xterm.loadAddon(this.webglAddon);
this.xterm.loadAddon(this.ligaturesAddon);
if (this.profile.ligatures) {
this.xterm.loadAddon(this.ligaturesAddon);
}
this.bindListeners();
this.fit();
this.xterm.focus();
Expand Down Expand Up @@ -24967,7 +24969,7 @@ class terminal_controller_default extends BridgeComponent {
// controllers/font_loader_controller.js
class font_loader_controller_default extends Controller {
connect() {
this.fonts = window.fonts.map((font) => JSON.parse(font));
this.fonts = [JSON.parse(window.font)];
let css = this.fonts.map((font) => {
return `@font-face {
font-family: '${font.name}';
Expand Down
2 changes: 1 addition & 1 deletion archipelago/WebView/controllers/font_loader_controller.js
Expand Up @@ -2,7 +2,7 @@ import {Controller} from '@hotwired/stimulus'

export default class extends Controller {
connect() {
this.fonts = window.fonts.map(font => JSON.parse(font))
this.fonts = [JSON.parse(window.font)]

let css = this.fonts.map((font) => {
return `@font-face {
Expand Down
4 changes: 3 additions & 1 deletion archipelago/WebView/controllers/terminal_controller.js
Expand Up @@ -95,7 +95,9 @@ export default class extends BridgeComponent {
this.element.append(this._wrapperElement);
this.xterm.open(this._xtermElement);
this.xterm.loadAddon(this.webglAddon);
this.xterm.loadAddon(this.ligaturesAddon);
if (this.profile.ligatures) {
this.xterm.loadAddon(this.ligaturesAddon);
}

this.bindListeners();
this.fit();
Expand Down

0 comments on commit edd2821

Please sign in to comment.