The first would be easy to simulate semantically, treating the leading whitespace as a flexible tab stop and thus replacing all the leading spaces with a space of the appropriate width (basically, the editor would replace the leading spaces with `retval = select(` with opacity 0).
The second would be more difficult to handle, but so long as you know what to look for to indicate the style is being done it could be handled perfectly intelligently. It’s not the simplest thing, but it’s perfectly feasible.
Basically, variable width fonts can become fine so long as you also have semantic understanding of what is being achieved with whitespace. The use of monospace fonts is a cop-out, pure laziness. [Yes, I am deliberately stating this more strongly than I believe. It’s an understandable laziness, as the problem is hard and the industry and tooling all backs monospace, but it is laziness.]