-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 65da030
Showing
26 changed files
with
11,865 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules/ | ||
.nyc_output/ | ||
coverage/ | ||
|
||
dist/ | ||
|
||
*.tgz | ||
npm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node_modules/ | ||
.nyc_output/ | ||
.vscode/ | ||
coverage/ | ||
|
||
src/ | ||
dist/**/*.spec.* | ||
fonts/ | ||
|
||
*.tgz | ||
npm-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
language: node_js | ||
cache: | ||
directories: | ||
# https://twitter.com/maybekatz/status/905213355748720640 | ||
- ~/.npm | ||
node_js: | ||
- '8' | ||
- '9' | ||
- '10' | ||
|
||
# Trigger a push build on master and greenkeeper branches + PRs build on every | ||
# branch. Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147) | ||
branches: | ||
only: | ||
- master | ||
- /^greenkeeper.*$/ | ||
|
||
stages: | ||
- commitlint | ||
- test | ||
- name: release | ||
if: branch = master AND type IN (push) | ||
|
||
jobs: | ||
include: | ||
- stage: commitlint | ||
node_js: '8' | ||
script: commitlint-travis | ||
- stage: test | ||
script: npm test | ||
after_success: npm run coverage | ||
- stage: release | ||
node_js: '8' | ||
script: npm run release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch", | ||
"program": "${workspaceFolder}/dist/index.js", | ||
"preLaunchTask": "tsc: build - tsconfig.json", | ||
"outFiles": [ | ||
"${workspaceFolder}/dist/**/*.js" | ||
] | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug Tests", | ||
"program": "${workspaceFolder}/node_modules/ava/profile.js", | ||
"args": [ | ||
"--serial", | ||
"dist/index.spec.js" | ||
], | ||
"skipFiles": [ | ||
"<node_internals>/**/*.js" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Contribution Guide | ||
|
||
## Issues | ||
|
||
If you have a bug to report or a feature that you'd like to see, head over to | ||
the [issues][] section of the repository to open an issue. Some guidelines: | ||
|
||
* Do a check of the existing issues (both open and closed) to see if anyone had | ||
the same issue/request. If you find something, feel free to add your voice to | ||
the conversation if there's something new to add or or [give the issue a | ||
thumbs up][github reactions] to show you have the same issue/request. | ||
|
||
* Please include the version of both Node.js (`node -v`) and font-ligatures | ||
(`npm ls font-ligatures`) that you are using. If you're not on the latest | ||
version, try using that first and see if it fixes your issue. | ||
|
||
* Include specific details about what you were doing and what went wrong and | ||
how to reproduce the issue. Some sample code or a sample gist/repository go a | ||
long way to helping with debugging and finding a fix. | ||
|
||
* Be respectful of others in the conversation. Issues should be a place where | ||
people can discuss what they're seeing, learn and work toward a solution | ||
without worrying about being judged or lambasted. | ||
|
||
* If you have a question rather than an issue or feature request, don't be | ||
afraid to post it in the issues, but please be patient if it takes longer to | ||
get a response. All are encouraged to help answer questions. | ||
|
||
## Pull Requests | ||
|
||
Do you have a bugfix for an issue, a new feature, or even a fix for a typo in | ||
the documentation? You should open a Pull Request! Some steps to follow: | ||
|
||
1. If your change is a substantial addition or it will result in a breaking | ||
change to the library, consider first [opening an issue](#issues) to dicuss | ||
the problem and the proposed solution. | ||
|
||
2. [Fork the repository][github fork] if you haven't before | ||
|
||
3. [Set up your development environment](#developer-setup) and make your | ||
changes. Also be sure to add tests for your change. | ||
|
||
4. When you're ready to push your changes, run `npm t` to lint, build and test | ||
your code. Any failures here will cause your pull request's continuous | ||
integration to fail, so it's best to catch it early. | ||
|
||
5. Once you've pushed your code into your fork, [open a pull request][new pull | ||
request] and follow the template to fill in the pull request information. | ||
|
||
## Developer Setup | ||
|
||
### Prerequisites | ||
|
||
* [Node.js][] 6.x or later | ||
|
||
### Setting Up | ||
|
||
This package is written in [Typescript][]. You can get things installed and | ||
built using the following: | ||
|
||
``` | ||
npm i | ||
npm run build | ||
``` | ||
|
||
### Testing | ||
|
||
Once you have made a change, you'll want to make sure that all of the tests are | ||
passing. You can do so by running: | ||
|
||
``` | ||
npm t | ||
``` | ||
|
||
This will run tests and compute code coverage on the source code. You can view a | ||
detailed html coverage report by running: | ||
|
||
``` | ||
npm run show-coverage | ||
``` | ||
|
||
### Committing | ||
|
||
This project uses the [Angular commit style][angular commit style] for | ||
generating changelogs and determining release versions. Any pull request with | ||
commits that don't follow this style will fail continuous integration. If you're | ||
not familiar with the style, you can run the following instead of the standard | ||
`git commit` to get a guided walkthrough to generating your commit message: | ||
|
||
``` | ||
npm run commit | ||
``` | ||
|
||
[issues]: https://github.com/princjef/font-ligatures/issues | ||
[new pull request]: https://github.com/princjef/font-ligatures/compare | ||
[angular commit style]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines | ||
[github reactions]: https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/ | ||
[github fork]: https://help.github.com/articles/fork-a-repo | ||
[Node.js]: https://nodejs.org | ||
[Typescript]: https://www.typescriptlang.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Jeffrey Principe | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# font-ligatures | ||
|
||
[![Travis CI build status](https://travis-ci.org/princjef/font-ligatures.svg?branch=master)](https://travis-ci.org/princjef/font-ligatures) | ||
[![codecov](https://codecov.io/gh/princjef/font-ligatures/branch/master/graph/badge.svg)](https://codecov.io/gh/princjef/font-ligatures) | ||
[![npm version](https://img.shields.io/npm/v/font-ligatures.svg)](https://npmjs.org/package/font-ligatures) | ||
|
||
Find ligature replacements for any system font. Useful for determining glyph | ||
substitutions and ranges where ligatures exist within a string of input text. | ||
|
||
``` | ||
npm install font-ligatures | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
const fontLigatures = require('font-ligatures'); | ||
|
||
(async () => { | ||
const font = await fontLigatures.load('Iosevka'); | ||
console.log(font.findLigatures('in --> out')); | ||
// { | ||
// inputGlyphs: [ 76, 81, 3, 16, 16, 33, 3, 82, 88, 87 ], | ||
// outputGlyphs: [ 76, 81, 3, 3140, 3128, 33, 3, 82, 88, 87 ], | ||
// contextRanges: [ [ 3, 6 ] ] | ||
// } | ||
})(); | ||
``` | ||
|
||
## API | ||
|
||
### `load(name)` | ||
|
||
Loads the font with the given name, returning a Promise with a font that can be | ||
used to find ligature information. | ||
|
||
**Params** | ||
|
||
* `name` [*string*] - The font family of the font to load | ||
|
||
### Font | ||
|
||
Object returned by `load()`. Includes the following methods: | ||
|
||
#### `findLigatures(text)` | ||
|
||
Scans the provided text for font ligatures, returning an object with the | ||
following keys: | ||
|
||
* `inputGlyphs` [*number[]*] - The list of font glyphs in the input text. | ||
* `outputGlyphs` [*number[]*] - The list of font glyphs after performing | ||
replacements for font ligatures. | ||
* `contextRanges` [*[number, number]\[\]*] - Sorted array of ranges that must | ||
be rendered together to produce the ligatures in the output sequence. The | ||
ranges are inclusive on the left and exclusive on the right | ||
|
||
**Params** | ||
|
||
* `text` [*string*] - text to search for ligatures | ||
|
||
## Font Support | ||
|
||
This library is designed to support fonts that make use of programming | ||
ligatures. As a result, it is tested against all of the ligatures produced by | ||
the following fonts: | ||
|
||
* [Fira Code][] | ||
* [Iosevka][] | ||
* [Monoid][] | ||
|
||
If there is another font that you use which doesn't seem to be working, please | ||
open an issue with the font information and where to get it. The most likely | ||
cause is that the font uses a type of substitution which is not yet supported. | ||
|
||
## Contributing | ||
|
||
Want to contribute to the project? Go check out the [Contribution | ||
Guide](CONTRIBUTING.md) for instructions to set up your development | ||
environment, open an issue and create a pull request. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.