Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
credit FreeType for the hinting interpreter
Where the TrueType spec leaves details open, the interpreter follows
FreeType's ttinterp.c (rounding, original distances, IUP, movement along
near-perpendicular vectors, tolerance of invalid references). The FreeType
License asks for the credit line in the documentation: it is in the source
header, THIRD_PARTY_NOTICES.md and the README, and the license text ships
as licenses/FTL.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ljnxm1Qjrocq1izGajLx8J
  • Loading branch information
matmen and claude committed Oct 15, 2026
commit 9b07e0a103863a739c806fe57745abaaf2762c59
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
- Text rendering: glyph outlines touching the left edge of their bitmap could come out inverted (a rasterizer
rounding issue); hinting made it common


## 3.0.0

ImageScript is now written in TypeScript and has no WebAssembly or native binaries anymore. Every codec and renderer
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ The deflate/inflate implementation is derived from [fflate](https://github.com/1
The JPEG codec is based in part on the work of the Independent JPEG Group (libjpeg) and on
[pdf.js](https://github.com/mozilla/pdf.js), the glyph rasterizer is translated from
[font-rs](https://github.com/raphlinus/font-rs). The WebP codecs follow [RFC 9649](https://www.rfc-editor.org/rfc/rfc9649) and [RFC 6386](https://www.rfc-editor.org/rfc/rfc6386)
and reproduces [libwebp](https://chromium.googlesource.com/webm/libwebp)'s color conversion. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for their licenses.
and reproduce [libwebp](https://chromium.googlesource.com/webm/libwebp)'s color conversion, the TrueType hinting follows
[FreeType](https://freetype.org)'s interpreter (portions of this software are copyright © 2026 The FreeType Project).
See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for their licenses.

---

Expand Down
12 changes: 12 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ following projects, under their own licenses. Each derived file says so in its h
| [RFC 9649](https://www.rfc-editor.org/rfc/rfc9649) (WebP Image Format) | `src/codecs/vp8l.ts` (lossless bitstream, short distance code table), `src/codecs/webp.ts` (container) | BSD-3-Clause (Revised BSD) |
| [RFC 6386](https://www.rfc-editor.org/rfc/rfc6386) (VP8 Data Format and Decoding Guide, with the libvpx reference decoder) | `src/codecs/vp8-tables.ts` (probability and quantizer tables), `src/codecs/vp8.ts` (decoding procedures) | BSD-3-Clause |
| [libwebp](https://chromium.googlesource.com/webm/libwebp) | `src/codecs/vp8.ts` (YUV to RGB conversion, "fancy" chroma upsampling), `src/codecs/webp.ts` (animation frame blending) | BSD-3-Clause |
| [FreeType](https://freetype.org) | `src/render/hinting.ts` (behavior and parts of the logic of the TrueType interpreter) | FreeType License |

## fflate, Fast CRC32 in JavaScript

Expand Down Expand Up @@ -142,3 +143,14 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSE
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

## FreeType

Portions of this software are copyright © 2026 The FreeType Project (https://freetype.org). All rights reserved.

The TrueType hinting interpreter in `src/render/hinting.ts` is written after the TrueType instruction specification.
Where the specification leaves details open, its behavior and parts of its logic follow FreeType's interpreter
(`src/truetype/ttinterp.c`): the fixed point rounding, measuring original distances on the unscaled outline, the
interpolation of untouched points (IUP), the handling of near-perpendicular freedom and projection vectors, and the
tolerance of invalid references. FreeType is used under the FreeType License, included as
[licenses/FTL.txt](licenses/FTL.txt).
169 changes: 169 additions & 0 deletions licenses/FTL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
The FreeType Project LICENSE
----------------------------

2006-Jan-27

Copyright 1996-2002, 2006 by
David Turner, Robert Wilhelm, and Werner Lemberg



Introduction
============

The FreeType Project is distributed in several archive packages;
some of them may contain, in addition to the FreeType font engine,
various tools and contributions which rely on, or relate to, the
FreeType Project.

This license applies to all files found in such packages, and
which do not fall under their own explicit license. The license
affects thus the FreeType font engine, the test programs,
documentation and makefiles, at the very least.

This license was inspired by the BSD, Artistic, and IJG
(Independent JPEG Group) licenses, which all encourage inclusion
and use of free software in commercial and freeware products
alike. As a consequence, its main points are that:

o We don't promise that this software works. However, we will be
interested in any kind of bug reports. (`as is' distribution)

o You can use this software for whatever you want, in parts or
full form, without having to pay us. (`royalty-free' usage)

o You may not pretend that you wrote this software. If you use
it, or only parts of it, in a program, you must acknowledge
somewhere in your documentation that you have used the
FreeType code. (`credits')

We specifically permit and encourage the inclusion of this
software, with or without modifications, in commercial products.
We disclaim all warranties covering The FreeType Project and
assume no liability related to The FreeType Project.


Finally, many people asked us for a preferred form for a
credit/disclaimer to use in compliance with this license. We thus
encourage you to use the following text:

"""
Portions of this software are copyright © <year> The FreeType
Project (https://freetype.org). All rights reserved.
"""

Please replace <year> with the value from the FreeType version you
actually use.


Legal Terms
===========

0. Definitions
--------------

Throughout this license, the terms `package', `FreeType Project',
and `FreeType archive' refer to the set of files originally
distributed by the authors (David Turner, Robert Wilhelm, and
Werner Lemberg) as the `FreeType Project', be they named as alpha,
beta or final release.

`You' refers to the licensee, or person using the project, where
`using' is a generic term including compiling the project's source
code as well as linking it to form a `program' or `executable'.
This program is referred to as `a program using the FreeType
engine'.

This license applies to all files distributed in the original
FreeType Project, including all source code, binaries and
documentation, unless otherwise stated in the file in its
original, unmodified form as distributed in the original archive.
If you are unsure whether or not a particular file is covered by
this license, you must contact us to verify this.

The FreeType Project is copyright (C) 1996-2000 by David Turner,
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
specified below.

1. No Warranty
--------------

THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
USE, OF THE FREETYPE PROJECT.

2. Redistribution
-----------------

This license grants a worldwide, royalty-free, perpetual and
irrevocable right and license to use, execute, perform, compile,
display, copy, create derivative works of, distribute and
sublicense the FreeType Project (in both source and object code
forms) and derivative works thereof for any purpose; and to
authorize others to exercise some or all of the rights granted
herein, subject to the following conditions:

o Redistribution of source code must retain this license file
(`FTL.TXT') unaltered; any additions, deletions or changes to
the original files must be clearly indicated in accompanying
documentation. The copyright notices of the unaltered,
original files must be preserved in all copies of source
files.

o Redistribution in binary form must provide a disclaimer that
states that the software is based in part of the work of the
FreeType Team, in the distribution documentation. We also
encourage you to put an URL to the FreeType web page in your
documentation, though this isn't mandatory.

These conditions apply to any software derived from or based on
the FreeType Project, not just the unmodified files. If you use
our work, you must acknowledge us. However, no fee need be paid
to us.

3. Advertising
--------------

Neither the FreeType authors and contributors nor you shall use
the name of the other for commercial, advertising, or promotional
purposes without specific prior written permission.

We suggest, but do not require, that you use one or more of the
following phrases to refer to this software in your documentation
or advertising materials: `FreeType Project', `FreeType Engine',
`FreeType library', or `FreeType Distribution'.

As you have not signed this license, you are not required to
accept it. However, as the FreeType Project is copyrighted
material, only this license, or another one contracted with the
authors, grants you the right to use, distribute, and modify it.
Therefore, by using, distributing, or modifying the FreeType
Project, you indicate that you understand and accept all the terms
of this license.

4. Contacts
-----------

There are two mailing lists related to FreeType:

o freetype@nongnu.org

Discusses general use and applications of FreeType, as well as
future and wanted additions to the library and distribution.
If you are looking for support, start in this list if you
haven't found anything to help you in the documentation.

o freetype-devel@nongnu.org

Discusses bugs, as well as engine internals, design issues,
specific licenses, porting, etc.

Our home page can be found at

https://freetype.org


--- end of FTL.TXT ---
12 changes: 9 additions & 3 deletions src/render/hinting.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/*!
* TrueType hinting interpreter. Where the TrueType specification leaves details open, its behavior and parts of its
* logic follow FreeType's TrueType interpreter (src/truetype/ttinterp.c): fixed point rounding, original distances
* on the unscaled outline (IP, IUP, MDRP, MD), the IUP interpolation, the movement along near-perpendicular vectors
* and the tolerance of invalid references. Portions of this software are copyright © 2026 The FreeType Project
* (https://freetype.org). All rights reserved. FreeType License, see THIRD_PARTY_NOTICES.md and licenses/FTL.txt
*/
// TrueType hinting: an interpreter for the glyph programs (instructions) of TrueType fonts, following the TrueType
// instruction set specification (Apple TrueType Reference Manual, Microsoft OpenType "TrueType instructions").
// Hinting moves outline points so that stems and edges land on pixel boundaries at small sizes.
// Coordinates are 26.6 fixed point numbers (64 = one pixel), kept as JS numbers. Where the specification leaves
// details open (rounding of fixed point math, tolerance of invalid references, near-perpendicular vectors), this
// behaves like FreeType's classic ("v35") interpreter, which the tests compare against point for point.
// Coordinates are 26.6 fixed point numbers (64 = one pixel), kept as JS numbers. The tests compare the results with
// FreeType's classic ("v35") interpreter point for point.
import { Font, GlyfPoints, PathCommand, contourToPath } from './font.ts';

class HintError extends Error { }
Expand Down
Loading