diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..72211e1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,34 @@ +# Changelog + +## 1.3.1 + +- Fix: removed an outdated baseline/y-offset correction in `adjustFont.ts` that was misaligning generated fonts (affects fonts generated with v1.2.0 through v1.3.0). + +## 1.3.0 + +- Multipage atlas generation fix +- Added `textureSize` override + +## 1.2.1 + +- Pinned `opentype.js` to `1.3.4` to fix a `loadSync` issue in newer versions + +## 1.2.0 + +- Updated `msdf-bmfont-xml` to `^2.8.0` + +## 1.1.1 + +- Made `presets` key optional in `.config.json` + +## 1.1.0 + +- Charset configuration with presets support + +## 1.0.2 + +- Fixed header image URL in README for the npm page + +## 1.0.0 + +- Initial npm publish, library exports added diff --git a/package.json b/package.json index 9e18223..7ec79a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lightningjs/msdf-generator", - "version": "1.3.0", + "version": "1.3.1", "description": "Converts font files (.ttf, .otf, .woff, .woff2) to SDF format for Lightning 3's renderer, with added font metrics generation for SDF and Canvas Web fonts", "type": "module", "exports": { diff --git a/src/adjustFont.ts b/src/adjustFont.ts index 04a4776..d01c22e 100644 --- a/src/adjustFont.ts +++ b/src/adjustFont.ts @@ -24,15 +24,8 @@ import type { SdfFontInfo } from "./genFont.js"; const metricsSubDir = 'metrics'; /** - * Adjusts the font data for the generated fonts. - * - * @remarks - * A bug in the msdf-bmfont-xml package causes both the baseline and y-offsets - * of every character to be incorrect which results in the text being rendered - * out of intended alignment. This function corrects that data. - * - * See the following GitHub issue for more information: - * https://github.com/soimy/msdf-bmfont-xml/pull/93 + * Extracts font metrics from the source font and writes them into the + * generated JSON and a separate metrics file. * * @param fontInfo */ @@ -46,21 +39,6 @@ export async function adjustFont(fontInfo: SdfFontInfo) { opentype.load(fontInfo.fontPath), ]); const json = JSON.parse(jsonFileContents); - const distanceField = json.distanceField.distanceRange; - /** - * `pad` used by msdf-bmfont-xml - * - * (This is really just distanceField / 2 but guarantees a truncated integer result) - */ - const pad = (distanceField >> 1); - - // Remove 1x pad from the baseline - json.common.base = json.common.base - pad; - - // Remove 2x pad from the y-offset of every character - for (const char of json.chars) { - char.yoffset = char.yoffset - pad - pad; - } const fontMetrics = { ascender: font.tables.os2!.sTypoAscender as number,