# Changelog

All notable changes to this project will be documented in this file.

## [0.4.0] - 2026-07-24

### Added

- Super/subscript text runs now import with Photoshop's size reduction, preserving per-character typography such as the smaller "$" and cents in a price. The factor is read from the document's authored "Superscript Size" / "Subscript Size" type preference stored in the PSD, falling back to Photoshop's default (58.3%) when absent. The baseline raise is not reproduced — CE.SDK has no per-range baseline shift, so raised runs sit on the main baseline at reduced size.
- Opt-in raster layer-mask baking via `flags: { bakeLayerMasks: true }`: bakes a layer's raster mask (including density, inversion, and canvas-relative offsets) into the alpha channel of the imported pixels. Off by default because baking is destructive — CE.SDK has no editable layer-mask equivalent. A baked mask with a declared feather radius emits the new `LAYER_MASK_FEATHER_IGNORED` info diagnostic.
- Parser `flags` now merge with the defaults, so a single flag can be passed without restating the rest.
- The public option types are now exported: `Flags`, `Options`, `TypefaceParams`, `TypefaceResolver`, `FontResolverOptions`, and `FontResolverResult`.

### Changed

- Point text imports with an auto-sizing frame, matching Photoshop's model where the layer bounds are an output of the glyphs rather than a wrap boundary. No authored value is modified to make text fit: font size, letter spacing, and leading all render verbatim, and wrapping that Photoshop never showed cannot occur. The block stays anchored to the authored bounds according to its paragraph alignment. With a substituted font the text now runs long or short instead of being squeezed; supplying the original fonts restores the exact layout. Rotated point text keeps an absolute frame with proportional font-size fitting (shrink only, letter spacing untouched), replacing the previous letter-spacing binary search; the `TEXT_FIT_INEXACT` "spacing was reset" warning is gone.
- Text font size is now derived from the vertical scale of the PSD text transform (previously the average of the horizontal and vertical scales), matching Photoshop's rendered glyph height exactly. Horizontally stretched or compressed text imports at its authored height and renders at natural glyph width — CE.SDK has no glyph stretching.
- Line height (leading) now follows Photoshop's auto-leading semantics: a style run without an explicit `AutoLeading` inherits it from the document's default stylesheet (`TheNormalStyleSheet`), so stale `Leading` values under auto leading are ignored, while a deliberately authored leading (`AutoLeading: false`) is imported as-is, however small. The previous behavior reset any leading below 0.6 to the 1.2 default (`TEXT_LINE_HEIGHT_TOO_SMALL` is no longer emitted).
- Point text is vertically placed by aligning the engine's first-line ink top with the PSD's recorded ink bounds, matching Photoshop's baseline-anchored rendering; the previous metric-based correction remains as fallback.
- `LAYER_MASK_REMOVED` now only fires for genuine, enabled raster masks (previously it also fired for disabled masks and vector-derived mask records).

### Removed

- The `TEXT_FIT_INEXACT` and `TEXT_LINE_HEIGHT_TOO_SMALL` warning codes are removed from the registry — the behaviors that emitted them are gone (letter spacing is never reset; authored line height is preserved).

### Fixed

- Text containing `{{…}}` spans no longer traps the engine during import (text fitting now runs before text variables are re-enabled).
- A raster mask that fails to decode with `bakeLayerMasks` enabled now emits `LAYER_MASK_FAILED` instead of being dropped silently.

## [0.3.0] - 2026-06-11

### Added

- Import Photoshop Layer Style → Stroke effects (`lfx2` / `FrFX` solid-color strokes) onto CE.SDK text and graphic blocks: color, width, position (Inside/Center/Outside), opacity (baked into color alpha), and Round corner geometry to match Photoshop's rasterized-outline rendering. Gradient, pattern, and non-Normal blend-mode strokes remain unsupported and now emit a stable `LAYER_EFFECT_STROKE_*` diagnostic carrying the source value (gradient/pattern type, blend-mode name). (#15518)
- Dual ESM + CommonJS build: the package now ships both `dist/index.js` (ESM) and `dist/index.cjs` (CJS) with matching type declarations, so it can be consumed via both `import` and `require`.

### Changed

