emf-converter 4.17.0 → 4.18.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 CHANGED
@@ -72,7 +72,7 @@ const svgUrl = await convertMetafileToSvgDataUrl(buffer);
72
72
  // => "data:image/svg+xml;base64,PHN2ZyB4bWxucz0i..." (drop straight into <img src>)
73
73
  ```
74
74
 
75
- Paths, text, gradients, clipping and pattern brushes stay vectors; bitmaps are embedded as `<image>` elements (PNG/JPEG/GIF/WebP bytes verbatim, never re-encoded). Raster operations that read the destination (all 256 ROP3 codes, bitwise ROP2, pattern brushes through ROP2) are evaluated exactly against a hidden raster mirror and embedded as image patches holding only the pixels they change, so the SVG is the same with or without a canvas backend.
75
+ Paths, text, gradients, clipping and pattern brushes stay vectors; bitmaps are embedded as `<image>` elements (PNG/JPEG/GIF/WebP bytes verbatim, never re-encoded; arithmetic-coded and CMYK/YCCK JPEG are decoded by the bundled Windows-matching decoder and embedded as pixels, and a 12-bit JPEG draws nothing, as in Windows). Raster operations that read the destination (all 256 ROP3 codes, bitwise ROP2, pattern brushes through ROP2) are evaluated exactly against a hidden raster mirror and embedded as image patches holding only the pixels they change, so the SVG is the same with or without a canvas backend.
76
76
 
77
77
  ### Rendering in React (JSX / TSX)
78
78
 
@@ -127,8 +127,8 @@ const png = await convertMetafileToDataUrl(buffer, { fonts });
127
127
  - Fonts are realised the way GDI's font mapper does it (face substitutes, pitch/family fallback, weight choice, cell vs em height, `lfWidth` stretching), with GDI's metrics, advances, underline and strike-out.
128
128
  - Glyphs are grid-fitted by the font's own TrueType instructions (including Windows' ClearType rules), scan-converted with dropout control, and placed on GDI's integer grid honouring Dx arrays, `ETO_*` flags and every `TA_*` alignment.
129
129
  - Non-antialiased, grayscale or ClearType rendering is chosen from the font's quality; `fontSmoothing` sets what `DEFAULT_QUALITY` means (Windows' default is ClearType).
130
- - Raster faces (MS Sans Serif, MS Serif, Courier, Small Fonts, System, Terminal, Fixedsys, Helv, Tms Rmn) are drawn from their bitmaps with GDI's size choice and stretching.
131
- - Rotated text uses GDI's rounded font matrix; EMF+ `DrawString` honours the text rendering hint, string-format tracking and margins, and texture/gradient brushes.
130
+ - Raster faces (MS Sans Serif, MS Serif, Courier, Small Fonts, System, Terminal, Fixedsys, Helv, Tms Rmn) are drawn from their bitmaps with GDI's size choice and stretching (up to 8 vertically, 5 horizontally). The size depends on the faces supplied: pass `8514sys.fon` and `8514fix.fon` along with `vgasys.fon` and `vgafix.fon` to get the System and Fixedsys sizes a 120 dpi or larger session draws.
131
+ - Rotated text uses GDI's rounded font matrix. Text from a compatible-mode metafile replays the recorded Dx array but not the slight horizontal stretch (about 1.0006) Windows playback applies, which re-grid-fits a few Segoe UI heights. EMF+ `DrawString` honours the text rendering hint, string-format tracking and margins, and texture/gradient brushes.
132
132
 
133
133
  Without `fonts`, text is drawn by the host's canvas font engine (supply `fontFamilyMap` to remap Windows face names). SVG output always keeps text as `<text>`; with `fonts` it carries GDI's exact per-glyph positions.
134
134
 
@@ -189,7 +189,7 @@ See [How it works](docs/how-it-works.md) for the pipeline, the Windows-parity de
189
189
 
190
190
  ## Limitations
191
191
 
192
- Everything is measured against output painted by Windows itself, and a few areas still differ from it: some image effects, text with ClearType and EMF+ antialiasing, nonuniform wide-pen nibs, and rotated bicubic `DrawImage` sampling. Metric WMF map modes assume a 96 dpi device unless you pass `wmfReferenceDpi`.
192
+ Everything is measured against output painted by Windows itself, and a few areas still differ from it: some image effects, text with ClearType and EMF+ antialiasing, diagonal and curved glyph hinting, the last 0.26% of CMYK JPEG values, and rotated high-quality `DrawImage` sampling (within one level). Metric WMF map modes assume a 96 dpi device unless you pass `wmfReferenceDpi`.
193
193
 
194
194
  See [Limitations](docs/limitations.md) for the details and [Outstanding work](docs/outstanding-work.md) for what is still open.
195
195
 
@@ -131,12 +131,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131
131
  THE SOFTWARE.
132
132
 
133
133
 
134
- ===== Independent JPEG Group software (src/jpeg-arith.ts) =====
134
+ ===== Independent JPEG Group software (src/jpeg-arith.ts, src/jpeg-turbo.ts) =====
135
135
 
136
136
  src/jpeg-arith.ts decodes arithmetic-coded JPEG and is a port of the entropy
137
137
  decoder in libjpeg's jdarith.c and the probability table in jaricom.c. This
138
138
  software is based in part on the work of the Independent JPEG Group.
139
139
 
140
+ src/jpeg-turbo.ts, the decoder that runs around it, reproduces libjpeg's output
141
+ bit for bit and follows its algorithms: the accurate integer inverse DCT of
142
+ jidctint.c (its fixed-point constants, passes and descaling), the Huffman table
143
+ layout and decoding of jdhuff.c (mincode, maxcode and valptr), the triangle
144
+ ("fancy") chroma upsampling of jdsample.c with its rounding terms and the
145
+ fixed-point YCbCr to RGB conversion of jdcolor.c, which src/jpeg-cmyk.ts also
146
+ uses for YCCK. It is covered by the same license.
147
+
140
148
  scripts/gdi-fixtures/arith-jpeg-encoder.ts, a test tool that is not part of the
141
149
  published package, is a port of the arithmetic encoder in libjpeg's jcarith.c
142
150
  and is covered by the same license.
@@ -144,14 +152,14 @@ and is covered by the same license.
144
152
  The following is the IJG license under which libjpeg (as distributed in
145
153
  libjpeg-turbo's README.ijg) is provided:
146
154
 
147
- This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
148
- All Rights Reserved except as specified below.
149
-
150
155
  The authors make NO WARRANTY or representation, either express or implied,
151
156
  with respect to this software, its quality, accuracy, merchantability, or
152
157
  fitness for a particular purpose. This software is provided "AS IS", and you,
153
158
  its user, assume the entire risk as to its quality and accuracy.
154
159
 
160
+ This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
161
+ All Rights Reserved except as specified below.
162
+
155
163
  Permission is hereby granted to use, copy, modify, and distribute this
156
164
  software (or portions thereof) for any purpose, without fee, subject to these
157
165
  conditions:
@@ -223,3 +231,22 @@ Consortium, and may be copied, distributed, embedded, made, used, and sold
223
231
  without restriction. Altered versions of this profile shall have the original
224
232
  identification and copyright information removed and shall not be
225
233
  misrepresented as the original profile.
234
+
235
+
236
+ ===== Measured Windows data and cited references (no third-party code) =====
237
+
238
+ src/jpeg-cmyk-data.ts, src/emf-gdi-illuminant-data.ts, src/emf-plus-image-curves.ts,
239
+ src/emf-plus-hq-cubic-weights.ts and src/emf-ansi-tables.ts are tables measured by
240
+ running Windows (the ICM colour-management module, GDI halftone and colour
241
+ adjustment, GDI+, the Windows code pages) on test inputs; the capture and
242
+ generator scripts are under scripts/gdi-fixtures and each file's header names its
243
+ origin. They are measurements of program output, not copies of Microsoft source
244
+ code or data files: the RSWOP.icm profile, mscms.dll and the Windows fonts are not
245
+ bundled, and are read from the host only when the fixtures are regenerated or
246
+ compared. The diagnostic TrueType fonts under src/__fixtures__/gdi are built by
247
+ scripts/gdi-fixtures/build-*-fonts.py (fontTools, a build-time tool that is not
248
+ bundled) from hand-written four-point glyphs and contain no third-party glyph
249
+ data.
250
+
251
+ Comments in the source cite the Wine project's gdi32 tests (gdi32/tests/path.c)
252
+ as evidence of GDI's behaviour. No Wine code or data is copied.