emf-converter 4.25.7 → 4.26.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 +1 -1
- package/dist/browser.js +44 -3
- package/dist/browser.mjs +44 -3
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +44 -3
- package/dist/index.mjs +44 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -344,7 +344,7 @@ page. The defaults are `1252` and `437`; explicit text charsets are unchanged.
|
|
|
344
344
|
| `maxRecords` | `number` | `200000`/`500000` | Records processed per stream before replay stops (EMF+ uses the higher default unless overridden) |
|
|
345
345
|
| `gdiAntialias` | `boolean` | `false` (PNG) | `true` smooths every shape edge with Canvas antialiasing instead of reproducing Windows' own GDI/GDI+ rasterisation |
|
|
346
346
|
| `fonts` | `Array<ArrayBuffer \| ArrayBufferView>` | None | TrueType (`.ttf`/`.ttc`) and raster (`.fon`/`.fnt`) font files for exact GDI text |
|
|
347
|
-
| `fontSmoothing` | `'cleartype' \| 'gray' \| 'mono'` | `'cleartype'` | What `DEFAULT_QUALITY` / `DRAFT_QUALITY` / `PROOF_QUALITY` fonts render as (Windows' system setting) |
|
|
347
|
+
| `fontSmoothing` | `'cleartype' \| 'gray' \| 'mono'` | `'cleartype'` | What `DEFAULT_QUALITY` / `DRAFT_QUALITY` / `PROOF_QUALITY` fonts and GDI+ SystemDefault text render as (Windows' system setting) |
|
|
348
348
|
| `fontFamilyMap` | `Record<string, string>` | None | Without `fonts`: maps Windows face names (case-insensitive) to locally available fonts, e.g. `{ calibri: 'Carlito' }` |
|
|
349
349
|
| `signal` | `AbortSignal` | None | Cancels the conversion: the promise rejects with `signal.reason` when it aborts (see [Cancellation](#cancellation)) |
|
|
350
350
|
| `timeoutMs` | `number` | None | Rejects with a `DOMException` named `TimeoutError` after this many milliseconds |
|
package/dist/browser.js
CHANGED
|
@@ -42878,7 +42878,15 @@ var RealizedFont = class {
|
|
|
42878
42878
|
this.advanceOutlines = /* @__PURE__ */ new Map();
|
|
42879
42879
|
this.outlines = /* @__PURE__ */ new Map();
|
|
42880
42880
|
this.glyphs = /* @__PURE__ */ new Map();
|
|
42881
|
+
/**
|
|
42882
|
+
* The font was asked for at NONANTIALIASED_QUALITY (GDI+ SingleBitPerPixelGridFit), not turned monochrome by
|
|
42883
|
+
* the `gasp` table under AntiAliasGridFit: those glyphs keep the previous path (the native grayscale corpora,
|
|
42884
|
+
* `gdiplus-courier-gray` and `gdiplus-shpix-x`, lose exact glyphs the GDI way).
|
|
42885
|
+
*/
|
|
42886
|
+
this.singleBitRequested = false;
|
|
42881
42887
|
this.reverseCmap = null;
|
|
42888
|
+
this.gdiMonoSize = null;
|
|
42889
|
+
this.gdiMonoOutlines = /* @__PURE__ */ new Map();
|
|
42882
42890
|
this.ctSize = null;
|
|
42883
42891
|
/** CLEARTYPE_NATURAL_QUALITY: ClearType glyphs keep their own (natural) widths. */
|
|
42884
42892
|
this.naturalWidths = false;
|
|
@@ -42938,6 +42946,17 @@ var RealizedFont = class {
|
|
|
42938
42946
|
* way, at a half turn it rounded (all 530 ascents and descents of five faces at lfHeight -8..-60 for 90, 180 and
|
|
42939
42947
|
* 270 degrees, escapement and world rotation alike). Undefined for an upright baseline.
|
|
42940
42948
|
*/
|
|
42949
|
+
/**
|
|
42950
|
+
* GDI+ SingleBitPerPixelGridFit glyphs are close to GDI's monochrome glyphs: hinted with GDI's arithmetic and
|
|
42951
|
+
* scan-converted with GDI's converter, 1,658 of 1,680 native upright regular glyphs are exact (`xwvyAkMWKVXZ4&%`,
|
|
42952
|
+
* Arial, Tahoma, Times New Roman and Segoe UI at 9 to 36 px), against 1,442 with the previous arithmetic. GDI+'s
|
|
42953
|
+
* own arithmetic is neither: 15 glyphs (Arial 16 `w` among them) are exact only the old way, and no subset of
|
|
42954
|
+
* GDI's projection, movement and ISECT rules gets both. Italic faces keep the previous path (Times New Roman
|
|
42955
|
+
* Italic 22 in `textx-plus-singlebitgridfit`: 8 pixels the GDI way).
|
|
42956
|
+
*/
|
|
42957
|
+
plusMonoAsGdi(gdiPlus, mode, gridFit) {
|
|
42958
|
+
return gdiPlus && mode === "mono" && gridFit && this.singleBitRequested;
|
|
42959
|
+
}
|
|
42941
42960
|
rotatedMetrics(ux, uy) {
|
|
42942
42961
|
if (Math.abs(ux) > 1e-9 && Math.abs(uy) > 1e-9) {
|
|
42943
42962
|
return { ascent: this.rotatedAscent, descent: this.rotatedDescent };
|
|
@@ -42972,6 +42991,20 @@ var RealizedFont = class {
|
|
|
42972
42991
|
}
|
|
42973
42992
|
return this.reverseCmap.get(index) ?? 65533;
|
|
42974
42993
|
}
|
|
42994
|
+
/**
|
|
42995
|
+
* The outline of an upright GDI+ SingleBitPerPixelGridFit glyph, hinted
|
|
42996
|
+
* with GDI's arithmetic (see {@link plusMonoAsGdi}). Advances keep coming
|
|
42997
|
+
* from {@link outline}, whose placement the DrawString fixtures pin.
|
|
42998
|
+
*/
|
|
42999
|
+
gdiMonoOutline(index) {
|
|
43000
|
+
let g = this.gdiMonoOutlines.get(index);
|
|
43001
|
+
if (!g) {
|
|
43002
|
+
this.gdiMonoSize ?? (this.gdiMonoSize = new HintedSize(this.ttf, this.ppemX, this.ppem, { version: 35, grayscale: false, gdiArithmetic: true, reportStretched: this.playbackStretched }, true));
|
|
43003
|
+
g = this.gdiMonoSize.hintGlyph(index < this.ttf.numGlyphs ? index : NOTDEF);
|
|
43004
|
+
this.gdiMonoOutlines.set(index, g);
|
|
43005
|
+
}
|
|
43006
|
+
return g;
|
|
43007
|
+
}
|
|
42975
43008
|
outline(index) {
|
|
42976
43009
|
let g = this.outlines.get(index);
|
|
42977
43010
|
if (!g) {
|
|
@@ -43118,7 +43151,8 @@ var RealizedFont = class {
|
|
|
43118
43151
|
}
|
|
43119
43152
|
const skew = m && !(Math.abs(m[1]) < 1e-9 && Math.abs(m[2]) < 1e-9) && !(Math.abs(m[0]) < 1e-9 && Math.abs(m[3]) < 1e-9);
|
|
43120
43153
|
const rotation = skew && m && !this.gdiPlus && this.ppemX === this.ppem ? rotationMatrix(m, this.ppem, (this.ttf.headFlags & 8) !== 0) : null;
|
|
43121
|
-
const
|
|
43154
|
+
const asGdiMono = !m && !subX && !subY && this.ppemX === this.ppem && !this.syntheticItalic && !(this.ttf.fsSelection & 1) && this.plusMonoAsGdi(this.gdiPlus, this.mode, this.gridFit);
|
|
43155
|
+
const src = skew ? this.rotatedOutline(index, rotation ? rotation.ppem : 0) : asGdiMono ? this.gdiMonoOutline(index) : this.outline(index);
|
|
43122
43156
|
if (skew && m && rotation) {
|
|
43123
43157
|
m = rotation.matrix;
|
|
43124
43158
|
} else if (skew && m) {
|
|
@@ -43161,7 +43195,7 @@ var RealizedFont = class {
|
|
|
43161
43195
|
if (this.mode === "mono") {
|
|
43162
43196
|
const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
|
|
43163
43197
|
const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
|
|
43164
|
-
bitmap = this.gdiPlus ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43198
|
+
bitmap = this.gdiPlus && !asGdiMono ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43165
43199
|
} else if (this.mode === "cleartype") {
|
|
43166
43200
|
const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
|
|
43167
43201
|
bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
|
|
@@ -43416,6 +43450,7 @@ var GdiFontCollection = class _GdiFontCollection {
|
|
|
43416
43450
|
this.installedFonts
|
|
43417
43451
|
);
|
|
43418
43452
|
tt2.naturalWidths = spec.quality === CLEARTYPE_NATURAL_QUALITY;
|
|
43453
|
+
tt2.singleBitRequested = spec.quality === NONANTIALIASED_QUALITY;
|
|
43419
43454
|
return tt2;
|
|
43420
43455
|
};
|
|
43421
43456
|
let tt = make(resolvePpem(best, spec.height), spec.height > 0 ? Math.round(spec.height) : 0);
|
|
@@ -54869,10 +54904,16 @@ function worldUnitFont(rCtx, obj) {
|
|
|
54869
54904
|
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54870
54905
|
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54871
54906
|
}
|
|
54907
|
+
function resolvePlusTextHint(hint, smoothing) {
|
|
54908
|
+
if (hint !== 0) {
|
|
54909
|
+
return hint;
|
|
54910
|
+
}
|
|
54911
|
+
return smoothing === "mono" ? 1 : smoothing === "gray" ? 3 : 5;
|
|
54912
|
+
}
|
|
54872
54913
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54873
54914
|
const fonts = rCtx.fonts;
|
|
54874
54915
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
54875
|
-
const hint = rCtx.textRenderingHint ?? 0;
|
|
54916
|
+
const hint = resolvePlusTextHint(rCtx.textRenderingHint ?? 0, fonts?.defaultSmoothing);
|
|
54876
54917
|
const graySmooth = hint === 3 || hint === 4 || hint === 5;
|
|
54877
54918
|
const solidViaCoverage = !!color && graySmooth && !isSvgContext(rCtx.ctx);
|
|
54878
54919
|
const sampler = isSvgContext(rCtx.ctx) ? null : solidViaCoverage ? solidSampler(cssColorToArgb(paint) ?? 4278190080) : color ? null : brushSampler2;
|
package/dist/browser.mjs
CHANGED
|
@@ -42876,7 +42876,15 @@ var RealizedFont = class {
|
|
|
42876
42876
|
this.advanceOutlines = /* @__PURE__ */ new Map();
|
|
42877
42877
|
this.outlines = /* @__PURE__ */ new Map();
|
|
42878
42878
|
this.glyphs = /* @__PURE__ */ new Map();
|
|
42879
|
+
/**
|
|
42880
|
+
* The font was asked for at NONANTIALIASED_QUALITY (GDI+ SingleBitPerPixelGridFit), not turned monochrome by
|
|
42881
|
+
* the `gasp` table under AntiAliasGridFit: those glyphs keep the previous path (the native grayscale corpora,
|
|
42882
|
+
* `gdiplus-courier-gray` and `gdiplus-shpix-x`, lose exact glyphs the GDI way).
|
|
42883
|
+
*/
|
|
42884
|
+
this.singleBitRequested = false;
|
|
42879
42885
|
this.reverseCmap = null;
|
|
42886
|
+
this.gdiMonoSize = null;
|
|
42887
|
+
this.gdiMonoOutlines = /* @__PURE__ */ new Map();
|
|
42880
42888
|
this.ctSize = null;
|
|
42881
42889
|
/** CLEARTYPE_NATURAL_QUALITY: ClearType glyphs keep their own (natural) widths. */
|
|
42882
42890
|
this.naturalWidths = false;
|
|
@@ -42936,6 +42944,17 @@ var RealizedFont = class {
|
|
|
42936
42944
|
* way, at a half turn it rounded (all 530 ascents and descents of five faces at lfHeight -8..-60 for 90, 180 and
|
|
42937
42945
|
* 270 degrees, escapement and world rotation alike). Undefined for an upright baseline.
|
|
42938
42946
|
*/
|
|
42947
|
+
/**
|
|
42948
|
+
* GDI+ SingleBitPerPixelGridFit glyphs are close to GDI's monochrome glyphs: hinted with GDI's arithmetic and
|
|
42949
|
+
* scan-converted with GDI's converter, 1,658 of 1,680 native upright regular glyphs are exact (`xwvyAkMWKVXZ4&%`,
|
|
42950
|
+
* Arial, Tahoma, Times New Roman and Segoe UI at 9 to 36 px), against 1,442 with the previous arithmetic. GDI+'s
|
|
42951
|
+
* own arithmetic is neither: 15 glyphs (Arial 16 `w` among them) are exact only the old way, and no subset of
|
|
42952
|
+
* GDI's projection, movement and ISECT rules gets both. Italic faces keep the previous path (Times New Roman
|
|
42953
|
+
* Italic 22 in `textx-plus-singlebitgridfit`: 8 pixels the GDI way).
|
|
42954
|
+
*/
|
|
42955
|
+
plusMonoAsGdi(gdiPlus, mode, gridFit) {
|
|
42956
|
+
return gdiPlus && mode === "mono" && gridFit && this.singleBitRequested;
|
|
42957
|
+
}
|
|
42939
42958
|
rotatedMetrics(ux, uy) {
|
|
42940
42959
|
if (Math.abs(ux) > 1e-9 && Math.abs(uy) > 1e-9) {
|
|
42941
42960
|
return { ascent: this.rotatedAscent, descent: this.rotatedDescent };
|
|
@@ -42970,6 +42989,20 @@ var RealizedFont = class {
|
|
|
42970
42989
|
}
|
|
42971
42990
|
return this.reverseCmap.get(index) ?? 65533;
|
|
42972
42991
|
}
|
|
42992
|
+
/**
|
|
42993
|
+
* The outline of an upright GDI+ SingleBitPerPixelGridFit glyph, hinted
|
|
42994
|
+
* with GDI's arithmetic (see {@link plusMonoAsGdi}). Advances keep coming
|
|
42995
|
+
* from {@link outline}, whose placement the DrawString fixtures pin.
|
|
42996
|
+
*/
|
|
42997
|
+
gdiMonoOutline(index) {
|
|
42998
|
+
let g = this.gdiMonoOutlines.get(index);
|
|
42999
|
+
if (!g) {
|
|
43000
|
+
this.gdiMonoSize ?? (this.gdiMonoSize = new HintedSize(this.ttf, this.ppemX, this.ppem, { version: 35, grayscale: false, gdiArithmetic: true, reportStretched: this.playbackStretched }, true));
|
|
43001
|
+
g = this.gdiMonoSize.hintGlyph(index < this.ttf.numGlyphs ? index : NOTDEF);
|
|
43002
|
+
this.gdiMonoOutlines.set(index, g);
|
|
43003
|
+
}
|
|
43004
|
+
return g;
|
|
43005
|
+
}
|
|
42973
43006
|
outline(index) {
|
|
42974
43007
|
let g = this.outlines.get(index);
|
|
42975
43008
|
if (!g) {
|
|
@@ -43116,7 +43149,8 @@ var RealizedFont = class {
|
|
|
43116
43149
|
}
|
|
43117
43150
|
const skew = m && !(Math.abs(m[1]) < 1e-9 && Math.abs(m[2]) < 1e-9) && !(Math.abs(m[0]) < 1e-9 && Math.abs(m[3]) < 1e-9);
|
|
43118
43151
|
const rotation = skew && m && !this.gdiPlus && this.ppemX === this.ppem ? rotationMatrix(m, this.ppem, (this.ttf.headFlags & 8) !== 0) : null;
|
|
43119
|
-
const
|
|
43152
|
+
const asGdiMono = !m && !subX && !subY && this.ppemX === this.ppem && !this.syntheticItalic && !(this.ttf.fsSelection & 1) && this.plusMonoAsGdi(this.gdiPlus, this.mode, this.gridFit);
|
|
43153
|
+
const src = skew ? this.rotatedOutline(index, rotation ? rotation.ppem : 0) : asGdiMono ? this.gdiMonoOutline(index) : this.outline(index);
|
|
43120
43154
|
if (skew && m && rotation) {
|
|
43121
43155
|
m = rotation.matrix;
|
|
43122
43156
|
} else if (skew && m) {
|
|
@@ -43159,7 +43193,7 @@ var RealizedFont = class {
|
|
|
43159
43193
|
if (this.mode === "mono") {
|
|
43160
43194
|
const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
|
|
43161
43195
|
const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
|
|
43162
|
-
bitmap = this.gdiPlus ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43196
|
+
bitmap = this.gdiPlus && !asGdiMono ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43163
43197
|
} else if (this.mode === "cleartype") {
|
|
43164
43198
|
const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
|
|
43165
43199
|
bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
|
|
@@ -43414,6 +43448,7 @@ var GdiFontCollection = class _GdiFontCollection {
|
|
|
43414
43448
|
this.installedFonts
|
|
43415
43449
|
);
|
|
43416
43450
|
tt2.naturalWidths = spec.quality === CLEARTYPE_NATURAL_QUALITY;
|
|
43451
|
+
tt2.singleBitRequested = spec.quality === NONANTIALIASED_QUALITY;
|
|
43417
43452
|
return tt2;
|
|
43418
43453
|
};
|
|
43419
43454
|
let tt = make(resolvePpem(best, spec.height), spec.height > 0 ? Math.round(spec.height) : 0);
|
|
@@ -54867,10 +54902,16 @@ function worldUnitFont(rCtx, obj) {
|
|
|
54867
54902
|
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54868
54903
|
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54869
54904
|
}
|
|
54905
|
+
function resolvePlusTextHint(hint, smoothing) {
|
|
54906
|
+
if (hint !== 0) {
|
|
54907
|
+
return hint;
|
|
54908
|
+
}
|
|
54909
|
+
return smoothing === "mono" ? 1 : smoothing === "gray" ? 3 : 5;
|
|
54910
|
+
}
|
|
54870
54911
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54871
54912
|
const fonts = rCtx.fonts;
|
|
54872
54913
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
54873
|
-
const hint = rCtx.textRenderingHint ?? 0;
|
|
54914
|
+
const hint = resolvePlusTextHint(rCtx.textRenderingHint ?? 0, fonts?.defaultSmoothing);
|
|
54874
54915
|
const graySmooth = hint === 3 || hint === 4 || hint === 5;
|
|
54875
54916
|
const solidViaCoverage = !!color && graySmooth && !isSvgContext(rCtx.ctx);
|
|
54876
54917
|
const sampler = isSvgContext(rCtx.ctx) ? null : solidViaCoverage ? solidSampler(cssColorToArgb(paint) ?? 4278190080) : color ? null : brushSampler2;
|
package/dist/index.d.mts
CHANGED
|
@@ -224,7 +224,10 @@ interface EmfConvertOptions {
|
|
|
224
224
|
* Windows' system-wide font smoothing, which GDI applies to fonts that
|
|
225
225
|
* ask for `DEFAULT_QUALITY`, `DRAFT_QUALITY` or `PROOF_QUALITY` (most
|
|
226
226
|
* metafiles): `'cleartype'` (Windows' default), `'gray'` (standard
|
|
227
|
-
* antialiasing) or `'mono'` (smoothing off).
|
|
227
|
+
* antialiasing) or `'mono'` (smoothing off). GDI+ text with the
|
|
228
|
+
* SystemDefault rendering hint (EMF+ files without a TextRenderingHint)
|
|
229
|
+
* follows it too: ClearTypeGridFit, AntiAliasGridFit or single-bit
|
|
230
|
+
* grid-fitted. Only used with `fonts`.
|
|
228
231
|
*/
|
|
229
232
|
fontSmoothing?: 'cleartype' | 'gray' | 'mono';
|
|
230
233
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -224,7 +224,10 @@ interface EmfConvertOptions {
|
|
|
224
224
|
* Windows' system-wide font smoothing, which GDI applies to fonts that
|
|
225
225
|
* ask for `DEFAULT_QUALITY`, `DRAFT_QUALITY` or `PROOF_QUALITY` (most
|
|
226
226
|
* metafiles): `'cleartype'` (Windows' default), `'gray'` (standard
|
|
227
|
-
* antialiasing) or `'mono'` (smoothing off).
|
|
227
|
+
* antialiasing) or `'mono'` (smoothing off). GDI+ text with the
|
|
228
|
+
* SystemDefault rendering hint (EMF+ files without a TextRenderingHint)
|
|
229
|
+
* follows it too: ClearTypeGridFit, AntiAliasGridFit or single-bit
|
|
230
|
+
* grid-fitted. Only used with `fonts`.
|
|
228
231
|
*/
|
|
229
232
|
fontSmoothing?: 'cleartype' | 'gray' | 'mono';
|
|
230
233
|
/**
|
package/dist/index.js
CHANGED
|
@@ -42879,7 +42879,15 @@ var RealizedFont = class {
|
|
|
42879
42879
|
this.advanceOutlines = /* @__PURE__ */ new Map();
|
|
42880
42880
|
this.outlines = /* @__PURE__ */ new Map();
|
|
42881
42881
|
this.glyphs = /* @__PURE__ */ new Map();
|
|
42882
|
+
/**
|
|
42883
|
+
* The font was asked for at NONANTIALIASED_QUALITY (GDI+ SingleBitPerPixelGridFit), not turned monochrome by
|
|
42884
|
+
* the `gasp` table under AntiAliasGridFit: those glyphs keep the previous path (the native grayscale corpora,
|
|
42885
|
+
* `gdiplus-courier-gray` and `gdiplus-shpix-x`, lose exact glyphs the GDI way).
|
|
42886
|
+
*/
|
|
42887
|
+
this.singleBitRequested = false;
|
|
42882
42888
|
this.reverseCmap = null;
|
|
42889
|
+
this.gdiMonoSize = null;
|
|
42890
|
+
this.gdiMonoOutlines = /* @__PURE__ */ new Map();
|
|
42883
42891
|
this.ctSize = null;
|
|
42884
42892
|
/** CLEARTYPE_NATURAL_QUALITY: ClearType glyphs keep their own (natural) widths. */
|
|
42885
42893
|
this.naturalWidths = false;
|
|
@@ -42939,6 +42947,17 @@ var RealizedFont = class {
|
|
|
42939
42947
|
* way, at a half turn it rounded (all 530 ascents and descents of five faces at lfHeight -8..-60 for 90, 180 and
|
|
42940
42948
|
* 270 degrees, escapement and world rotation alike). Undefined for an upright baseline.
|
|
42941
42949
|
*/
|
|
42950
|
+
/**
|
|
42951
|
+
* GDI+ SingleBitPerPixelGridFit glyphs are close to GDI's monochrome glyphs: hinted with GDI's arithmetic and
|
|
42952
|
+
* scan-converted with GDI's converter, 1,658 of 1,680 native upright regular glyphs are exact (`xwvyAkMWKVXZ4&%`,
|
|
42953
|
+
* Arial, Tahoma, Times New Roman and Segoe UI at 9 to 36 px), against 1,442 with the previous arithmetic. GDI+'s
|
|
42954
|
+
* own arithmetic is neither: 15 glyphs (Arial 16 `w` among them) are exact only the old way, and no subset of
|
|
42955
|
+
* GDI's projection, movement and ISECT rules gets both. Italic faces keep the previous path (Times New Roman
|
|
42956
|
+
* Italic 22 in `textx-plus-singlebitgridfit`: 8 pixels the GDI way).
|
|
42957
|
+
*/
|
|
42958
|
+
plusMonoAsGdi(gdiPlus, mode, gridFit) {
|
|
42959
|
+
return gdiPlus && mode === "mono" && gridFit && this.singleBitRequested;
|
|
42960
|
+
}
|
|
42942
42961
|
rotatedMetrics(ux, uy) {
|
|
42943
42962
|
if (Math.abs(ux) > 1e-9 && Math.abs(uy) > 1e-9) {
|
|
42944
42963
|
return { ascent: this.rotatedAscent, descent: this.rotatedDescent };
|
|
@@ -42973,6 +42992,20 @@ var RealizedFont = class {
|
|
|
42973
42992
|
}
|
|
42974
42993
|
return this.reverseCmap.get(index) ?? 65533;
|
|
42975
42994
|
}
|
|
42995
|
+
/**
|
|
42996
|
+
* The outline of an upright GDI+ SingleBitPerPixelGridFit glyph, hinted
|
|
42997
|
+
* with GDI's arithmetic (see {@link plusMonoAsGdi}). Advances keep coming
|
|
42998
|
+
* from {@link outline}, whose placement the DrawString fixtures pin.
|
|
42999
|
+
*/
|
|
43000
|
+
gdiMonoOutline(index) {
|
|
43001
|
+
let g = this.gdiMonoOutlines.get(index);
|
|
43002
|
+
if (!g) {
|
|
43003
|
+
this.gdiMonoSize ?? (this.gdiMonoSize = new HintedSize(this.ttf, this.ppemX, this.ppem, { version: 35, grayscale: false, gdiArithmetic: true, reportStretched: this.playbackStretched }, true));
|
|
43004
|
+
g = this.gdiMonoSize.hintGlyph(index < this.ttf.numGlyphs ? index : NOTDEF);
|
|
43005
|
+
this.gdiMonoOutlines.set(index, g);
|
|
43006
|
+
}
|
|
43007
|
+
return g;
|
|
43008
|
+
}
|
|
42976
43009
|
outline(index) {
|
|
42977
43010
|
let g = this.outlines.get(index);
|
|
42978
43011
|
if (!g) {
|
|
@@ -43119,7 +43152,8 @@ var RealizedFont = class {
|
|
|
43119
43152
|
}
|
|
43120
43153
|
const skew = m && !(Math.abs(m[1]) < 1e-9 && Math.abs(m[2]) < 1e-9) && !(Math.abs(m[0]) < 1e-9 && Math.abs(m[3]) < 1e-9);
|
|
43121
43154
|
const rotation = skew && m && !this.gdiPlus && this.ppemX === this.ppem ? rotationMatrix(m, this.ppem, (this.ttf.headFlags & 8) !== 0) : null;
|
|
43122
|
-
const
|
|
43155
|
+
const asGdiMono = !m && !subX && !subY && this.ppemX === this.ppem && !this.syntheticItalic && !(this.ttf.fsSelection & 1) && this.plusMonoAsGdi(this.gdiPlus, this.mode, this.gridFit);
|
|
43156
|
+
const src = skew ? this.rotatedOutline(index, rotation ? rotation.ppem : 0) : asGdiMono ? this.gdiMonoOutline(index) : this.outline(index);
|
|
43123
43157
|
if (skew && m && rotation) {
|
|
43124
43158
|
m = rotation.matrix;
|
|
43125
43159
|
} else if (skew && m) {
|
|
@@ -43162,7 +43196,7 @@ var RealizedFont = class {
|
|
|
43162
43196
|
if (this.mode === "mono") {
|
|
43163
43197
|
const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
|
|
43164
43198
|
const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
|
|
43165
|
-
bitmap = this.gdiPlus ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43199
|
+
bitmap = this.gdiPlus && !asGdiMono ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43166
43200
|
} else if (this.mode === "cleartype") {
|
|
43167
43201
|
const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
|
|
43168
43202
|
bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
|
|
@@ -43417,6 +43451,7 @@ var GdiFontCollection = class _GdiFontCollection {
|
|
|
43417
43451
|
this.installedFonts
|
|
43418
43452
|
);
|
|
43419
43453
|
tt2.naturalWidths = spec.quality === CLEARTYPE_NATURAL_QUALITY;
|
|
43454
|
+
tt2.singleBitRequested = spec.quality === NONANTIALIASED_QUALITY;
|
|
43420
43455
|
return tt2;
|
|
43421
43456
|
};
|
|
43422
43457
|
let tt = make(resolvePpem(best, spec.height), spec.height > 0 ? Math.round(spec.height) : 0);
|
|
@@ -54870,10 +54905,16 @@ function worldUnitFont(rCtx, obj) {
|
|
|
54870
54905
|
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54871
54906
|
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54872
54907
|
}
|
|
54908
|
+
function resolvePlusTextHint(hint, smoothing) {
|
|
54909
|
+
if (hint !== 0) {
|
|
54910
|
+
return hint;
|
|
54911
|
+
}
|
|
54912
|
+
return smoothing === "mono" ? 1 : smoothing === "gray" ? 3 : 5;
|
|
54913
|
+
}
|
|
54873
54914
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54874
54915
|
const fonts = rCtx.fonts;
|
|
54875
54916
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
54876
|
-
const hint = rCtx.textRenderingHint ?? 0;
|
|
54917
|
+
const hint = resolvePlusTextHint(rCtx.textRenderingHint ?? 0, fonts?.defaultSmoothing);
|
|
54877
54918
|
const graySmooth = hint === 3 || hint === 4 || hint === 5;
|
|
54878
54919
|
const solidViaCoverage = !!color && graySmooth && !isSvgContext(rCtx.ctx);
|
|
54879
54920
|
const sampler = isSvgContext(rCtx.ctx) ? null : solidViaCoverage ? solidSampler(cssColorToArgb(paint) ?? 4278190080) : color ? null : brushSampler2;
|
package/dist/index.mjs
CHANGED
|
@@ -42877,7 +42877,15 @@ var RealizedFont = class {
|
|
|
42877
42877
|
this.advanceOutlines = /* @__PURE__ */ new Map();
|
|
42878
42878
|
this.outlines = /* @__PURE__ */ new Map();
|
|
42879
42879
|
this.glyphs = /* @__PURE__ */ new Map();
|
|
42880
|
+
/**
|
|
42881
|
+
* The font was asked for at NONANTIALIASED_QUALITY (GDI+ SingleBitPerPixelGridFit), not turned monochrome by
|
|
42882
|
+
* the `gasp` table under AntiAliasGridFit: those glyphs keep the previous path (the native grayscale corpora,
|
|
42883
|
+
* `gdiplus-courier-gray` and `gdiplus-shpix-x`, lose exact glyphs the GDI way).
|
|
42884
|
+
*/
|
|
42885
|
+
this.singleBitRequested = false;
|
|
42880
42886
|
this.reverseCmap = null;
|
|
42887
|
+
this.gdiMonoSize = null;
|
|
42888
|
+
this.gdiMonoOutlines = /* @__PURE__ */ new Map();
|
|
42881
42889
|
this.ctSize = null;
|
|
42882
42890
|
/** CLEARTYPE_NATURAL_QUALITY: ClearType glyphs keep their own (natural) widths. */
|
|
42883
42891
|
this.naturalWidths = false;
|
|
@@ -42937,6 +42945,17 @@ var RealizedFont = class {
|
|
|
42937
42945
|
* way, at a half turn it rounded (all 530 ascents and descents of five faces at lfHeight -8..-60 for 90, 180 and
|
|
42938
42946
|
* 270 degrees, escapement and world rotation alike). Undefined for an upright baseline.
|
|
42939
42947
|
*/
|
|
42948
|
+
/**
|
|
42949
|
+
* GDI+ SingleBitPerPixelGridFit glyphs are close to GDI's monochrome glyphs: hinted with GDI's arithmetic and
|
|
42950
|
+
* scan-converted with GDI's converter, 1,658 of 1,680 native upright regular glyphs are exact (`xwvyAkMWKVXZ4&%`,
|
|
42951
|
+
* Arial, Tahoma, Times New Roman and Segoe UI at 9 to 36 px), against 1,442 with the previous arithmetic. GDI+'s
|
|
42952
|
+
* own arithmetic is neither: 15 glyphs (Arial 16 `w` among them) are exact only the old way, and no subset of
|
|
42953
|
+
* GDI's projection, movement and ISECT rules gets both. Italic faces keep the previous path (Times New Roman
|
|
42954
|
+
* Italic 22 in `textx-plus-singlebitgridfit`: 8 pixels the GDI way).
|
|
42955
|
+
*/
|
|
42956
|
+
plusMonoAsGdi(gdiPlus, mode, gridFit) {
|
|
42957
|
+
return gdiPlus && mode === "mono" && gridFit && this.singleBitRequested;
|
|
42958
|
+
}
|
|
42940
42959
|
rotatedMetrics(ux, uy) {
|
|
42941
42960
|
if (Math.abs(ux) > 1e-9 && Math.abs(uy) > 1e-9) {
|
|
42942
42961
|
return { ascent: this.rotatedAscent, descent: this.rotatedDescent };
|
|
@@ -42971,6 +42990,20 @@ var RealizedFont = class {
|
|
|
42971
42990
|
}
|
|
42972
42991
|
return this.reverseCmap.get(index) ?? 65533;
|
|
42973
42992
|
}
|
|
42993
|
+
/**
|
|
42994
|
+
* The outline of an upright GDI+ SingleBitPerPixelGridFit glyph, hinted
|
|
42995
|
+
* with GDI's arithmetic (see {@link plusMonoAsGdi}). Advances keep coming
|
|
42996
|
+
* from {@link outline}, whose placement the DrawString fixtures pin.
|
|
42997
|
+
*/
|
|
42998
|
+
gdiMonoOutline(index) {
|
|
42999
|
+
let g = this.gdiMonoOutlines.get(index);
|
|
43000
|
+
if (!g) {
|
|
43001
|
+
this.gdiMonoSize ?? (this.gdiMonoSize = new HintedSize(this.ttf, this.ppemX, this.ppem, { version: 35, grayscale: false, gdiArithmetic: true, reportStretched: this.playbackStretched }, true));
|
|
43002
|
+
g = this.gdiMonoSize.hintGlyph(index < this.ttf.numGlyphs ? index : NOTDEF);
|
|
43003
|
+
this.gdiMonoOutlines.set(index, g);
|
|
43004
|
+
}
|
|
43005
|
+
return g;
|
|
43006
|
+
}
|
|
42974
43007
|
outline(index) {
|
|
42975
43008
|
let g = this.outlines.get(index);
|
|
42976
43009
|
if (!g) {
|
|
@@ -43117,7 +43150,8 @@ var RealizedFont = class {
|
|
|
43117
43150
|
}
|
|
43118
43151
|
const skew = m && !(Math.abs(m[1]) < 1e-9 && Math.abs(m[2]) < 1e-9) && !(Math.abs(m[0]) < 1e-9 && Math.abs(m[3]) < 1e-9);
|
|
43119
43152
|
const rotation = skew && m && !this.gdiPlus && this.ppemX === this.ppem ? rotationMatrix(m, this.ppem, (this.ttf.headFlags & 8) !== 0) : null;
|
|
43120
|
-
const
|
|
43153
|
+
const asGdiMono = !m && !subX && !subY && this.ppemX === this.ppem && !this.syntheticItalic && !(this.ttf.fsSelection & 1) && this.plusMonoAsGdi(this.gdiPlus, this.mode, this.gridFit);
|
|
43154
|
+
const src = skew ? this.rotatedOutline(index, rotation ? rotation.ppem : 0) : asGdiMono ? this.gdiMonoOutline(index) : this.outline(index);
|
|
43121
43155
|
if (skew && m && rotation) {
|
|
43122
43156
|
m = rotation.matrix;
|
|
43123
43157
|
} else if (skew && m) {
|
|
@@ -43160,7 +43194,7 @@ var RealizedFont = class {
|
|
|
43160
43194
|
if (this.mode === "mono") {
|
|
43161
43195
|
const smartGrid = !m && !subX && !subY && (!this.gdiPlus || this.ppemX === this.ppem && !this.syntheticItalic);
|
|
43162
43196
|
const controlOn = src.scanSet ? src.scanControl : this.ppem <= DEFAULT_DROPOUT_PPEM;
|
|
43163
|
-
bitmap = this.gdiPlus ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43197
|
+
bitmap = this.gdiPlus && !asGdiMono ? rasterizeMono(o, this.gdiPlus && !this.gridFit ? UNHINTED_MONO_DROPOUT : dropoutMode(controlOn, src.scanType), void 0, true, smartGrid, false, false, false, false, true) : msMonoBitmap(o, msScanFlags(controlOn, src.scanType));
|
|
43164
43198
|
} else if (this.mode === "cleartype") {
|
|
43165
43199
|
const dropout = src.scanSet ? dropoutMode(src.scanControl, src.scanType) : !this.gdiPlus ? 0 : 2;
|
|
43166
43200
|
bitmap = rasterizeClearType(o, this.gdiPlus, this.gdiPlus ? clearTypeSpread(this.ttf) : void 0, dropout, !this.gdiPlus && clearTypeSmoothsVertically(this.ttf, this.ppem));
|
|
@@ -43415,6 +43449,7 @@ var GdiFontCollection = class _GdiFontCollection {
|
|
|
43415
43449
|
this.installedFonts
|
|
43416
43450
|
);
|
|
43417
43451
|
tt2.naturalWidths = spec.quality === CLEARTYPE_NATURAL_QUALITY;
|
|
43452
|
+
tt2.singleBitRequested = spec.quality === NONANTIALIASED_QUALITY;
|
|
43418
43453
|
return tt2;
|
|
43419
43454
|
};
|
|
43420
43455
|
let tt = make(resolvePpem(best, spec.height), spec.height > 0 ? Math.round(spec.height) : 0);
|
|
@@ -54868,10 +54903,16 @@ function worldUnitFont(rCtx, obj) {
|
|
|
54868
54903
|
const em = obj.emSize * getPageUnitMultiplier(unit, 1, dpi) / (page || 1);
|
|
54869
54904
|
return Number.isFinite(em) && em > 0 ? { ...obj, emSize: em, unit: 0 } : obj;
|
|
54870
54905
|
}
|
|
54906
|
+
function resolvePlusTextHint(hint, smoothing) {
|
|
54907
|
+
if (hint !== 0) {
|
|
54908
|
+
return hint;
|
|
54909
|
+
}
|
|
54910
|
+
return smoothing === "mono" ? 1 : smoothing === "gray" ? 3 : 5;
|
|
54911
|
+
}
|
|
54871
54912
|
function realizePlusEngineFont(rCtx, font, paint, brushSampler2) {
|
|
54872
54913
|
const fonts = rCtx.fonts;
|
|
54873
54914
|
const color = typeof paint === "string" ? rgbaToHex(paint) : null;
|
|
54874
|
-
const hint = rCtx.textRenderingHint ?? 0;
|
|
54915
|
+
const hint = resolvePlusTextHint(rCtx.textRenderingHint ?? 0, fonts?.defaultSmoothing);
|
|
54875
54916
|
const graySmooth = hint === 3 || hint === 4 || hint === 5;
|
|
54876
54917
|
const solidViaCoverage = !!color && graySmooth && !isSvgContext(rCtx.ctx);
|
|
54877
54918
|
const sampler = isSvgContext(rCtx.ctx) ? null : solidViaCoverage ? solidSampler(cssColorToArgb(paint) ?? 4278190080) : color ? null : brushSampler2;
|