GithubHelp home page GithubHelp logo

heremaps / harp-fontcatalog-generator Goto Github PK

View Code? Open in Web Editor NEW
6.0 10.0 3.0 730 KB

Generator to create fontcatalogs to be used by harp.gl

Home Page: https://heremaps.github.io/harp.gl/

License: Apache License 2.0

TypeScript 2.58% Shell 0.83% JavaScript 96.58%
harpgl typescript

harp-fontcatalog-generator's Introduction

@here/harp-fontcatalog-generator Build Status

This module contains the necessary scripts and resources to generate a font catalog to be used with the harp.gl renderer. It includes the NotoSans-Regular font as part of the package because the script uses a glyph from that font as a fallback, in case some glyph from the font that it processes is missing.

For information about coding style or contributing, please refer to the information main project harp.gl.

Development

Prerequisites

  • Node.js - Please see nodejs.org for installation instructions
  • Yarn - Please see yarnpkg.com for installation instructions.

Download dependencies

Run:

yarn install

to download and install all required packages and set up the yarn workspace.

Installation

You can install it with yarn or with npm:

yarn add @here/harp-fontcatalog-generator

or

npm install @here/harp-fontcatalog-generator

Run unit tests in Node.js environment

Run:

yarn test

FontCatalog Description

To generate your own FontCatalog assets to use with harp.gl, you need to supply a JSON file containing your FontCatalog description. This file is composed of the following paremeters:

  • name: FontCatalog's name (Default: Default).
  • size: FontCatalog's glyph pixel size (Default: 32).
  • distance: FontCatalog's glyph pixel distance (Default: 8).
  • type: FontCatalog's glyph type, which could be regular SDF or MSDF (Default: SDF).
  • fontsDir: Relative path to the directory where all the .ttf font files for this FontCatalog are stored.
  • fonts: Array containing all the fonts to be included in this FontCatalog. Every font entry is composed of:
    • name: Font's name.
    • bold: Font's bold variant (Optional).
    • italic: Font's italic variant (Optional).
    • boldItalic: Font's boldItalic variant (Optional).
    • blocks: Array containing the specific Unicode Blocks of this font for which we want to generate glyphs (Optional).

The size, distance and type parameters influence how SDF glyphs are rasterize, and thus, can affect the quality of the output FontCatalog. To learn more about Font SDF Rasterization, visit the msdfgen repository.

FontCatalog Generation

After installing the package, just run:

harp-fontcatalog-generator -- -i <PATH_TO_DESCRIPTION> -o <OUTPUT_PATH>

Which will output assets in the following directory structure:

├── <NAME>_Assets
│   ├── Extra
│   │   ├── Specials.json
│   │   └── Specials.png
│   ├── FontA
│   │   ├── Basic_Latin.json
│   │   ├── Basic_Latin.png
│   │   └── ...
│   ├── FontB
│   │   ├── Basic_Latin.json
│   │   ├── Basic_Latin.png
│   │   └── ...
│   └── ...
├── <NAME>_BoldAssets (if any)
│   └── ...
├── <NAME>_ItalicAssets (if any)
│   └── ...
├── <NAME>_BoldItalicAssets (if any)
│   └── ...
└── <NAME>_FontCatalog.json

To use these assets with your harp.gl theme files, copy all of them to your resources folder and reference them from the theme with a relative path:

"fontCatalogs": [
    {
        "name": "<NAME>",
        "url": "./<NAME>_FontCatalog.json"
    }
]

License

Copyright (C) 2018-2019 HERE Europe B.V.

Unless otherwise noted in a LICENSE file for specific files or directories, the code in this repository is licensed under Apache 2.0 license.

See the LICENSE file in the root of this project for license details.

harp-fontcatalog-generator's People

Contributors

dependabot[bot] avatar musculman avatar ninok avatar tsteenbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

qqliyan lume xyzmaps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.