Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle proportional fonts? #13

Open
tobia opened this issue Sep 15, 2015 · 1 comment
Open

How to handle proportional fonts? #13

tobia opened this issue Sep 15, 2015 · 1 comment

Comments

@tobia
Copy link

tobia commented Sep 15, 2015

I like this plugin. Yes, it's not a proper implementation of elastic tabstops, because ST does not allow one yet, but it has the added benefit of being able to open the files in any fixed-width editor and see them properly aligned.

One things that bugs me though, is that I use ST with a proportional font and the alignment comes and goes. Example:

example of elastic tabstops with proportional fonts

This obviously happens because some letters are wider than a space, so they overflow the tab stop and jump to the next one.

I'd like to develop a patch for this myself, but I'm unsure how to do it. Does ST have an API that returns the screen position (in pixels) of a certain character position (in rows and cols)? Do I have to compute the string widths myself, using some Python package that can parse the current font?

Even if I was able to determine the string widths, what's the best way to align them? If I add more spaces, I lose the automatic alignment in fixed-width editors.

Any idea?

@adzenith
Copy link
Member

It's going to be pretty complicated, and you could easily lose automatic alignment in fixed-width editors.
I'd check out view.text_to_layout.
You could use different-width spaces, if your language supports them. I just tried using an em space in Python 3 and it appeared to work fine. Then in a fixed-width environment that em-width space would hopefully show up as a normal space. Could work?

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

No branches or pull requests

2 participants