Package Exports
- bsc-plugin-auto-google-fonts
- bsc-plugin-auto-google-fonts/dist/google-fonts-plugin.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bsc-plugin-auto-google-fonts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Auto Google Fonts
A BrighterScript plugin that makes it easy to use Google Fonts in your Roku SceneGraph applications. Simply reference any Google Font by name, and the plugin automatically downloads and bundles it with your app.
Features
- Simple Syntax: Use
googleFont:FontNameto reference any Google Font - Automatic Downloads: Fonts are automatically downloaded from Google Fonts GitHub repository
- Smart Selection: Automatically chooses the best font variant (prioritizes variable fonts, then regular weights)
- Build-Time Processing: Fonts are downloaded and bundled during the build process
- XML & BrightScript Support: Works in both SceneGraph XML components and BrightScript code
- Caching: Downloaded fonts are cached to speed up subsequent builds
Installation
npm install bsc-plugin-auto-google-fontsUsage
1. Configure BrighterScript
Add the plugin to your bsconfig.json:
{
"plugins": [
"google-fonts-roku"
]
}2. Use Google Fonts in Your App
In XML Components
<Label
text="Hello, World!"
font="googleFont:Roboto"
fontSize="48"
/>In BrightScript Code
sub init()
label = CreateObject("roSGNode", "Label")
label.text = "Hello, World!"
label.font = "googleFont:Roboto"
label.fontSize = 48
m.top.appendChild(label)
end sub3. Build Your Project
When you build your project with BrighterScript, the plugin will:
- Scan your code for
googleFont:references - Download the specified fonts from the Google Fonts repository
- Replace
googleFont:FontNamewithpkg:/fonts/FontName.ttf - Copy the fonts to your staging directory
Supported Font Names
You can use any font from Google Fonts. Use the exact font family name as shown on the Google Fonts website.
Examples:
googleFont:RobotogoogleFont:Open SansgoogleFont:LatogoogleFont:MontserratgoogleFont:Playfair Display
How It Works
The plugin operates during the BrighterScript build process:
- Scanning Phase (
beforePrepublish): Scans all.brsand.xmlfiles forgoogleFont:references - Download Phase: Downloads fonts from the Google Fonts GitHub repository to your project's
fonts/directory - Transform Phase (
beforeFileTranspile/afterFileTranspile): ReplacesgoogleFont:FontNamewithpkg:/fonts/FontName.ttfin your code - Copy Phase (
afterPrepublish): Copies all downloaded fonts to the staging directory
Font Selection Logic
When multiple font files are available for a font family, the plugin automatically selects the best one using this priority:
- Variable fonts with
[wght]axis (most flexible) - Other variable fonts
- Regular static fonts
- Any available font file
Requirements
- BrighterScript ^0.69.4
- Node.js (with
curlavailable in PATH)
Project Structure
your-roku-project/
├── bsconfig.json # BrighterScript configuration
├── source/ # Your BrightScript source files
├── components/ # Your SceneGraph XML components
├── fonts/ # Downloaded fonts (auto-generated)
└── out/
└── staging/
└── fonts/ # Fonts copied to staging (auto-generated)Demo
A working demo is included in the demo/ directory. To run it:
npm run build
# Deploy the demo/ directory to your Roku deviceThe demo shows how to use both system fonts and Google Fonts side by side.
Configuration
The plugin uses these directories (relative to your rootDir in bsconfig.json):
- Fonts Directory:
fonts/- where downloaded fonts are stored - Staging Directory: Specified by
stagingDirin your BrighterScript config
Troubleshooting
Font Not Found
If a font fails to download, check:
- The font name matches exactly with Google Fonts
- The font is in the
ofl/,apache/, orufl/directories of the Google Fonts repository - Your internet connection is working
curlis installed and available
Font Not Loading on Roku
Ensure:
- The font file was copied to
pkg:/fonts/in your deployed app - The font format is
.ttf(Roku supports TrueType fonts) - The font file isn't corrupted (check file size)
Development
To work on this plugin:
# Install dependencies
npm install
# Build the plugin
npm run build
# Watch for changes
npm run watchCredits
This plugin downloads fonts from the Google Fonts GitHub repository, which contains fonts licensed under open source licenses (OFL, Apache, UFL).