Fork me on GitHub
#membrane-term
<
2021-11-03
>
lread01:11:52

Oh that orange site! Should I dare?

lread01:11:39

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?

phronmophobic01:11:24

that how membrane.ui/label positions text

lread01:11:41

Ok. Cool, I understood correctly!

phronmophobic01:11:36

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

lread01:11:51

Yeah. Makes sense.

phronmophobic01:11:09

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

lread01:11:59

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.

phronmophobic01:11:03

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

lread01:11:23

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.

phronmophobic01:11:30

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

lread01:11:08

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.

phronmophobic01:11:25

essentially, the label draws it at the top left corner

1
phronmophobic01:11:46

so the baseline offset should be the same as the ascent

lread01:11:46

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

😄 1
lread01:11:58

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

phronmophobic01:11:31

Any feedback for membrane is definitely welcome!

lread01:11:07

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

lread01:11:21

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

🎉 1
lread02:11:07

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

lread02:11:55

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

phronmophobic02:11:03

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

phronmophobic02:11:01

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

phronmophobic02:11:40

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

phronmophobic02:11:31

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

phronmophobic02:11:11

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

lread02:11:58

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

phronmophobic02:11:25

getSpacing returns line height I believe

lread02:11:40

yeah but skia draws on the baseline

phronmophobic02:11:56

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

lread02:11:56

no the descent, I think?

phronmophobic02:11:08

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

lread02:11:36

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

👍 1
lread02:11:09

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

lread03:11:09

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.

phronmophobic03:11:30

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

phronmophobic03:11:43

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

lread03:11:09

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
phronmophobic03:11:14

the docs also need a revamp

phronmophobic03:11:41

I love your adhoc label inspector

phronmophobic03:11:45

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

lread03:11:41

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.

phronmophobic03:11:53

that would be more than welcome

lread03:11:12

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

lread03:11:23

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