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

Allow options of GeistSans and GeistMono to be customizable #60

Open
2 tasks done
mwskwong opened this issue Nov 21, 2023 · 0 comments
Open
2 tasks done

Allow options of GeistSans and GeistMono to be customizable #60

mwskwong opened this issue Nov 21, 2023 · 0 comments
Labels
bug Something isn't working where: package The issue corresponds to the distribution package

Comments

@mwskwong
Copy link

mwskwong commented Nov 21, 2023

Font Name (Geist Sans/Geist Mono):

  • Geist Sans
  • Geist Mono

This is an enhancement instead of a bug. It would be great if we could customize the options of GeistSans and GeistMono. e.g. may be we can do

import localFont from 'next/font/local';

// since LocalFont is not exported from next/font/local
type LocalFont = Parameters<typeof localFont>[0];

// omitting src, clearly we don't want that part to be customizable.
export const GeistMono = (options?: Omit<LocalFont, 'src'>) =>
  localFont({
    src: './fonts/geist-mono/GeistMono-Variable.woff2',
    variable: '--font-geist-mono',
    adjustFontFallback: false,
    fallback: [
      'ui-monospace',
      'SFMono-Regular',
      'Roboto Mono',
      'Menlo',
      'Monaco',
      'Liberation Mono',
      'DejaVu Sans Mono',
      'Courier New',
      'monospace',
    ],
    ...options,
  });

export const GeistSans = (options?: Omit<LocalFont, 'src'>) =>
  localFont({
    src: './fonts/geist-sans/Geist-Variable.woff2',
    variable: '--font-geist-sans',
    ...options,
  });

Then we can allow users to customize the options they way they want, e.g. for my case, I want to prevent the monospace font from being preloaded.

const geistMono = GeistMono({ preload: false });

This syntax also matches that from next/font/google.

@mwskwong mwskwong added the bug Something isn't working label Nov 21, 2023
@mwskwong mwskwong changed the title Allow customizating options of GeistSans and GeistMono Allow options of GeistSans and GeistMono to be customizable Nov 21, 2023
@guidoferreyra guidoferreyra added the where: package The issue corresponds to the distribution package label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working where: package The issue corresponds to the distribution package
Projects
None yet
Development

No branches or pull requests

2 participants