- The generic `LAYER_EFFECTS_REMOVED` warning for unsupported layer styles is replaced by `LAYER_EFFECT_KIND_UNSUPPORTED`, which names the specific effect kind (Drop Shadow, Bevel & Emboss, Pattern Overlay, etc.). (#15518)
- Node.js ≥ 22 is now required.

### Fixed

- Off-canvas text layers now fall back to the layer's native `left/top/width/height` frame when the `TySh`-affine-derived position would place the text bounding box more than one page size outside the canvas. This fixes text that was parsed correctly but rendered invisible off-page (e.g. a `TX`/`TY` translation of `-6692` placing text at ~(-4250, -4200) on a 3000×3000 page). The fallback is gated by the off-canvas threshold, so it cannot move text that was already positioned correctly. (#15575)

## [0.2.1] - 2026-04-17

### Fixed

- **BREAKING**: Corrected the declared minimum `@cesdk/engine` / `@cesdk/node` peer dependency to **1.72.0** (0.2.0 incorrectly declared `^1.70.0`). The 0.2.0 release added text decoration import via `engine.block.setTextDecoration`, which was introduced in CE.SDK 1.72.0, so 0.2.0 does not run on 1.70.x or 1.71.x in practice. If you are already on CE.SDK ≥ 1.72.0 this is a no-op; if you were still on 1.70.x or 1.71.x with 0.2.0 installed, upgrade your CE.SDK to 1.72.0+ before upgrading to 0.2.1.

## [0.2.0] - 2026-04-16

### Changed

- **BREAKING**: Minimum required `@cesdk/engine` / `@cesdk/node` version is now **1.70.0** (previously 1.38.0). Update your CE.SDK dependency before upgrading this package.
- **BREAKING**: Renamed exported helper `addGoogleFontsAssetLibrary` → `addGfontsAssetLibrary`. Update your imports and call sites. The new helper registers two CDN-hosted asset sources — `ly.img.gfonts` (1,394 Google Fonts) and `ly.img.gfonts-fallbacks` (16 proprietary-font aliases like Helvetica→Roboto) — from the new shared `@imgly/gfonts` package. The package no longer ships `assets/google-fonts/`. Customers who referenced the previous `ly.img.google-fonts` asset source ID directly (e.g. via `engine.asset.findAssets` or `addAssetToSource`) must also update to `ly.img.gfonts`. The `TypefaceResolver` extension point is unchanged.
- Replaced `opentype.js` and `woff2-encoder` dependencies with the built-in `engine.editor.getFontMetrics()` API for font metrics extraction. This reduces bundle size and eliminates redundant font fetching. No rendering changes.
- Font-resolver logic simplified from ~200 lines to ~80 lines. The hardcoded `TYPEFACE_ALIAS_MAP`, `fetchGoogleFonts`, and `buildAssetPath` helpers have been removed.
- Warning messages rewritten per the new `WARNING_GUIDELINES.md`: font-related, layer-feature, structural, text, and color warnings now use consistent wording and severity levels.

### Added

- Text decorations (underline, strikethrough) are now applied from PSD style runs.
- Explicit font weight and style are now applied per text run (previously only the first run's weight/style was honored).
- Per-run font sizes are now applied for text blocks with mixed font sizes within a single text run.

### Fixed

- Proprietary-font fallback lookups now use strict case-insensitive id/label matching against the fallbacks asset source. Previously, fuzzy matching on the 16-entry fallback source could silently alias unrelated fonts (notably CJK fonts like "Hiragino Kaku Gothic Pro") to arbitrary substitutes, causing render drift.

## [0.1.1] - 2025-01-16

### Fixed

- Don't apply rotation to layers with skew/shear transforms. Previously, layers with skew transforms would have incorrect rotation applied. Now the importer detects skew transforms and logs a warning instead of applying incorrect rotation.
- Add guard against division by zero when processing degenerate transform matrices.
- Fix warning message to be layer-type agnostic (applies to text, image, and graphic blocks).

## [0.1.0] - 2025-01-10

### Added

- Use buffer URLs instead of blob URLs for transient resources.
- WOFF2 font support.

### Fixed

- Handle capacity overflow errors when processing large layer masks.
