Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions landed-rfcs/0001-ns-fonts-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- Start Date: 2020-12-21
- Target Major Version: 8.x
- Reference Issues: N/A
- Implementation PR: https://github.com/NativeScript/nativescript-cli/pull/5452

# Summary

A sore spot for quite a long time is trying to get the font-family combination correct for iOS/Android.
For a custom font such as barlow-bold.ttf the css needs to be:

```
font-family: Barlow, barlow-bold;
```
This feature would list all the available custom fonts with their correct form to use it in css.

# Basic example

Add a convenient cli command which prints out exactly what css is needed for any given font:
```
$ ns fonts

Found Custom Fonts:
-------------------
barlow-bold.ttf -> font-family: Barlow, barlow-bold;
fontawesome.ttf -> font-family: FontAwesome, fontawesome;
```

# Motivation

Getting this correct is sometimes incredibly frustrating for custom fonts.

This feature would save ton of time debugging why custom fonts aren't working.

# Detailed design

Add a new CLI command `ns fonts` that will find a `fonts` folder in all the possible locations (`<projectRoot>/fonts`, `<projectRoot>/<appPath>/fonts` - where `<projectRoot>` is the root of the project, and `<appPath>` is the value for `appPath` in the `nativescript.config.ts` - falling back to the default value of `app` & `src`).

For each font we get the metadata with a package like [font-finder](https://www.npmjs.com/package/font-finder) and then output a css string with the correct values that can be copy-pasted right into any css file from the output of the `ns fonts` command (no manualy modifications required).