npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apl-custom-fonts

v1.0.0

Published

Converts Text to AVG at runtime for easy use with the Alexa Presentation Language

Downloads

37

Readme

APLCustomFonts

NPM version Build Status

This module allows for an easy implementation of custom fonts for the Alexa Presentation Language at runtime. It converts any text into an APL-compatible Alexa Vector Graphic (AVG) that can be easily implemented in any APL document.

Installation

This module requires NodeJS.

$ npm install --save apl-custom-fonts

Constructor

Here is an example of initializing the module, loading a font and converting it into an AVG.

const APLCustomFonts = require('apl-custom-fonts').default;

const customFont = new APLCustomFonts("Hello world!", {
    fill: 'black',
    fontSize: 72
});

customFont.loadFont('./fonts/OpenSans_Medium.ttf');
console.log(customFont.getAVG());

Note: The options parameter accepts more entries. A complete overview of all available options is described below at .updateOptions.

API

.loadFont()

Used to synchronously load a font in memory. The preferred file types are .ttf or .otf.

.updateOptions(options: Options)

Options is an required object containing optional entries:

  • fill define the text color (default is "black")
  • fontSize define the font size (default is 72)
  • stroke define the stroke color (default is "white")
  • strokeWidth define the stroke width (default is 1)
  • letterSpacing define the letter spacing (default is 0)

.getAVG(text?: string)

Convert text to AVG. Optionally uses a text parameter for passing text to convert to AVG.

.getPath(text?: string)

Convert text to raw path data. Optionally uses a text parameter for passing text to convert to path data.

.getSVG(text?: string)

Convert text to SVG. Optionally uses a text parameter for passing text to convert to SVG.

.getDimensions()

Get dimensions of path data.

APL Integration

The generated AVGs can be implemented like any other AVG. It is recommended creating separate objects for each generated AVG-text. AVGs can be easily added to the graphics object in your APL document like so:

{
    "type": "APL",
    "version": "1.6",
	"graphics": {
		"HelloWorldText": {
			"type": "AVG",
			"version": "1.2",
			"width": 743,
			"height": 73,
			"items": {
				"type": "path",
				"description": "Hello World!",
				"fill": "blue",
				"stroke": "red",
				"strokeWidth": 1,
				"pathData": "M19.51 57L15.12 57Q14.33 57 13.68 56.5 13.03 55.99 12.89 55.2L12.89 55.2 2.95 ... 729.94 52.82Z"
			}
		}
	},
}

When added to your APL document, AVGs can be referenced by any VectorGraphic object.

{
	"type": "VectorGraphic",
	"source": "HelloWorldText",
	"scale": "best-fill"
}

License

MIT

Credits

APLCustomFonts depends on the following modules:

A big shoutout goes out to these guys! Thanks for making this module possible.