Canvas-Txt icon indicating copy to clipboard operation
Canvas-Txt copied to clipboard

Why Y position + fontsize?

Open PoeHaH opened this issue 3 years ago • 5 comments

Hi @geongeorge

Thank you for creating this great helper. Feel free to send me a PayPal donate link 🙂.

I have a quick question: in your source code, I see you're adding the fontsize to the Y-position:

if (this.vAlign === 'top')
      txtY = y + this.fontSize

Because of that, my output is not aligned to the top of the debug lines:

image

Is there a reason I'm not aware about for adding the fontSize to the Y position? Can it be removed?

PoeHaH avatar May 17 '21 10:05 PoeHaH

Hey @PoeHaH , Sorry for the delayed response. Are you sure that is causing the space you have? y + this.fontSize is there because otherwise it would render the text base line on the y line which will be above the rectangular box. Something like this: New Project (2)

geongeorge avatar Jun 04 '21 05:06 geongeorge

Thanks for your reply!

Hmm odd! I changed it t to txtY = y and that works but perhaps there's another issue going on like a line height or something. I'll have to dig further.

PoeHaH avatar Jun 04 '21 06:06 PoeHaH

@PoeHaH Weird! I'll take a look into this soon.

Thanks for pointing this out

geongeorge avatar Jun 04 '21 06:06 geongeorge

I appreciate that. I'm using your library in some of my software so I'd like to see it maintained. Reach out to me if you need anything that can help with that :).

PoeHaH avatar Jun 04 '21 06:06 PoeHaH

Fixes this here: https://github.com/geongeorge/Canvas-Txt/pull/76

geongeorge avatar Aug 16 '22 10:08 geongeorge