@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 1.96 kB
JavaScript
import*as i18n from"../../core/i18n/i18n.js";import platformFontsWidgetStyles from"./platformFontsWidget.css.js";import*as UI from"../../ui/legacy/legacy.js";const UIStrings={renderedFonts:"Rendered Fonts",networkResource:"Network resource",localFile:"Local file",dGlyphs:"{n, plural, =1 {(# glyph)} other {(# glyphs)}}"},str_=i18n.i18n.registerUIStrings("panels/elements/PlatformFontsWidget.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class PlatformFontsWidget extends UI.ThrottledWidget.ThrottledWidget{sharedModel;sectionTitle;fontStatsSection;constructor(t){super(!0),this.sharedModel=t,this.sharedModel.addEventListener("ComputedStyleChanged",this.update,this),this.sectionTitle=document.createElement("div"),this.sectionTitle.classList.add("title"),this.contentElement.classList.add("platform-fonts"),this.contentElement.appendChild(this.sectionTitle),this.sectionTitle.textContent=i18nString(UIStrings.renderedFonts),this.fontStatsSection=this.contentElement.createChild("div","stats-section")}doUpdate(){const t=this.sharedModel.cssModel(),e=this.sharedModel.node();return e&&t?t.getPlatformFonts(e.id).then(this.refreshUI.bind(this,e)):Promise.resolve()}refreshUI(t,e){if(this.sharedModel.node()!==t)return;this.fontStatsSection.removeChildren();const n=!e||!e.length;if(this.sectionTitle.classList.toggle("hidden",n),!n&&e){e.sort((function(t,e){return e.glyphCount-t.glyphCount}));for(let t=0;t<e.length;++t){const n=this.fontStatsSection.createChild("div","font-stats-item");n.createChild("span","font-name").textContent=e[t].familyName;n.createChild("span","font-delimeter").textContent="—";n.createChild("span").textContent=e[t].isCustomFont?i18nString(UIStrings.networkResource):i18nString(UIStrings.localFile);const s=n.createChild("span","font-usage"),i=e[t].glyphCount;s.textContent=i18nString(UIStrings.dGlyphs,{n:i})}}}wasShown(){super.wasShown(),this.registerCSSFiles([platformFontsWidgetStyles])}}