Coder Social home page Coder Social logo

samuelmeuli / font-manager Goto Github PK

View Code? Open in Web Editor NEW
27.0 2.0 26.0 456 KB

πŸ—‚ Manages, downloads and applies Google Fonts for picker components

License: MIT License

JavaScript 1.90% TypeScript 85.89% CSS 12.21%
google-fonts font-picker fonts

font-manager's Introduction

Font Manager

Internal dependency for the font-picker and font-picker-react packages. It is used for managing the list of fonts, keeping track of the active font and downloading/activating Google Fonts.

font-manager's People

Contributors

dependabot[bot] avatar samuelmeuli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

font-manager's Issues

Currently incompatible with Nextjs/SSR

Hi,

thanks for this! Technically coming from font-picker-react, but the underlying issue is in here.

Currently, importing FontPicker imports font-manager, which imports loadFontPreviews, which imports dependencies from './font-styles/declarations.

When initially loading that file, it will instantly try append a style element to <head>.

Can probably be easily fixed by something like:

let previewFontsStylesheet: HTMLStyleElement;

/**
 * Add declaration for applying the specified preview font
 */
export function applyFontPreview(previewFont: Font, selectorSuffix: string): void {
	if(!previewFontsStylesheet && typeof document !== 'undefined') {
		previewFontsStylesheet = document.createElement('style');
		document.head.appendChild(previewFontsStylesheet);
	}

	const fontId = getFontId(previewFont.family);
	const style = `
			#font-button-${fontId}${selectorSuffix} {
				font-family: "${previewFont.family}";
			}
		`;
	previewFontsStylesheet.appendChild(document.createTextNode(style));
}

Add `oneOfVariants` option

Hi. Thanks for sharing your module.

I would like to use https://fonts.google.com/specimen/UnifrakturCook which is not available in regular variant. So if I add 700 to the variants I would expect it to be loaded but as i see it is explicitly omitting the font if merely a subset of the desired variants is included in the font.

How can I have for example Average Sans, Open Sans, UnifrakturCook, UnifrakturMaguntia in one combined menu?

imho it should not be needed to have a font matching every variant as specified in the variants but at least one.

like, instead of

this.options.variants.every((variant: Variant): boolean => font.variants.includes(variant))

rather the following:

font.variants.filter( variant =>  this.options.variants.includes(variant) ).length

Is that a change request you would accept or would you rather have a new property among the lines of oneOfVariants: ['700', 'regular'] ?

Default font loaded does not populate links & more from getActiveFont()

For my project I need to fetch the font file / link from the active font and pass it along to a database after I click submit. But the default loaded font only shows family and id for the font. You can see the image below where I fetched activefont for the default font and after the information from a font selected afterwards.

Is there an easier way to do this, or a way to add this information for the default font as well?

image

font-picker is golden btw!

Regards
BjΓΈrn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.