Alignment breaks in presence of non-standard-width glyphs #122

Open
opened 2018-02-24 05:53:48 +01:00 by pythonissam · 2 comments
pythonissam commented 2018-02-24 05:53:48 +01:00 (Migrated from github.com)
$ brittany --version
brittany version 0.9.0.0
Copyright (C) 2016-2017 Lennart Spitzner
There is NO WARRANTY, to the extent permitted by law.

Example

f xs
  | xs == "a" = True
  | xs == "abc" = True

will be formatted correctly like below:

f xs | xs == "a"   = True
     | xs == "abc" = True

Though

f xs
  | xs == "あ" = True
  | xs == "abc" = True

becomes

f xs | xs == "あ"   = True
     | xs == "abc" = True

I guess brittany doesn't handle multibyte strings.

```bash $ brittany --version brittany version 0.9.0.0 Copyright (C) 2016-2017 Lennart Spitzner There is NO WARRANTY, to the extent permitted by law. ``` # Example ```haskell f xs | xs == "a" = True | xs == "abc" = True ``` will be formatted correctly like below: ```haskell f xs | xs == "a" = True | xs == "abc" = True ``` Though ```haskell f xs | xs == "あ" = True | xs == "abc" = True ``` becomes ```haskell f xs | xs == "あ" = True | xs == "abc" = True ``` I guess brittany doesn't handle multibyte strings.
lspitzner commented 2018-02-25 18:08:45 +01:00 (Migrated from github.com)

I see, that is a bit unfortunate. However it does not seem to be connected to "multibyte" aspect, but rather to the fact that even with monospace fonts, the glyph for "あ" is larger than other glyphs. The alignment functionality in brittany really only makes sense when all glyphs have the same size.

So the only fix I can think of is to disable alignment: Either globally via
_lconfig_columnAlignMode = ColumnAlignModeDisabled or perhaps we could implement something that disables only in relevant cases? I don't really know and somewhat doubt that such cases could be detected reliably though, because it is more the font's property than the codepoint's.

I see, that is a bit unfortunate. However it does not seem to be connected to "multibyte" aspect, but rather to the fact that even with monospace fonts, the glyph for "あ" is larger than other glyphs. The alignment functionality in brittany really only makes sense when all glyphs have the same size. So the only fix I can think of is to disable alignment: Either globally via `_lconfig_columnAlignMode = ColumnAlignModeDisabled` or perhaps we could implement something that disables only in relevant cases? I don't really know and somewhat doubt that such cases could be detected reliably though, because it is more the font's property than the codepoint's.
tfausak commented 2019-06-18 15:32:11 +02:00 (Migrated from github.com)

How should this be aligned?

f x = case x of
  "1" -> () -- U+0031
  "2" -> () -- U+FF12
  _   -> ()

All of the arrows are aligned. They start at column 8. But the characters themselves aren't the same visual width.

How _should_ this be aligned? ``` hs f x = case x of "1" -> () -- U+0031 "2" -> () -- U+FF12 _ -> () ``` All of the arrows are aligned. They start at column 8. But the characters themselves aren't the same visual width.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#122
There is no content yet.