[go: up one dir, main page]

Skip to content

A tool for easy fetching & downloading fonts from Google Fonts

License

Notifications You must be signed in to change notification settings

Tomax47/gfscoute

Repository files navigation

GFScoute V1.0.0

License: MIT npm version Downloads

GFScoute Logo

Introduction

gfscoute is a npm tool designed for effortless fonts fetching & downloading from Google Fonts.

Features

  • Download By Name: GFScoute makes it easy to search & download the font by its name.
  • Multiple Extensions Support: The tool will download the font file locally in its original type [.tff, .woff2, etc...].

Installation

To install gfscoute, use npm:

npm install gfscoute

or yarn:

yarn add gfscoute

Usage

To use gfscoute, import or require the DownloadFont from the package:

import DownloadFont from "gfscoute";
const DownloadFont = require("gfscoute");

Example of calling the function /test/:

DownloadFont("Georgia")
  .then(console.log("Success"))
  .catch((error) => {
    console.log(error);
  });

The ScoutFont function can be called to search the font, and return a Boolean response:

import { ScouteFont } from "gfscoute";

const fontName = "Roboto";

ScouteFont(fontName)
  .then((resp) => {
    if (resp) {
        // Font found. Perform action...
    });
    } else {
      // Font could not be found.
    }
  })
  .catch((error) => {
    // Handle error
  });

Complete example:

"use client";

import { useState } from "react";
import DownloadFont from "gfscoute";

export default function Fonts() {
  const [fontName, setFontName] = useState("");

  const hadnleDownload = (name: string) => {
    DownloadFont(name)
      .then(() => console.log("Success"));
      .catch((error: Error) => {
        throw error;
      });
  };

  return (
    <>
      <h1>Type font's name</h1>
      <input
        id="fontName"
        value={fontName}
         => setFontName(e.target.value)}
      />
      <button  => hadnleDownload(fontName)}>
        {" "}
        Download Font
      </button>
    </>
  );
}

About

A tool for easy fetching & downloading fonts from Google Fonts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published