How to remove sidebearings of glyphs at lines edges?

I’m making a monospaced font, and since the spacing will be the same for all glyphs, I’m using a filter with Transformations;LSB:+50.0;RSB:+50.0; to automate spacing in the sidebearings.

However, and as expected, when using the font and aligning the text box to a grid, the text is always offset by the sidebearings, forcing me to always shift the text box so the glyphs match the grid:

What is the best way to make the first and last glyphs of each line to have their edge sidebearings canceled out (or not have them at all)?

I have a few ideas in mind, but I’m not sure they’re good enough for what I’m trying to achieve:

  • Using positional alternates, but it will just bloat the font with 3× more glyphs (.init, .fina, and .isol) than actually needed.
  • Using the kern feature to lookup for the start/end of the text and any line breaks, as suggested by this article. Not sure if this actually works, though.
  • Or, is there any better way to implement spacing only in medial glyphs instead of using a Transformations filter to apply to all the glyphs?

Context: I’m making this font to be used in CAM projects. Things like 3D printing, CNC machining, and other types of printing/machining that require precision. Having whitespace will complicate the design process.

What about a left sidebarring of 0, and a right sidebarring of one grit unit?


It doesn’t fully solve the problem… Yes, it now aligns to the grid, but the bounding box on the right side will still be bigger than it needs to be…

Why is that a problem? You need to have the sidebearings somewhere in a monospaced font.

I know, but I don’t want the bounding box of a text to be bigger than it needs to be. I want any whitespace to be trimmed on both sides.

That would be a request to the developer of the app you are using the font in.

I don’t intent to make this font compatible only to a single app…

Again, it is not a font issue. It’s a UI issue. If you want a monospaced font, you need to have sidebearings. If you change that, it is not a monospaced font anymore. Or you change the design and make the letters touch.

Your font is perfectly compatible with all apps that support opentype. The question is how the app displays it. You can hardly influence that from within the font.