membrane-term

lread 2021-11-03T01:26:52.001500Z

Oh that orange site! Should I dare?

lread 2021-11-03T01:34:39.006Z

I’m entertaining myself by learning how membrane positions fonts vs how plain old skia positions text. Am I understanding correctly in that when skia is asked to draw text at x,`y` it y is the position of the text’s baseline, but membrane sees y as the top of the text’s bounding box?

phronmophobic 2021-11-03T01:35:24.006300Z

that how membrane.ui/label positions text

lread 2021-11-03T01:35:41.006600Z

Ok. Cool, I understood correctly!

phronmophobic 2021-11-03T01:36:36.007700Z

I'd like to have better support for text generally, but I also don't want to make too many half-baked versions

lread 2021-11-03T01:36:51.007900Z

Yeah. Makes sense.

phronmophobic 2021-11-03T01:37:09.008700Z

it's definitely an area for improvement, but it's also a bit of a rabbit hole

lread 2021-11-03T01:37:59.010300Z

I was trying to clean up some of the askew-ness of the unicode glyphs… which led me to the rabbit hole of understanding how text is rendered.

phronmophobic 2021-11-03T01:38:03.010600Z

I do want to improve it, but I also want to spend some time thinking about it to try and come up with a decent API

lread 2021-11-03T01:39:23.012500Z

I’m just exploring and learning, I think I could commit font support almost as is and we could create separate issues for unicode support.

phronmophobic 2021-11-03T01:39:30.012800Z

but I'd be happy to explain how things currently work and help come up with work arounds

lread 2021-11-03T01:41:08.014500Z

Well… my current confusion is around finding the font’s baseline. The font metrics returned are all based off that. This isn’t a problem for skia, because the font is drawn on the baseline, but I’m not sure how to find the baseline with membrane.

lread 2021-11-03T01:42:20.015500Z

perty!

phronmophobic 2021-11-03T01:42:25.015700Z

essentially, the label draws it at the top left corner

✅ 1
phronmophobic 2021-11-03T01:42:46.016200Z

so the baseline offset should be the same as the ascent

lread 2021-11-03T01:43:46.017200Z

Ah… ok, I just have to negate the ascent and I’ve got the baseline! Hmm… a picture is worth many words!

😄 1
lread 2021-11-03T01:44:58.017700Z

I shall try and play with this new found knowledge, thanks!

phronmophobic 2021-11-03T01:46:31.018300Z

Any feedback for membrane is definitely welcome!

lread 2021-11-03T01:47:07.018900Z

Well, my feedback will likely come in the form of questions like these!

phronmophobic 2021-11-03T01:47:55.019200Z

perfect!

lread 2021-11-03T01:48:21.019700Z

It’s good fun playing with membrane.term, thanks for that!

🎉 1
lread 2021-11-03T02:37:43.022500Z

Aha! @smith.adriane, I think I might have found what was throwing me off. Label text, when converted https://github.com/phronmophobic/membrane/blob/f8fe28a7b262fe8ca92b6f101534d89c60879402/csource/skia.cpp#L219.

lread 2021-11-03T02:39:07.023200Z

So effectively, I think that means there is a descent gap sized padding above text.

lread 2021-11-03T02:40:55.023600Z

Which seems like a bug to me, but maybe intentional for some reason I don’t yet understand.

phronmophobic 2021-11-03T02:48:03.024100Z

oh, I remember now. It's just drawn one line down.

phronmophobic 2021-11-03T02:49:01.025Z

The basic reasoning at the time was that every other drawing primitive had its origin in the top left corner.

phronmophobic 2021-11-03T02:49:40.025700Z

shifting the text down one line mean that labels could match that

phronmophobic 2021-11-03T02:50:31.026800Z

I have some different ideas for what a better text primitive might look like, but that's what label does

phronmophobic 2021-11-03T02:51:11.027600Z

I wouldn't update label's implementation at this point, but I do intend on adding newer text primitives that give better layout options

lread 2021-11-03T02:51:58.027900Z

I think it might be shifted on descent gap height down?

phronmophobic 2021-11-03T02:52:25.028200Z

getSpacing returns line height I believe

lread 2021-11-03T02:52:40.028500Z

yeah but skia draws on the baseline

phronmophobic 2021-11-03T02:53:56.029400Z

right, so it's effectively shifted by the ascent?

lread 2021-11-03T02:54:56.030300Z

no the descent, I think?

phronmophobic 2021-11-03T02:56:08.031100Z

I'm away from keyboard, but I guess I would just draw rectangles for ascent, descent, and leading on top of the text

lread 2021-11-03T02:57:36.031600Z

That’s exactly what I’m playing with simple_smile now.

👍 1
lread 2021-11-03T02:59:09.032600Z

That’s my unadjusted version. But if I compensate for the descent gap. Things look better.

lread 2021-11-03T03:05:09.034100Z

Anyway, without having used membrane much, I don’t know if the gap is helpful in the general. In the specific here, it was confusing for me, but if you want to keep the behavior as is, a note in the docs would do the trick.

phronmophobic 2021-11-03T03:07:30.036100Z

yea, changing it would be more likely to break existing code than fix it, so I’m unlikely to change it, but adding newer, better text primitives and deprecating label is definitely on the cards

phronmophobic 2021-11-03T03:08:43.036600Z

currently, label tries to do too many things and none well

lread 2021-11-03T03:12:09.037900Z

Hey at least it prints labels, right? Poor label, you’re going to give it a complex! But yeah, I’m good now. I understand how it works and can work with it.

😆 1
phronmophobic 2021-11-03T03:22:14.038300Z

the docs also need a revamp

phronmophobic 2021-11-03T03:22:41.038700Z

I love your adhoc label inspector

phronmophobic 2021-11-03T03:23:45.039300Z

not sure if you've seen https://vimeo.com/66085662, but being able to quickly throw together adhoc visual tools is one of the goals I'm working towards

lread 2021-11-03T03:45:41.042100Z

I really enjoy doing a REPL eval and immediately seeing the effect of my change. So very cool. Have not seen that video yet, thanks, will put on my watch list. I’m happy to tweak docs here and there, as I learn this and that, if that would be helpful.

phronmophobic 2021-11-03T03:46:53.042400Z

that would be more than welcome

phronmophobic 2021-11-03T03:47:51.043100Z

if you're feeling extra ambitious, I would love your take on some of the design notes: • https://blog.phronemophobic.com/what-is-a-user-interface.htmlhttps://blog.phronemophobic.com/ui-model.htmlhttps://blog.phronemophobic.com/reusable-ui-components.html

lread 2021-11-03T03:49:12.043500Z

Not sure what I can offer, but I can give ’em a read!

lread 2021-11-03T03:50:23.043800Z

That’s it for me for today, g’night!

phronmophobic 2021-11-03T03:51:47.044Z

night!