{"id":22994590,"url":"https://github.com/mrmaxie/get-google-fonts","last_synced_at":"2025-05-07T07:21:40.735Z","repository":{"id":37602103,"uuid":"117337188","full_name":"MrMaxie/get-google-fonts","owner":"MrMaxie","description":"Downloads and adapts Google fonts to working offline","archived":false,"fork":false,"pushed_at":"2024-01-04T15:32:36.000Z","size":66,"stargazers_count":61,"open_issues_count":8,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-04T21:59:10.420Z","etag":null,"topics":["download","fonts","google","javascript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrMaxie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-13T11:12:26.000Z","updated_at":"2024-12-13T06:00:00.000Z","dependencies_parsed_at":"2024-06-18T15:23:41.067Z","dependency_job_id":"f21dba90-35b7-465e-ac56-0370d70781cd","html_url":"https://github.com/MrMaxie/get-google-fonts","commit_stats":{"total_commits":38,"total_committers":11,"mean_commits":"3.4545454545454546","dds":0.5,"last_synced_commit":"2f8b15f6d7072533ca2ad5e0b74ccf28a313e8c8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMaxie%2Fget-google-fonts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMaxie%2Fget-google-fonts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMaxie%2Fget-google-fonts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMaxie%2Fget-google-fonts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrMaxie","download_url":"https://codeload.github.com/MrMaxie/get-google-fonts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831462,"owners_count":21810808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["download","fonts","google","javascript"],"created_at":"2024-12-15T05:19:27.723Z","updated_at":"2025-05-07T07:21:40.716Z","avatar_url":"https://github.com/MrMaxie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get Google Fonts\n\nScript downloading CSS file with fonts and adapt it to working in closed environment/offline. Useful for example when project must to be ran in network without connection with internet or when you make application based on projects like [Electron](https://electron.atom.io/).\n\n## Getting Started\n\nScript can be \"installed\" manually by cloning `./main.js` file or with NPM:\n```\nnpm install get-google-fonts\n```\n\n## Example Result\n\nFor example CSS with fonts used like this:\n```html\n\u003clink href='https://fonts.googleapis.com/css?family=Roboto:400,700\u0026amp;subset=cyrillic' rel='stylesheet'\u003e\n```\n\nCan be replaced with:\n```html\n\u003clink href='fonts/fonts.css' rel='stylesheet'\u003e\n```\n\n## Using in command line\n\nUsing in command line it's possible when script is installed as `global` or you know full path to `cli.js` file. By default NPM will prefer to install script as global and after that scripts will share file in bin directory named `get-google-fonts`. Then you can just to use that command anywhere.\n\n```\nUsage:\n  get-google-fonts [OPTIONS] [ARGS]\n\nOptions:\n  -i, --input URL         Input URL of CSS with fonts\n  -o, --output [STRING]   Output directory (Default is ./fonts)\n  -p, --path [STRING]     Path placed before every source of font in CSS  (Default is ./)\n  -c, --css [STRING]      Name of CSS file (Default is fonts.css)\n  -t, --template [STRING] Template of font filename (Default is {_family}-{weight}-{comment}{i}.{ext})\n  -u, --useragent STRING  User-agent used at every connection\n  -q, --quiet             Don't displays a lot of useful information\n  -b, --base64            Save fonts inside CSS file as base64 URIs\n\t  --non-strict-ssl    Force to accepts only valid SSL certificates; in some\n\t\t\t\t\t\t  cases,such proxy or self-signed certificates\n\t\t\t\t\t\t  should be turned off\n  -w, --overwriting       Allows overwrite existing files\n\t  --print-options     Shows result options object without performing any\n\t\t\t\t\t\t  action\n  -s, --simulate          Simulation; No file will be saved\n  -h, --help              Display help and usage details\n```\n\nTo get a result like in [Example](#Example-Result), just enter the command in the folder with the HTML file:\n\n```\nget-google-fonts -i \"https://fonts.googleapis.com/css?family=Roboto:400,700\u0026subset=cyrillic\"\n```\n\n## Using in code\n\nGet-google-fonts can be required as module.\n\n```javascript\nconst GetGoogleFonts = require('get-google-fonts');\n```\n\nTo get result like in [Example](#Example-Result), just create object and run `download` method.\n```javascript\nnew GetGoogleFonts().download('https://fonts.googleapis.com/css?family=Roboto:400,700\u0026subset=cyrillic')\n// =\u003e Promise\n```\n\nThere are three useful methods in all module.\n\n### Constructor\n\nParameters:\n\n- `config` Allows you to preconfigure all downloads done by this object. [See more...](#Config-object) **[optional]**\n\nExample:\n\n```javascript\nlet ggf_ttf = new GetGoogleFonts({\n\tuserAgent: 'Wget/1.18'\n})\nlet ggf_defaults = new GetGoogleFonts()\n```\n### download\n\nParameters:\n\n- `url` URL to CSS as fonts object or plain string. Can be an array of arguments witch will be passed through [GetGoogleFonts.constructUrl()](#constructUrl).\n- `config` Allows you to configure this one downloads. [See more...](#Config-object) **[optional]**\n\nExample:\n\n```javascript\nggf.download([\n\t{\n\t\tRoboto: [400, 700]\n\t},\n\t['cyrillic']\n]).then(() =\u003e {\n\tconsole.log('Done!')\n}).catch(() =\u003e {\n\tconsole.log('Whoops!')\n})\n// or\nggf.download('https://fonts.googleapis.com/css?family=Roboto:400,700\u0026subset=cyrillic', {\n\tuserAgent: 'Wget/1.18'\n}).then(() =\u003e {\n\tconsole.log('Done!')\n}).catch(() =\u003e {\n\tconsole.log('Whoops!')\n})\n```\n\n### constructUrl\n\nGenerate URL of Google Fonts using given parameters.\n\nParameters:\n\n- `families` Object of fonts names and weights\n- `subsets` Array of subsets\n\nExample:\n\n```javascript\nGetGoogleFonts.constructUrl(\n\t{\n\t\tRoboto: ['400', 700],\n\t\t'Roboto': [400, '700i'],\n\t\t'Alegreya Sans SC': [300]\n\t},\n\t['cyrillic']\n)\n// =\u003e https://fonts.googleapis.com/css?family=Roboto:400,700,700i|Alegreya+Sans+SC:300\u0026subset=cyrillic\n```\n\n## Config object\n\nObjects will be considered as follows:\nDownload config \u003e GetGoogleFonts object config \u003e Default config\n\n```javascript\n// Default config object\n{\n\t// Output directory when where all files will be saved.\n\t// According to this path, relative paths will be resolved.\n\toutputDir:  './fonts',\n\t// Path placed before every source of font in CSS.\n\t// It's also can be URL of your website.\n\tpath:       './',\n\t// Template of font filename.\n\ttemplate:   '{_family}-{weight}-{comment}{i}.{ext}',\n\t// Name of CSS file. Like other files\n\t// will be placed relative to output directory\n\tcssFile:    'fonts.css',\n\t// User-agent used at every connection. Accordingly, Google Fonts will\n\t// send the appropriate fonts. For example, providing a wget's\n\t// user-agent will end with the download of .ttf fonts.\n\t// Default user-agent downloads .woff2 fonts.\n\tuserAgent:  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' +\n\t\t\t\t'(KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',\n\t// Save fonts inside CSS file as base64 URIs\n\tbase64:      false,\n\t// Force to accepts only valid SSL certificates; in some cases,\n\t// such proxy or self-signed certificates should be turned off\n\tstrictSSL:   true,\n\t// Allows overwrite existing files.\n\toverwriting: false,\n\t// Displays a lot of useful information.\n\tverbose:     false,\n\t// Simulation; No file will be saved.\n\tsimulate:    false\n}\n```\n\n## Template\n\nFollowing variables can be used in the template:\n- `{comment}` Text from comment placed before @font-face. Google place there name of subset e.g. latin\n- `{family}` Font-family e.g. Source Sans Pro\n- `{_family}` Font-family (whitespace will be replaced with underscore) e.g. Source_Sans_Pro\n- `{weight}` Font-weight e.g. 400\n- `{filename}` Name of original file e.g. ODelI1aHBYDBqgeIAH2zlC2Q8seG17bfDXYR_jUsrzg\n- `{ext}` Original extension e.g. woff2\n- `{i}` A number that is incremented one by one each time a font file is added. Useful to preserve the uniqueness of font names in case you are not sure if the previous variables are enough. **It starts from 1.**\n\n## License\n\nThis project is licensed under the Apache-2.0 License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmaxie%2Fget-google-fonts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmaxie%2Fget-google-fonts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmaxie%2Fget-google-fonts/lists"}