Skip to content

Comments

Type six, format two#155

Open
RoelN wants to merge 5 commits intomainfrom
sixtwo
Open

Type six, format two#155
RoelN wants to merge 5 commits intomainfrom
sixtwo

Conversation

@RoelN
Copy link
Collaborator

@RoelN RoelN commented Feb 17, 2026

An attempt to kickstart type 6, format 2 parsing by looking at what's missing and peeking from existing code on how to solve this :P

Currently simply attempting to get the info we see in the TTX dump here: #153 (comment)

Code to test Bangers with this PR (so far), our test font with confirmed 6.2 lookup. EDIT: or use the gsub.test.js test!

import fs from "node:fs";
import { Font } from "./lib-font.js";

const font = new Font("Bangers");
const fontBuffer = await fs.promises.readFile("./fonts/Bangers-Regular.ttf");
font.fromDataBuffer(Uint8Array.from(fontBuffer).buffer, "Bangers-Regular.ttf");

font.onload = () => {
  const { GSUB, post } = font.opentype.tables;

  // Get Bangers' 6.2 lookup
  const lookup = GSUB.getLookup(3);
  const subtable = lookup.getSubTable(0);

  // Get defenition, use `getInputClassDef`, `getLookaheadClassDef` or `getLookaheadClassDef`
  const inputClassDef = subtable.getInputClassDef();

  // Show what chars we got
  for (const record of inputClassDef.classRangeRecords) {
    for (let gid = record.startGlyphID; gid <= record.endGlyphID; gid++) {
      const char = post.getGlyphName(gid);
      console.log(char);
    }
  }
};

So we actually enforce a style!
This was deceivingly simple... is this really all there is to it?!
(Basically transplanting the test file used during dev!)
@RoelN RoelN requested a review from Pomax February 17, 2026 16:25
@RoelN
Copy link
Collaborator Author

RoelN commented Feb 17, 2026

@Pomax This was basically copied of off existing code, to get to the Bangers chars as detailed in #153 I would love a pair of extra eyes on this, as even though I seem to be getting the data I want, I might be oversimplifying. I'll be testing this tomorrow with more fonts, and seeing if and how this works together with Wakamai Fondue.

Base automatically changed from prettier-config to main February 17, 2026 22:05
@RoelN
Copy link
Collaborator Author

RoelN commented Feb 18, 2026

I tested some more fonts from the Google Fonts repo, these all seem to be working nicely! Pretty thrilled this seems to be all there is to it. But waiting for you to confirm, @Pomax!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant