From 7405a9210045b6af486ca791d94c2472b8dd85c4 Mon Sep 17 00:00:00 2001 From: Fatih Erikli Date: Mon, 4 Dec 2023 16:30:17 +0300 Subject: [PATCH] Display the glyph by codepoint if the glyph name contains dot --- .../views/editor/panel-reference-font.js | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/fontra/views/editor/panel-reference-font.js b/src/fontra/views/editor/panel-reference-font.js index 7f22c55e18..4a4777aca8 100644 --- a/src/fontra/views/editor/panel-reference-font.js +++ b/src/fontra/views/editor/panel-reference-font.js @@ -319,9 +319,44 @@ export default class ReferenceFontPanel extends Panel { this.editorController.sceneSettings.glyphLines ); - const letter = this.model.charOverride || selectedGlyphInfo?.character; + let textToDisplay; - if (!letter) { + if (this.model.charOverride) { + textToDisplay = this.model.charOverride.charAt(0); + } else { + if (selectedGlyphInfo) { + if (selectedGlyphInfo.glyphName.includes(".")) { + const baseGlyphName = selectedGlyphInfo.glyphName.split(".")[0]; + const codePoint = (this.editorController.fontController.glyphMap[ + baseGlyphName + ] || [])[0]; + if (codePoint) { + textToDisplay = String.fromCodePoint(codePoint); + } + } else { + textToDisplay = selectedGlyphInfo.character; + } + } + } + + if (!textToDisplay) { + return; + } + + if ( + !textToDisplay && + selectedGlyphInfo && + selectedGlyphInfo.glyphName.includes(".") + ) { + const baseGlyphName = positionedGlyph.glyphName.split(".")[0]; + const codePoint = (this.editorController.fontController.glyphMap[baseGlyphName] || + [])[0]; + if (codePoint) { + textToDisplay = String.fromCodePoint(codePoint); + } + } + + if (!textToDisplay) { return; } @@ -340,7 +375,7 @@ export default class ReferenceFontPanel extends Panel { for (const font of this.model.fontList) { await this.ensureFontLoaded(font); currentCharacter.appendChild( - span({ style: `font-family: ${font.fontIdentifier};` }, [` ${letter}`]) + span({ style: `font-family: ${font.fontIdentifier};` }, [` ${textToDisplay}`]) ); } container.appendChild(currentCharacter);