fix: add missing font metrics for Assistant (#7752)

This commit is contained in:
David Luzar 2024-03-06 10:53:37 +01:00 committed by GitHub
parent a38e82f999
commit 68b1fdb20e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -326,7 +326,8 @@ export const getVerticalOffset = (
fontSize: ExcalidrawTextElement["fontSize"],
lineHeightPx: number,
) => {
const { unitsPerEm, ascender, descender } = FONT_METRICS[fontFamily];
const { unitsPerEm, ascender, descender } =
FONT_METRICS[fontFamily] || FONT_METRICS[FONT_FAMILY.Helvetica];
const fontSizeEm = fontSize / unitsPerEm;
const lineGap = lineHeightPx - fontSizeEm * ascender + fontSizeEm * descender;
@ -953,6 +954,11 @@ const FONT_METRICS = {
ascender: 1977,
descender: -480,
},
[FONT_FAMILY.Assistant]: {
unitsPerEm: 1000,
ascender: 1050,
descender: -500,
},
} as Record<number, FontMetrics>;
export const getDefaultLineHeight = (fontFamily: FontFamilyValues) => {