| 1 | # gftools packager |
| 2 | |
| 3 | |
| 4 | Push upstream font families to the `google/fonts` [repository](https://github.com/google/fonts). |
| 5 | |
| 6 | ``` |
| 7 | usage: gftools [-h] [-p] [-br BASE_REPO] [-hr HEAD_REPO] [-l {ofl,apache,ufl}] [--latest-release] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] |
| 8 | [--skip-tags] |
| 9 | family_name repo_path |
| 10 | |
| 11 | positional arguments: |
| 12 | family_name Name of font family or path to a METADATA.pb file |
| 13 | repo_path Path to the google/fonts repository |
| 14 | |
| 15 | options: |
| 16 | -h, --help show this help message and exit |
| 17 | -p, --pr Open a pull request on google/fonts or a forked repo |
| 18 | -br BASE_REPO, --base-repo BASE_REPO |
| 19 | Repo owner to send pull request. Default is 'google' |
| 20 | -hr HEAD_REPO, --head-repo HEAD_REPO |
| 21 | Repo owner to push branch. Default is 'google' |
| 22 | -l {ofl,apache,ufl}, --license {ofl,apache,ufl} |
| 23 | licence type for new family |
| 24 | --latest-release Get assets from latest upstream release |
| 25 | --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL} |
| 26 | --skip-tags |
| 27 | |
| 28 | ``` |
| 29 | |
| 30 | ## Setup |
| 31 | |
| 32 | The packages needs a GitHub Personal Access Token. Please add one to your account, https://github.com/settings/tokens and enable the following scopes: |
| 33 | |
| 34 |  |
| 35 | |
| 36 | Finally, Add the key to a new environment variable on your computer called `GH_TOKEN`. On Mac edit the file `~/.bash_profile` and add the following lines: |
| 37 | |
| 38 | ``` |
| 39 | export GH_TOKEN="your-access-token" |
| 40 | export GH_USERNAME="your-github-username" |
| 41 | ``` |
| 42 | |
| 43 | ## Pushing a new family |
| 44 | |
| 45 | Let's push [Maven Pro](https://github.com/googlefonts/mavenproFont). |
| 46 | |
| 47 | |
| 48 | 1. In the terminal, navigate to your local `google/fonts` repo: |
| 49 | |
| 50 | `cd path/to/your/google/fonts` |
| 51 | |
| 52 | 2. run gftools packager with the following command: |
| 53 | |
| 54 | `gftools packager "Maven Pro" . -p` |
| 55 | |
| 56 | Here's a breakdown of the arguments: |
| 57 | |
| 58 | - `Maven Pro` is the family name. We can also provide a path to a family's metadata file instead e.g `path/to/google/fonts/ofl/mavenpro/METADATA.pb`. |
| 59 | - `.` is the directory to our local `google/fonts` repo. We can actually run the tool from any directory. |
| 60 | - `-p` Opens a pull request in `google/fonts`. This argument is optional. |
| 61 | |
| 62 | Once you've run the tool, you'll get the following message: |
| 63 | |
| 64 |  |
| 65 | |
| 66 | 3. Open the newly generated METADATA.pb file in your favorite text editor and populate the newly added `source` fields. |
| 67 | |
| 68 |  |
| 69 | |
| 70 | 4. Rerun the last command in your terminal and you should now have the following message: |
| 71 | |
| 72 |  |
| 73 | |
| 74 | |
| 75 | 5. Please inspect the newly created PR and complete the items on the checklist. If you need to make any modifications to description files or METADATA.pb files, `git checkout` the branch and do them by hand. If you rerun the packager it will overwrite any hand edited files that are listed in the METADATA.pb file. |
| 76 | |
| 77 | |
| 78 | ## Pushing an updated family |
| 79 | |
| 80 | Use the same commands in the previous quick start. Since the `METADATA.pb` file has source fields, you won't need to run the tool twice. |
| 81 | |
| 82 | ## Tips |
| 83 | |
| 84 | - Set your favorite editor to open `METADATA.pb` by default. On Mac, this allows you to open them up from your terminal `open path/to/METADATA.pb` |
| 85 | - On Mac, you can command+click on urls in the terminal and it will open them in your web browser ;-) |