Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3a2f13d
port to protozero from @joto - refs #143
Aug 21, 2019
06d0cb4
try to work around travis node_modules caching
Aug 24, 2019
209129c
implement glyph compositing (port from https://github.com/mapbox/glyp…
Aug 26, 2019
12ddc76
Merge branch 'master' of github.com:mapbox/node-fontnik into port-to-…
Aug 26, 2019
f2c5462
make format
Aug 26, 2019
46a7202
Merge branch 'port-to-protozero' of github.com:mapbox/node-fontnik in…
Aug 26, 2019
ade6735
make format
Aug 26, 2019
37ff268
port over tests from https://github.com/mapbox/glyph-pbf-composite/tr…
Aug 26, 2019
a0c2072
attempt to defeat the node_modules cache again, to get new dep on travis
Aug 26, 2019
d6bf0ac
Revert "attempt to defeat the node_modules cache again, to get new de…
Aug 26, 2019
702a470
port to node v12
Nov 28, 2019
e83e79f
drop node v4/6, add v12
Nov 28, 2019
ab2eb76
make format
Nov 28, 2019
5507815
upgrade boost to fix compilation error: unable to find numeric litera…
Nov 28, 2019
d291b85
workaround gcc bug
Nov 28, 2019
133c49a
async resource
Nov 28, 2019
8bb5316
suppress spurious leak inside node
Nov 28, 2019
c7c4112
alternative approach to fix gcc compile
Nov 28, 2019
366e12f
Merge pull request #165 from mapbox/node-v12
springmeyer May 22, 2020
0ca92d2
fix addition of width, height, and left properties
May 22, 2020
38636aa
ugprade deps
May 22, 2020
d333911
no need for prepublish check
May 22, 2020
a46d749
add node v14 support
May 22, 2020
8515f08
use latest clang++
May 22, 2020
0816bf7
bump to v0.6.0
May 22, 2020
e8c48d2
make format fixes
May 22, 2020
d87eb16
avoid header guard check
May 22, 2020
ab24bd8
bump to 0.6.0-dev.1, update readme [publish binary]
May 22, 2020
f80b4cc
clang tidy fixes
May 23, 2020
1c14486
fewer clang-tidy checks
May 23, 2020
bc0db8c
more clang tidy fixes
May 23, 2020
7736228
disable clang-tidy for the moment
May 23, 2020
30cde66
Merge branch 'master' of github.com:mapbox/node-fontnik into glyph-co…
May 23, 2020
81d07d8
add to npm ignore
May 23, 2020
30d2200
fix merge problem
May 26, 2020
5bc8dfe
make format
May 26, 2020
1d0c895
bump to v0.6.0 [publish binary]
May 26, 2020
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
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '*'
Checks: '*,-llvm-header-guard,-fuchsia*,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers'
WarningsAsErrors: '*'
HeaderFilterRegex: '\/src\/'
AnalyzeTemporaryDtors: false
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.mason
.toolchain
bench
glyphs
build
fonts
lib
Expand Down
92 changes: 47 additions & 45 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,62 +39,62 @@ script:
# run your tests and build binaries
matrix:
include:
# linux publishable node v4/release
# linux publishable node v8
- os: linux
env: BUILDTYPE=release
node_js: 4
# linux publishable node v4/debug
node_js: 8
# linux publishable node v8/debug
- os: linux
env: BUILDTYPE=debug
node_js: 4
# linux publishable node v6
node_js: 8
# linux publishable node v10
- os: linux
env: BUILDTYPE=release
node_js: 6
# linux publishable node v6/debug
node_js: 10
# linux publishable node v10/debug
- os: linux
env: BUILDTYPE=debug
node_js: 6
# linux publishable node v8
node_js: 10
# linux publishable node v12
- os: linux
env: BUILDTYPE=release
node_js: 8
# linux publishable node v8/debug
node_js: 12
# linux publishable node v10/debug
- os: linux
env: BUILDTYPE=debug
node_js: 8
# linux publishable node v8
node_js: 14
# linux publishable node v14
- os: linux
env: BUILDTYPE=release
node_js: 10
# linux publishable node v8/debug
node_js: 14
# linux publishable node v10/debug
- os: linux
env: BUILDTYPE=debug
node_js: 10
# osx publishable node v4
node_js: 12
# osx publishable node v8
- os: osx
osx_image: xcode8.2
osx_image: xcode11
env: BUILDTYPE=release
node_js: 4
# osx publishable node v6
node_js: 8
# osx publishable node v10
- os: osx
osx_image: xcode8.2
osx_image: xcode11
env: BUILDTYPE=release
node_js: 6
# osx publishable node v6
node_js: 10
# osx publishable node v12
- os: osx
osx_image: xcode8.2
osx_image: xcode11
env: BUILDTYPE=release
node_js: 8
# osx publishable node v6
node_js: 12
# osx publishable node v12
- os: osx
osx_image: xcode8.2
osx_image: xcode11
env: BUILDTYPE=release
node_js: 10
# Sanitizer build node v4/Debug
node_js: 14
# Sanitizer build node v10/Debug
- os: linux
env: BUILDTYPE=debug TOOLSET=asan
node_js: 4
node_js: 10
sudo: required
# Overrides `install` to set up custom asan flags
install:
Expand All @@ -118,8 +118,10 @@ matrix:
- true
# g++ build (default builds all use clang++)
- os: linux
env: BUILDTYPE=debug CXX="g++-6" CC="gcc-6"
node_js: 4
# Note: -fext-numeric-literals is needed to workaround gcc bug:
# boost/math/constants/constants.hpp:269:3: error: unable to find numeric literal operator 'operatorQ'
env: BUILDTYPE=debug CXX="g++-6" CC="gcc-6" CXXFLAGS="-fext-numeric-literals"
node_js: 10
addons:
apt:
sources:
Expand All @@ -136,7 +138,7 @@ matrix:
# Coverage build
- os: linux
env: BUILDTYPE=debug CXXFLAGS="--coverage" LDFLAGS="--coverage"
node_js: 4
node_js: 10
# Overrides `script` to publish coverage data to codecov
before_script:
- npm test
Expand All @@ -162,15 +164,15 @@ matrix:
# Overrides `script`, no need to run tests
before_script:
# Clang tidy build
- os: linux
env: CLANG_TIDY
node_js: 4
# Overrides `install` to avoid initializing clang toolchain
install:
# First run the clang-tidy target
# Any code formatting fixes automatically applied by clang-tidy
# will trigger the build to fail (idea here is to get us to pay attention
# and get in the habit of running these locally before committing)
- make tidy
# Overrides `script`, no need to run tests
before_script:
# - os: linux
# env: CLANG_TIDY
# node_js: 10
# # Overrides `install` to avoid initializing clang toolchain
# install:
# # First run the clang-tidy target
# # Any code formatting fixes automatically applied by clang-tidy
# # will trigger the build to fail (idea here is to get us to pay attention
# # and get in the habit of running these locally before committing)
# - make tidy
# # Overrides `script`, no need to run tests
# before_script:
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 0.6.0

- Adds node v12 and v14 support
- Dropped node v4 and v6 support
- Adds `fontnik.composite`
- Drops `libprotobuf` dependency, uses `protozero` instead
- Requires c++14 compatible compiler
- Binaries are published using clang++ 10.0.0

# 0.5.2

- Adds .npmignore to keep downstream node_modules small.
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
[![Build Status](https://travis-ci.org/mapbox/node-fontnik.svg?branch=master)](https://travis-ci.org/mapbox/node-fontnik)
[![codecov](https://codecov.io/gh/mapbox/node-fontnik/branch/master/graph/badge.svg)](https://codecov.io/gh/mapbox/node-fontnik)

A library that delivers a range of glyphs rendered as SDFs (signed distance fields) in a protocol buffer. We use these encoded glyphs as the basic blocks of font rendering in [Mapbox GL](https://github.com/mapbox/mapbox-gl-js). SDF encoding is superior to traditional fonts for our usecase terms of scaling, rotation, and quickly deriving halos - WebGL doesn't have built-in font rendering, so the decision is between vectorization, which tends to be slow, and SDF generation.
A library that delivers a range of glyphs rendered as SDFs (signed distance fields) in a protocol buffer. We use these encoded glyphs as the basic blocks of font rendering in [Mapbox GL](https://github.com/mapbox/mapbox-gl-js). SDF encoding is superior to traditional fonts for our usecase in terms of scaling, rotation, and quickly deriving halos - WebGL doesn't have built-in font rendering, so the decision is between vectorization, which tends to be slow, and SDF generation.

The approach this library takes is to parse and rasterize the font with Freetype (hence the C++ requirement), and then generate a distance field from that rasterized image.

See also [TinySDF](https://github.com/mapbox/tiny-sdf), which is a faster but less precise approach to generating SDFs for fonts.

## [API](API.md)

## Installing

By default, installs binaries. On these platforms no external dependencies are needed.

- 64 bit OS X or 64 bit Linux
- Node.js v0.10.x, v0.12.x, v4.x or v6.x
- Node.js v8-v14

Just run:

Expand All @@ -30,7 +32,7 @@ However, other platforms will fall back to a source compile: see [building from
```
npm install --build-from-source
```
Building from source should automatically install `boost`, `freetype` and `protobuf` locally using [mason](https://github.com/mapbox/mason). These dependencies can be installed manually by running `./scripts/install_deps.sh`.
Building from source should automatically install `boost`, `freetype` and `protozero` locally using [mason](https://github.com/mapbox/mason). These dependencies can be installed manually by running `./scripts/install_deps.sh`.

## Local testing

Expand Down
36 changes: 7 additions & 29 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
'system_includes': [
"-isystem <(module_root_dir)/<!(node -e \"require('nan')\")",
"-isystem <(module_root_dir)/mason_packages/.link/include/",
"-isystem <(module_root_dir)/mason_packages/.link/include/freetype2",
'-isystem <(SHARED_INTERMEDIATE_DIR)'
"-isystem <(module_root_dir)/mason_packages/.link/include/freetype2"
],
# Flags we pass to the compiler to ensure the compiler
# warns us about potentially buggy or dangerous code
Expand All @@ -26,7 +25,8 @@
'-Wuninitialized',
'-Wunreachable-code',
'-Wold-style-cast',
'-Wno-error=unused-variable'
'-Wno-error=unused-variable',
'-Wno-deprecated-declarations'
]
},
# `targets` is a list of targets for gyp to run.
Expand All @@ -53,46 +53,24 @@
}
]
},
{
'target_name': 'action_before_build2',
'type': 'none',
'dependencies': [
'action_before_build'
],
'hard_dependency': 1,
'actions': [
{
'action_name': 'run_protoc_glyphs',
'inputs': [
'./proto/glyphs.proto'
],
'outputs': [
"<(SHARED_INTERMEDIATE_DIR)/glyphs.pb.cc"
],
'action': ['./mason_packages/.link/bin/protoc','-Iproto/','--cpp_out=<(SHARED_INTERMEDIATE_DIR)/','./proto/glyphs.proto']
}
]
},
{
# module_name and module_path are both variables passed by node-pre-gyp from package.json
'target_name': '<(module_name)', # sets the name of the binary file
'product_dir': '<(module_path)', # controls where the node binary file gets copied to (./lib/binding/module.node)
'type': 'loadable_module',
'dependencies': [ 'action_before_build2' ],
'dependencies': [ 'action_before_build' ],
# "make" only watches files specified here, and will sometimes cache these files after the first compile.
# This cache can sometimes cause confusing errors when removing/renaming/adding new files.
# Running "make clean" helps to prevent this "mysterious error by cache" scenario
# This also is where the benefits of using a "glob" come into play...
# See: https://github.com/mapbox/node-cpp-skel/pull/44#discussion_r122050205
'sources': [
'src/node_fontnik.cpp',
'src/glyphs.cpp',
'<(SHARED_INTERMEDIATE_DIR)/glyphs.pb.cc'
'src/glyphs.cpp'
],
"link_settings": {
"libraries": [
"-lfreetype",
"-lprotobuf-lite"
"-lfreetype"
],
"library_dirs": [
"<(module_root_dir)/mason_packages/.link/lib"
Expand Down Expand Up @@ -128,7 +106,7 @@
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET':'10.8',
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++11',
'CLANG_CXX_LANGUAGE_STANDARD':'c++14',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
}
}
Expand Down
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'target_defaults': {
'default_configuration': 'Release',
'cflags_cc' : [
'-std=c++11',
'-std=c++14',
# The assumption is that projects based on node-cpp-skel will also
# depend on mason packages. Currently (this will change in future mason versions)
# mason packages default to being built/linked with the CXX11_ABI=0.
Expand Down
Loading