Skip to content

Commit

Permalink
Display the glyph by codepoint if the glyph name contains dot
Browse files Browse the repository at this point in the history
  • Loading branch information
fatih-erikli committed Dec 4, 2023
1 parent a1ffacd commit 7405a92
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/fontra/views/editor/panel-reference-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit 7405a92

Please sign in to comment.