1.0.1 • Published 10 months ago

gfscoute v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

GFScoute V1.0.0

License: MIT

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/:

import { DownloadFont, ScouteFont } from "gfscoute";

const fontName = "Roboto";

ScouteFont(fontName)
  .then((resp) => {
    if (resp) {
      DownloadFont(fontName)
        .then(console.log("Success"))
        .catch((error) => {
          // Handle the error as you want here
          console.log(error);
        });
    } else {
      // Hadnle font not found case
    }
  })
  .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}
        onChange={(e) => setFontName(e.target.value)}
      />
      <button onClick={() => hadnleDownload(fontName)}>
        {" "}
        Download Font
      </button>
    </>
  );
}
1.0.1

10 months ago

1.0.0

10 months ago