File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,25 @@ var MeasureText = function (textStyle)
2626
2727 textStyle . syncFont ( canvas , context ) ;
2828
29- var width = Math . ceil ( context . measureText ( textStyle . testString ) . width * textStyle . baselineX ) ;
29+ var metrics = context . measureText ( textStyle . testString ) ;
30+
31+ if ( metrics . hasOwnProperty ( 'actualBoundingBoxAscent' ) && metrics . hasOwnProperty ( 'actualBoundingBoxDescent' ) )
32+ {
33+ var ascent = metrics . actualBoundingBoxAscent ;
34+ var descent = metrics . actualBoundingBoxDescent ;
35+
36+ var output = {
37+ ascent : ascent ,
38+ descent : descent ,
39+ fontSize : ( ascent + descent )
40+ } ;
41+
42+ CanvasPool . remove ( canvas ) ;
43+
44+ return output ;
45+ }
46+
47+ var width = Math . ceil ( metrics . width * textStyle . baselineX ) ;
3048 var baseline = width ;
3149 var height = 2 * baseline ;
3250
You can’t perform that action at this time.
0 commit comments