Skip to content

Commit 0fcda90

Browse files
committed
Defer cost of OSD tab font glyph render from tab initialization to time-of-use (cuts tab load time to roughly 1/3 of previous).
1 parent 1809bb8 commit 0fcda90

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/js/LogoManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ LogoManager.replaceLogoInFont = function (img) {
290290
LogoManager.drawPreview = function () {
291291
const $el = this.elements.$preview.empty();
292292
for (let i = this.logoStartIndex, I = this.font.constants.MAX_CHAR_COUNT; i < I; i++) {
293+
// Call this.font.draw to force the URL to be generated if it hasn't already
294+
this.font.draw(i);
293295
const url = this.font.data.character_image_urls[i];
294296
$el.append(`<img src="${url}" title="0x${i.toString(16)}"></img>`);
295297
}

src/js/tabs/osd.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ FONT.pushChar = function (fontCharacterBytes, fontCharacterBits) {
130130
}
131131
FONT.data.characters_bytes.push(fontCharacterBytes.slice(0));
132132
FONT.data.characters.push(fontCharacterBits.slice(0));
133-
FONT.draw(FONT.data.characters.length - 1);
134133
};
135134

136135
/**
@@ -262,6 +261,8 @@ FONT.upload = function ($progress) {
262261
FONT.preview = function ($el) {
263262
$el.empty();
264263
for (let i = 0; i < SYM.LOGO; i++) {
264+
// Call FONT.draw to force the URL to be generated if it hasn't already
265+
FONT.draw(i);
265266
const url = FONT.data.character_image_urls[i];
266267
$el.append(`<img src="${url}" title="0x${i.toString(16)}"></img>`);
267268
}
@@ -2769,6 +2770,10 @@ osd.initialize = function (callback) {
27692770
attach: $("#fontmanager"),
27702771
title: "OSD Font Manager",
27712772
content: $("#fontmanagercontent"),
2773+
onCreated: () => {
2774+
FONT.preview(fontPreviewElement);
2775+
LogoManager.drawPreview();
2776+
},
27722777
});
27732778

27742779
$(".elements-container div.cf_tip").attr("title", i18n.getMessage("osdSectionHelpElements"));
@@ -3506,8 +3511,6 @@ osd.initialize = function (callback) {
35063511
$(".font-manager-version-info").text(i18n.getMessage(`osdDescribeFontVersion${fontver}`));
35073512
$.get(`./resources/osd/${fontver}/${$font.data("font-file")}.mcm`, function (data) {
35083513
FONT.parseMCMFontFile(data);
3509-
FONT.preview(fontPreviewElement);
3510-
LogoManager.drawPreview();
35113514
updateOsdView();
35123515
$(".fontpresets option[value=-1]").hide();
35133516
});

0 commit comments

Comments
 (0)