Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vercel OG] Missing kerning when using custom font #413

Open
mwskwong opened this issue Mar 1, 2023 · 1 comment
Open

[Vercel OG] Missing kerning when using custom font #413

mwskwong opened this issue Mar 1, 2023 · 1 comment

Comments

@mwskwong
Copy link

mwskwong commented Mar 1, 2023

Bug report

Description / Observed Behavior

If the image generated by @vercel/og contains texts, those texts will not have the kerning correctly applied when using a custom font.
image

Expected Behavior

Kerning is applied.
image

Reproduction

Unable to demonstrate with https://og-playground.vercel.app, so I created a Next.js repo instead:

HTML: https://vercel-og-kerning.vercel.app/
OG: https://vercel-og-kerning.vercel.app/api/og
Repo: https://github.com/mwskwong/vercel-og-kerning

@pixelass
Copy link

I am experiencing a similar issue where the line-height is different, but it seems to happen more on some fonts than on others. I'm not sure if this is related but it sounds like it could since it is related to the spacing of letters. I notice greater issues with irregular fonts.

While creating the comparison images I also noticed that ligatures don't seem to be rendered correctly (see last example "Henny Penny" which uses ligatures on some repeating letters "ee" "ff" "oo"...)

HTML uses Next/font (google-fonts)

export const montserrat = createMontserrat({
  weight: ["900"],
  subsets: ["latin"],
});

Satori uses TTF downloaded from google-fonts

const montserrat = await fetch(
  new URL("../../../ions/assets/Montserrat/Montserrat-Black.ttf", import.meta.url)
).then(response => response.arrayBuffer());

I explicitly set several values trying to ensure consistent rendering:

const style = {
  fontWeight: "400",
  fontSize: "20px,
  fontFamily: "Montserrat",
  fontStyle: "normal",
  lineHeight: "1.5",
  letterSpacing: "0",
}

There are cases where the line-height is a higher and some where it's lower

HTML Satori
HTML Satori
HTML Satori

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants