[solved] Getting numbered item lists to align correctly

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
white_haired_uncle
Posts: 1109
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] Getting numbered item lists to align correctly

Post by white_haired_uncle »

I want to present an order list of items inside an [option] block, with the numbers right justified and space-padded. Unable to find a sprintf in wml, I went with lua for that (and it works, I just mention it because I wonder if I missed something.

I want this (assuming it shows up right in your browser, it does in mine):

Code: Select all

 9) Dyran
10) Dungamabur
But what I get is this
weird_list.png
weird_list.png (111.57 KiB) Viewed 312 times
Note how the '9' doesn't align with the '0' in '10', instead it's kind of centered. I assume this is the font. I can see that 'l' takes up much less width than 'm', so I assume the same sort of thing is going on with my numbers. And I assume the answer I'm looking for is to change the font, or similar attribute with pango, but all I can find is that font is an attribute I can set, but not a list of what I could actually set it to. And even if I had such a list, I wouldn't know what to choose without just guess and error.

TIA
Last edited by white_haired_uncle on June 10th, 2023, 10:02 pm, edited 1 time in total.
User avatar
Pentarctagon
Project Manager
Posts: 5531
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Getting numbered item lists to align correctly

Post by Pentarctagon »

It sounds like what you want is a monospace font. This does have issues currently on Windows for 1.17 though (https://github.com/wesnoth/wesnoth/issues/7462).
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
white_haired_uncle
Posts: 1109
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] Getting numbered item lists to align correctly

Post by white_haired_uncle »

Thanks, that worked.

Example in case someone bumps into this thread some day.

Code: Select all

{VARIABLE my_message "<span font_family='monospace'>$list_index|)</span> $to_autorecall.name| ($to_autorecall.language_name|)" }
Post Reply