simpledisplay custom font stream of thought

Posted 2022-10-24

I am unifying some of the simpledisplay font interfaces and wrote some random thoughts while doing it.

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

What Adam is working on

I've gotten a few requests to clean up some old code in the arsd code. Some of this code is over ten years old and has barely been touched in all that time (I always laugh when people say D is horribly unstable and changes too fast...) and I've changed my mind on some designs.

Part of this is updating the old docs. I have some FIXME things I fixed ages ago, but forgot to update the thing. Some things never got updated to link to alternate options (like simpledisplay's fonts, there's a couple ways to do it and the newer one isn't always better than the old one, so I kept both, but never updated the docs to explain this in both places).

Part of it is fixing some old bugs. Some of them are very easy to fix, just I never went back to finish it off.

And some of it is bridging the features better in code. For example, the old simpledisplay arsdTtfFont and the new OperatingSystemFont serve very similar, but not exactly the same purposes. Their interfaces are very different though, which makes it unnecessarily difficult to swap them. Additionally, you can construct an arsdTtfFont from a OperatingSystemFont (and interestingly, on Windows, it is possible to go the other way around too, but I don't think you can on X...), but neither the api nor docs make this obvious. So I can improve both and make it easier to use.

BTW it does really bug me that Xft has zero support for using a specific, application-provided ttf file. I think I can poke the private struct definitions to make it work but I'd rather to it through something with official support... and xft is tied together to fontconfig, and fontconfig really wants you to go through its system. Sigh. If it would allow me to pass it a block of memory - like Windows does - the systems could be fully unified in both directions.

One general thing I find myself doing a lot is when I have related concepts, I keep duplicating documentation. For example, I want a table that shows the pros and cons of various text options. I want this table to be seen on each option. Easiest way is to have an overview page and just link to it, but that's a link that a lot of people wouldn't even bother reading (sadly enough). And it is a bit of a pain to write since it means moving to the other page too and remembering to link it in. I don't know how I want to do this... cross-thing overviews don't fit so well in the inline doc model. adrdox lets you define a group thing, but the actual docs need to be on the module definition and I'm not sure I like that. I'm tempted to support something else but idk what yet.

In any case, I committed some of the common interface and doc updates in simpledisplay already, some docs in dom.d and others, and more will be coming soon. Throwing up some basic docs at least doesn't take too long and I can do it in between other things so it doesn't have to wait on my bigger projects to be finished.