Move out geometry class

This commit is contained in:
be5invis 2021-02-10 19:52:54 -08:00
parent b7c2b2a3b5
commit 5b1b362cfa
5 changed files with 155 additions and 159 deletions

View file

@ -1,70 +1,52 @@
## Modifications since version 2.x
### 5.0.0-rc.1
* Add Hooky variant for `j` (#864).
* Fix width of flat-hook-serifless `j` (#860).
* Add Circled Zero With Slash (`U+1F10D`, #861).
* Add bar-interrupted variants for Dollar and Cent sign (#863).
* Add bend and curly variants for `7` (#866).
* Add interrupted variants for `B` (#869).
* Add variant selectors for Greek lower Alpha and Iota (#873).
* Add tail to Greek lower Pi and Tau (#875).
* Add compact/descending variants for `J` (#876).
* Add cursive `v` and `w`.
### 5.0.0-beta.3
* **Breaking** Continue organizing and renaming variants.
- Variants of percent (`%`) sign are renamed.
* Fix the incorrect order of `capital-s` (`cv17`) and `capital-t` (`cv18`) variants (#831).
* Fix Misplaced serif in Slab `cyrl/e` (#832).
* Fix variant selector for `cyrl/shcha` (#833).
* Add oval slashed / dotted variants for `0` (#834).
* Add rings-continuous-slash-also-connected variant to `%` (#835).
* Add inward-serifed variants for `C`, `G`, `S`, `c` (#837).
* Add asymmetric variants for `N` (#838).
* Add base-serifed variants for `Y` (#850).
* Add base-serifed variants for `r` (#851).
* Add stylistic set matching PT Mono and Recursive Mono (#855).
* Add character Z NOTATION SCHEMA COMPOSITION (`U+2A1F`) and Z NOTATION RELATION COMPOSITION (`U+2A3E`) (#857).
### 5.0.0-beta.2
* Fix broken curly variants of `x` and `X` (#824).
* Add compact-serifed and compact-top-serifed variants of `r` (#826).
* Allow Zeta to share variants with `Z` (#827).
* Add serifed and top-serifed variants for `S` and `s` (#822).
* Add oblique-upper-left-bar variant for `5` (#820).
* Add oval variant for `0` (#828).
* Add corner and flat-hooked variants for `?` (#829).
### 5.0.0-beta.1
### 5.0.0
* **Breaking** Iosevka Aile and Iosevka Etoile now support `cv##` and `ss##` features.
* **Breaking** Pre-built “SS” families will no longer contain `cv##` and `ss##` features, as their style has already been pre-baked.
* **Breaking** Iosevka Sparkle is removed from prebuilt packages.
* **Breaking** Reorder `cv##` features and variant assignments for better organization.
* **Breaking** Spilt out variant selector for `A`, `V`, `W`, `Z` (#806).
* **Breaking** Certain variants' names are changed:
- Phrase `singlestorey` and `doublestorey` used in `a` and `g` variants are renamed to `single-storey` and `double-storey`.
* Add diagonal-tailed variants for `f`, `i`, `j`, `k`, `l`, `q`, `t` (#795).
* Add motion-serifed variants for `A`, `B`, `D`, `E`, `F`, `H`, `K`, `M`, `N`, `P`, `R`, `T`, `V`, `W`, `X`, `Y`, `Z`, `v`, `w`, `x`, `y`, `z` (#806, #815, #818).
* Add symmetric-legged variants for `K` and `k` (#807).
* Add horizontal-tailed and detach-tailed variants for `Q` (#808).
* Add hookless and capped variants for `G` (#809).
* Add open-contour variants for `P` and `R` (#810).
* Add standing variants for `R` (#810).
* Add toothed and motion-serifed variants for `U` (#811).
* Add double-v and asymmetric variants for `W` and `w` (#812).
* Add motion-serifed toothless variants for `u` (#813).
* Add flat-serifed variants for `1` (#819).
* Add IBM Plex Mono style set (#796).
* Fix broken geometry of `K` and `%` under ultra-wide (#800).
* Add straight-bar AE (`Æ`), follows variant selector for `A` (#800).
* Refine the shape of Slab `S` and `s` to add serifs at both terminals (#800).
- Variants of percent (`%`) sign are renamed.
* Add Characters:
* Z Notation Schema Composition (`U+2A1F`) and Z Notation Relation Composition (`U+2A3E`) (#857).
* Circled Zero With Slash (`U+1F10D`, #861).
* Add Variants:
* Add diagonal-tailed variants for `f`, `i`, `j`, `k`, `l`, `q`, `t` (#795).
* Add motion-serifed variants for `A`, `B`, `D`, `E`, `F`, `H`, `K`, `M`, `N`, `P`, `R`, `T`, `V`, `W`, `X`, `Y`, `Z`, `v`, `w`, `x`, `y`, `z` (#806, #815, #818).
* Add symmetric-legged variants for `K` and `k` (#807).
* Add horizontal-tailed and detach-tailed variants for `Q` (#808).
* Add hook-less and capped variants for `G` (#809).
* Add open-contour variants for `P` and `R` (#810).
* Add standing variants for `R` (#810).
* Add toothed and motion-serifed variants for `U` (#811).
* Add double-v and asymmetric variants for `W` and `w` (#812).
* Add motion-serifed toothless variants for `u` (#813).
* Add flat-serifed variants for `1` (#819).
* Add serifed and top-serifed variants for `S` and `s` (#800, #822).
* Add oblique-upper-left-bar variant for `5` (#820).
* Add compact-serifed and compact-top-serifed variants of `r` (#826).
* Add oval variant for `0` (#828).
* Add corner and flat-hooked variants for `?` (#829).
* Add oval slashed / dotted variants for `0` (#834).
* Add rings-continuous-slash-also-connected variant to `%` (#835).
* Add inward-serifed variants for `C`, `G`, `S`, `c` (#837).
* Add asymmetric variants for `N` (#838).
* Add base-serifed variants for `Y` (#850).
* Add base-serifed variants for `r` (#851).
* Add bar-interrupted variants for Dollar and Cent sign (#863).
* Add Hooky variant for `j` (#864).
* Add bend and curly variants for `7` (#866).
* Add interrupted variants for `B` (#869).
* Add variant selectors for Greek lower Alpha and Iota (#873).
* Add tail to Greek lower Pi and Tau (#875).
* Add compact/descending variants for `J` (#876).
* Add cursive `v` and `w`.
* Add straight-bar AE (`Æ`), follows variant selector for `A` (#800).
* Add IBM Plex Mono, PT Mono and Recursive Mono stylistic sets (#796, #855).
* Fix width of flat-hook-serifless `j` (#860).
* Fix broken shape of tailed Cyrillic DJE (`U+0452`, #803).
* Slightly increase size of `⊂`, `⊃`, `⊏` and `⊐` for better distinction (#804).

View file

@ -926,8 +926,11 @@ Subsection `variants` is used to configure character variants in the font. Prope
+ `z = 'curly-top-motion-serifed'`, `cv50 = 10`: Curly `z` with motion serifs at top.
- Styles for `ß` (Eszet):
+ `eszet = 'traditional'`, `cv51 = 1`: Traditional, Fraktur-like Eszet (`ß`).
+ `eszet = 'sulzbacher'`, `cv51 = 2`: More modern, beta-like Eszet (`ß`) (default).
+ `eszet = 'longs-s-lig'`, `cv51 = 3`: Eszet (`ß`) shown as a ligature of long-S (`ſ`) and `s`.
+ `eszet = 'traditional-tailed'`, `cv51 = 2`: Traditional, Fraktur-like Eszet (`ß`).
+ `eszet = 'sulzbacher'`, `cv51 = 3`: More modern, beta-like Eszet (`ß`) (default for Upright).
+ `eszet = 'sulzbacher-tailed'`, `cv51 = 4`: More modern, beta-like Eszet (`ß`) (default for Italic).
+ `eszet = 'longs-s-lig'`, `cv51 = 5`: Eszet (`ß`) shown as a ligature of long-S (`ſ`) and `s`.
+ `eszet = 'longs-s-lig-tailed'`, `cv51 = 6`: Eszet (`ß`) shown as a ligature of long-S (`ſ`) and `s`.
- Styles for `Λ`, `Δ`:
+ `turn-v = 'straight'`, `cv52 = 1`: Standard, straight `Λ`, `Δ` (default).
+ `turn-v = 'curly'`, `cv52 = 2`: Slightly curly `Λ`, `Δ`, like Iosevka 2.x.

View file

@ -0,0 +1,107 @@
"use strict";
const Transform = require("./transform");
const Point = require("./point");
const Anchor = require("./anchor");
module.exports = class GeometryStore {
constructor() {
this.m_contours = [];
this.m_references = [];
}
addContour(c, tag) {
if (tag) {
const zs = [...c];
zs.tag = tag;
this.m_contours.push(zs);
} else {
this.m_contours.push(c);
}
}
addReference(glyph, x, y) {
this.m_references.push({ glyph, x, y });
}
asContours() {
let result = [];
for (const c of this.m_contours) {
const c1 = [...c];
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
for (const r of this.m_references) {
for (const c of r.glyph.geometry.asContours()) {
let c1 = [];
for (const z of c) c1.push(Point.fromXY(z.type, z.x + r.x, z.y + r.y));
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
}
return result;
}
asReferences() {
if (this.m_contours && this.m_contours.length) return null;
if (!this.m_references.length) return null;
return this.m_references;
}
applyTranslate(shiftX, shiftY) {
for (const c of this.m_contours) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.translated(c[k], shiftX, shiftY);
}
}
for (const r of this.m_references) {
r.x += shiftX;
r.y += shiftY;
}
}
applyTransform(tfm) {
const cs = this.asContours();
for (const c of cs) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.transformed(tfm, c[k]);
}
}
this.m_contours = cs;
this.m_references.length = 0;
}
reTagContour(oldTag, newTag) {
for (const c of this.m_contours) {
if (c.tag === oldTag) c.tag = newTag;
}
}
ejectContour(tag) {
const cs = this.asContours();
let i = 0,
j = 0;
for (; i < cs.length; i++) if (!cs[i].tag || cs[i].tag !== tag) cs[j++] = cs[i];
cs.length = j;
this.m_contours = cs;
this.m_references = [];
}
suppressNaN() {
let broken = false,
complexity = 0;
for (const c of this.m_contours) {
for (const z of c) {
complexity++;
if (!isFinite(z.x)) {
broken = true;
z.x = 0;
}
if (!isFinite(z.y)) {
broken = true;
z.y = 0;
}
}
}
return broken ? 0xffff : complexity;
}
isEmpty() {
return !this.m_contours.length && !this.m_references.length;
}
};

View file

@ -3,6 +3,7 @@
const Transform = require("./transform");
const Point = require("./point");
const Anchor = require("./anchor");
const GeometryStore = require("./geometry");
module.exports = class Glyph {
constructor(_identifier) {
@ -114,9 +115,8 @@ module.exports = class Glyph {
includeContours(cs, shiftX, shiftY) {
for (const contour of cs) {
let c = [];
c.tag = contour.tag || cs.tag || this.defaultTag;
for (const z of contour) c.push(Point.translated(z, shiftX, shiftY));
this.geometry.addContour(c);
this.geometry.addContour(c, contour.tag || cs.tag || this.defaultTag);
}
}
@ -195,99 +195,3 @@ module.exports = class Glyph {
delete this.markAnchors[id];
}
};
class GeometryStore {
constructor() {
this.m_contours = [];
this.m_references = [];
}
addContour(c) {
this.m_contours.push(c);
}
addReference(glyph, x, y) {
this.m_references.push({ glyph, x, y });
}
asContours() {
let result = [];
for (const c of this.m_contours) {
const c1 = [...c];
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
for (const r of this.m_references) {
for (const c of r.glyph.geometry.asContours()) {
let c1 = [];
for (const z of c) c1.push(Point.fromXY(z.type, z.x + r.x, z.y + r.y));
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
}
return result;
}
asReferences() {
if (this.m_contours && this.m_contours.length) return null;
if (!this.m_references.length) return null;
return this.m_references;
}
applyTranslate(shiftX, shiftY) {
for (const c of this.m_contours) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.translated(c[k], shiftX, shiftY);
}
}
for (const r of this.m_references) {
r.x += shiftX;
r.y += shiftY;
}
}
applyTransform(tfm) {
const cs = this.asContours();
for (const c of cs) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.transformed(tfm, c[k]);
}
}
this.m_contours = cs;
this.m_references.length = 0;
}
reTagContour(oldTag, newTag) {
for (const c of this.m_contours) {
if (c.tag === oldTag) c.tag = newTag;
}
}
ejectContour(tag) {
const cs = this.asContours();
let i = 0,
j = 0;
for (; i < cs.length; i++) if (!cs[i].tag || cs[i].tag !== tag) cs[j++] = cs[i];
cs.length = j;
this.m_contours = cs;
this.m_references = [];
}
suppressNaN() {
let broken = false,
complexity = 0;
for (const c of this.m_contours) {
for (const z of c) {
complexity++;
if (!isFinite(z.x)) {
broken = true;
z.x = 0;
}
if (!isFinite(z.y)) {
broken = true;
z.y = 0;
}
}
}
return broken ? 0xffff : complexity;
}
isEmpty() {
return !this.m_contours.length && !this.m_references.length;
}
}

View file

@ -1,6 +1,6 @@
{
"name": "iosevka",
"version": "5.0.0-rc.1",
"version": "5.0.0",
"main": "./font-src/index.js",
"scripts": {
"build": "node utility/ensure-verda-exists && verda -f verdafile.js",