imagescript 3.7.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -97
- package/THIRD_PARTY_NOTICES.md +101 -1
- package/dist/animation-encoder.d.ts +62 -0
- package/dist/animation-encoder.js +204 -0
- package/dist/animation.d.ts +32 -2
- package/dist/animation.js +14 -3
- package/dist/codecs/gif.js +37 -24
- package/dist/codecs/png.js +77 -37
- package/dist/codecs/sharpyuv.js +150 -0
- package/dist/codecs/vp8-enc-dsp.js +9 -1
- package/dist/codecs/vp8l.js +1 -1
- package/dist/codecs/webp.js +36 -26
- package/dist/codecs/zlib.js +20 -0
- package/dist/image.d.ts +27 -3
- package/dist/image.js +54 -15
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/render/filter.js +939 -0
- package/dist/render/shape.js +12 -6
- package/dist/render/svg.js +1140 -36
- package/dist/render/text.js +9 -9
- package/dist/util/optimize.js +208 -62
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/render/shape.js
CHANGED
|
@@ -143,11 +143,11 @@ export class ShapeFont {
|
|
|
143
143
|
advance(glyph) {
|
|
144
144
|
return glyph < this.font.numGlyphs ? this.font.advance(glyph) : 0;
|
|
145
145
|
}
|
|
146
|
-
plan(script, direction) {
|
|
147
|
-
const key = `${script}:${direction}`;
|
|
146
|
+
plan(script, direction, features = []) {
|
|
147
|
+
const key = `${script}:${direction}:${features.map(([tag, value]) => `${tag}=${value}`).join(',')}`;
|
|
148
148
|
let plan = this.plans.get(key);
|
|
149
149
|
if (!plan)
|
|
150
|
-
this.plans.set(key, plan = new Planner(this, script, direction).compile());
|
|
150
|
+
this.plans.set(key, plan = new Planner(this, script, direction, features).compile());
|
|
151
151
|
return plan;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -166,12 +166,14 @@ export class Planner {
|
|
|
166
166
|
font;
|
|
167
167
|
script;
|
|
168
168
|
direction;
|
|
169
|
+
features;
|
|
169
170
|
map;
|
|
170
171
|
shaper;
|
|
171
|
-
constructor(font, script, direction) {
|
|
172
|
+
constructor(font, script, direction, features = []) {
|
|
172
173
|
this.font = font;
|
|
173
174
|
this.script = script;
|
|
174
175
|
this.direction = direction;
|
|
176
|
+
this.features = features;
|
|
175
177
|
this.map = new MapBuilder([font.gsub, font.gpos], scriptTags(script));
|
|
176
178
|
this.shaper = shaperFor.categorize(script, direction, this.map.chosenScript[0]);
|
|
177
179
|
}
|
|
@@ -203,6 +205,10 @@ export class Planner {
|
|
|
203
205
|
map.addFeature(tag, flags);
|
|
204
206
|
for (const [tag, flags] of HORIZONTAL_FEATURES)
|
|
205
207
|
map.addFeature(tag, flags);
|
|
208
|
+
if (this.features.length)
|
|
209
|
+
map.isSimple = false;
|
|
210
|
+
for (const [tag, value] of this.features)
|
|
211
|
+
map.addFeature(tag, 1, value);
|
|
206
212
|
if (shaper.overrideFeatures)
|
|
207
213
|
shaper.overrideFeatures(this);
|
|
208
214
|
const m = map.compile();
|
|
@@ -932,7 +938,7 @@ function position(plan, font, buffer) {
|
|
|
932
938
|
if (buffer.direction === 5)
|
|
933
939
|
buffer.reverse();
|
|
934
940
|
}
|
|
935
|
-
export function shapeRun(font, codepoints, script, direction, clusters, context = { before: [], after: [] }) {
|
|
941
|
+
export function shapeRun(font, codepoints, script, direction, clusters, context = { before: [], after: [] }, features = []) {
|
|
936
942
|
const buffer = new Buffer();
|
|
937
943
|
buffer.direction = direction;
|
|
938
944
|
buffer.script = script;
|
|
@@ -947,7 +953,7 @@ export function shapeRun(font, codepoints, script, direction, clusters, context
|
|
|
947
953
|
buffer.limit();
|
|
948
954
|
if (!buffer.len)
|
|
949
955
|
return [];
|
|
950
|
-
const plan = font.plan(script, direction);
|
|
956
|
+
const plan = font.plan(script, direction, features);
|
|
951
957
|
const targetDirection = buffer.direction;
|
|
952
958
|
let hasFractionSlash = false;
|
|
953
959
|
for (const info of buffer.info)
|