Apply gradient over mesh of antialiased primitives

I am drawing 2D geometry (line and quad strip meshes) with a gradient, by using the stencil
buffer to draw the geometry and then a quad that has the gradient. But it doesn’t work with
primitive antialiasing, probably since the stencil buffer can’t use the coverage bits.
Could someone point to a previous topic that addresses this issue? I tried to find such a topic
but couldn’t. Or maybe a different approach would work, by using a custom blend function?
Thank you.

An alternative way of drawing a color gradient would be to make an 1D-gradient texture and use texgen to address this texture based on screen coordinates.