Is it possible to hide everything beyond a glyph's canvas?

For example, if an element of a glyph is wider than the glyph’s defined width, is it possible to ‘clip’ the parts of the element that are not inside the box?

Can you give an example why you need that?

I’m trying to resolve the problem of underline’s appearance on the web — browsers and apps often mess up underline’s thickness or/and position. I need it for a design identity based on an underline.

In order to resolve the problem, I want to create a font feature with every glyph having a line under it. It seems that a smart component could help — however, I would still have to manually change the width of the line for every glyph. So I was hoping for a simpler solution like just inserting a wide underline into every glyph and automatically cutting it to the glyphs’ widths.

In short, I need a fast way to make hundreds of instances of a component to match the glyphs’ widths.

I hope that I make sense

An automatically inserted underline is a good task for a filter plug-in. But I don’t know what clipping has to do with it.

What thickness/position does your underline have? You could write a very small script that simply draws a rectangle at the given position with the given height and the width of the glyph.

This would make it difficult to later make edits globally, though. Second script approach: add a component (width: 100) to each glyph and set the x scale to layer width/100.