Skip to content

Instantly share code, notes, and snippets.

@hlotvonen
hlotvonen / gist:310ab9cd41ba99bf9bb23abd2a04c033
Last active September 12, 2024 12:04
Ways to substitute specific words with OpenType
# Goal: substitute each letter in the word "while" with the corresponding alternate.
# Option 0 — does not work, error "many-to-many substitution not available"
lookup whileAttrCalt-0 useExtension {
ignore sub @AllLetters w' h i l e;
ignore sub w' h i l e @AllLetters;
sub w' h' i' l' e' by w.alt2 h.alt2 i.alt2 l.alt2 e.alt2;
} whileAttrCalt-0;
@jjgrainger
jjgrainger / Vector.js
Last active July 29, 2024 11:18
A simple Vector class in javascript
var Vector = function(x, y) {
this.x = x || 0;
this.y = y || 0;
};
// return the angle of the vector in radians
Vector.prototype.getDirection = function() {
return Math.atan2(this.y, this.x);
};