javascript - KineticJS actual text height -


i'm having problem getting actual text height of text object.

var btntext = new kinetic.text({         x: xtracker,         y: headery,         fill: '#a2b1c3',         text: buttontext,         width: buttonwidth,         fontsize: 40,         fontfamily: 'impact',         align: 'center'     }); 

all of following methods return same number, 40, not actual height of text.

btntext.getheight(); btntext.gettextheight(); btntext._gettextsize().height; 

for debugging purposes, added following rect show text region

var tmp = new kinetic.rect({                         x: btntext.getposition().x,             y: btntext.getposition().y,             fill: 'rgba(0,0,0,0.3)',             width: btntext.getwidth(),             height: btntext.getheight()         }); 

here result:

enter image description here

you can see gray box (i.e. text region) larger actual text. need actual text size within region.

can use:

var metrics = context.measuretext(label); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -