Skip to content

Commit

Permalink
Merge pull request #1173 from stevencohn/1172-remove-kerning-in-palette
Browse files Browse the repository at this point in the history
fix extra kerning in command palette listbox
  • Loading branch information
stevencohn authored Nov 18, 2023
2 parents 72ef490 + 75bd43e commit e848196
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions OneMore/UI/MoreAutoCompleteList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,15 @@ protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
phrase = text.Substring(0, index);

e.Graphics.DrawString(phrase, Font, fore, x, e.Bounds.Y, StringFormat.GenericDefault);
size = e.Graphics.MeasureString(phrase, Font, new PointF(x, e.Bounds.Y), StringFormat.GenericDefault);
// when phrase is substring of word, GenericTypographic doesn't measure
// trailing space and when it is prefaced by a space, GenericDefault
// removes that space. So choose appropriate format carefully here
var format = index < text.Length - 1 && text[index - 1] == ' '
? StringFormat.GenericDefault
: StringFormat.GenericTypographic;

e.Graphics.DrawString(phrase, Font, fore, x, e.Bounds.Y, format);
size = e.Graphics.MeasureString(phrase, Font, new PointF(x, e.Bounds.Y), format);
x += size.Width;
}

Expand Down

0 comments on commit e848196

Please sign in to comment.