xod-wow / LiteMount

World of Warcraft addon LiteMount
GNU General Public License v2.0
31 stars 10 forks source link

Low Priority Feature Request: Use a monospaced font for the advanced options input #277

Closed LootFever closed 3 months ago

LootFever commented 3 months ago

This is really a low priority feature request.

It would be nice if the advanced options editor could use a monospaced font. I've looked at the editor in a kind of programming way for quite a while now and wished it were monospaced. I think this would improve readability too. 🤓

Currently I'm circumventing it by copying my advanced options into a different program, editing and posting it all back everytime I need to make a change.

getting ahead of myself ... Maybe down the line we can even get sth like tab-stop recognition or even syntax highlighting, but as we already talked about I'm probably one of the 0.1% that even uses all of this 😄

Feel free to decline it if you think it's too much of a personal request 😝

mbattersby commented 3 months ago

I agree it would be nice to have a monospaced font!

Now comes all the whinging. Sorry in advance.

As far as I can tell WoW doesn't doesn't ship a monospaced font. I'm not sure what do do about that.

Blizzard have done a nice job of providing fonts that support all the languages WoW supports and wrapping them up under a single name so I don't have to care and everyone in Korea, Russia and China is happy.

I can provide my own font, but I don't know how to find one that supports all of that. Or if that's even possible, or if I'd need to provide 4+ fonts and figure out how Blizzard give them a single name. I'm not prepared to make LiteMount only work in English, even though it's the only language I speak. Also the fonts have to be licensed in a way I can distribute them under GPL, and I have to be smart enough to be able to tell (which I'm not sure I am).

I honestly don't even know if a monospaced font is a concept that makes sense in Chinese or Korean. I assume it makes sense in Russian.

Using a monospace font is easy (literally changing one line). Having one to use seems hard.

Those other things, rewriting the wow edit box so that it's VSCode, I am definitely not going to do. :)

Happy adventuring, X.

LootFever commented 3 months ago

Regarding fonts I know that Droid and Noto have a wide range of coverage. If they cover all and are licensed in a way that you can use them I'm not sure.

Using a monospace font is easy (literally changing one line). Having one to use seems hard.

Where would I find that? Wanna check it out for curiosities sake.

mbattersby commented 3 months ago

The line that picks the font is in LiteMount/UI/Advanced.xml and is near the end of this block:

            <ScrollChild>
                <EditBox parentKey="EditBox" multiLine="true" autoFocus="false" mixin="LiteMountAdvancedEditBoxMixin">
                    <Size x="1" y="1" />
                    <Anchors>
                        <Anchor point="TOPLEFT" />
                    </Anchors>
                    <Scripts>
                        <OnLoad method="OnLoad" />
                        <OnTextChanged function="LiteMountOptionsControl_OnTextChanged" />
                        <OnEscapePressed function="EditBox_ClearFocus" />
                        <OnUpdate function="InputScrollFrame_OnUpdate" />
                        <OnCursorChanged function="ScrollingEdit_OnCursorChanged" />
                    </Scripts>
                    <FontString inherits="ChatFontNormal" />
                </EditBox>
            </ScrollChild>

It is the line that says <FontString inherits="ChatFontNormal" />. If you have a font that's been put in by another addon (and it loads before LiteMount) you can put the name in there. Otherwise you'd have to define your own named font as well from a TTF file.

<Font name="LiteMountAdvancedFont" font="Interface\Addons\LiteMount\UI\NotaMono.ttf" height="12" virtual="true" />

I'm guessing the syntax off the top of my head, the doc is https://warcraft.wiki.gg/wiki/XML/Font

mbattersby commented 3 months ago

Nota Sans Mono CJK TTF fonts are 33MB each for koKR, zhCN and zhTW. I don't really want to ship 100MB of fonts with my 250KB addon.

mbattersby commented 3 months ago

So this more or less works, and I learned more than I wanted about font rendering.

<FontFamily name="LiteMountMonoFont" virtual="true">
    <Member alphabet="roman">
        <Font font="Interface\AddOns\LiteMount\Fonts\FiraMono-Regular.ttf" height="12" />
    </Member>
    <Member alphabet="korean">
        <Font font="Fonts\2002.TTF" height="13"/>
    </Member>
    <Member alphabet="simplifiedchinese">
        <Font font="Fonts\ARKai_T.ttf" height="13"/>
    </Member>
    <Member alphabet="traditionalchinese">
        <Font font="Fonts\blei00d.TTF" height="13"/>
    </Member>
    <Member alphabet="russian">
        <Font font="Interface\AddOns\LiteMount\Fonts\FiraMono-Regular.ttf" height="12" />
    </Member>
</FontFamily>

It's monospace unless you put in a korean or chinese character, then it flips over to that font. Seems like the font renderer has some kind of "font that contains the longest sequence of initial glyphs" matching in it, and all the asian fonts contain the latin and cyrillic characters too because they are tiny in comparison and why not.

FiraMono is about 170k font file, NotoSans is about 400k. I'm still undecided if shipping an entire font is a good idea for a (fairly) niche use case.

mbattersby commented 3 months ago

11.0.2-1 uses a monospace font for the advanced editor where possible. Please try it out.

Going to close this off since the other two things would be as much work put together as LiteMount has been ever and are way beyond me.

LootFever commented 3 months ago

Saw the update today and got really excited when I read the changelog. It looks so good. Tankk you very much.

Going to close this off since the other two things would be as much work put together as LiteMount has been ever and are way beyond me.

No worries I can absolutely understand that.