diff --git a/cocos2d/core/labelttf/CCLabelTTF.js b/cocos2d/core/labelttf/CCLabelTTF.js index 57cd2a0b1a..42803f2a2a 100644 --- a/cocos2d/core/labelttf/CCLabelTTF.js +++ b/cocos2d/core/labelttf/CCLabelTTF.js @@ -923,13 +923,12 @@ document.body ? * @private */ cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { - + var clientHeight, labelDiv = cc.LabelTTF.__labelHeightDiv; if(fontName instanceof cc.FontDefinition){ /** @type cc.FontDefinition */ var fontDef = fontName; - var clientHeight = cc.LabelTTF.__fontHeightCache[fontDef._getCanvasFontStr()]; + clientHeight = cc.LabelTTF.__fontHeightCache[fontDef._getCanvasFontStr()]; if (clientHeight > 0) return clientHeight; - var labelDiv = cc.LabelTTF.__labelHeightDiv; labelDiv.innerHTML = "ajghl~!"; labelDiv.style.fontFamily = fontDef.fontName; labelDiv.style.fontSize = fontDef.fontSize + "px"; @@ -939,19 +938,18 @@ cc.LabelTTF.__getFontHeightByDiv = function (fontName, fontSize) { clientHeight = labelDiv.clientHeight; cc.LabelTTF.__fontHeightCache[fontDef._getCanvasFontStr()] = clientHeight; labelDiv.innerHTML = ""; - return clientHeight; } - - //Default - var clientHeight = cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize]; - if (clientHeight > 0) return clientHeight; - var labelDiv = cc.LabelTTF.__labelHeightDiv; - labelDiv.innerHTML = "ajghl~!"; - labelDiv.style.fontFamily = fontName; - labelDiv.style.fontSize = fontSize + "px"; - clientHeight = labelDiv.clientHeight; - cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize] = clientHeight; - labelDiv.innerHTML = ""; + else { + //Default + clientHeight = cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize]; + if (clientHeight > 0) return clientHeight; + labelDiv.innerHTML = "ajghl~!"; + labelDiv.style.fontFamily = fontName; + labelDiv.style.fontSize = fontSize + "px"; + clientHeight = labelDiv.clientHeight; + cc.LabelTTF.__fontHeightCache[fontName + "." + fontSize] = clientHeight; + labelDiv.innerHTML = ""; + } return clientHeight; }; diff --git a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js index 22dbb54890..471efee96c 100644 --- a/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +++ b/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js @@ -57,7 +57,6 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; if(fontNameOrFontDef instanceof cc.FontDefinition){ this._fontStyleStr = fontNameOrFontDef._getCanvasFontStr(); this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(fontNameOrFontDef); - }else { var deviceFontSize = fontSize * cc.view.getDevicePixelRatio(); this._fontStyleStr = fontStyle + " " + fontWeight + " " + deviceFontSize + "px '" + fontNameOrFontDef + "'"; @@ -188,8 +187,8 @@ cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/; var locContentWidth = node._contentSize.width * scale - locStrokeShadowOffsetX; //lineHeight - var lineHeight = node.getLineHeight(); - var transformTop = (lineHeight - this._fontClientHeight) / 2; + var lineHeight = node.getLineHeight() * scale; + var transformTop = (lineHeight - this._fontClientHeight * scale) / 2; if (locHAlignment === cc.TEXT_ALIGNMENT_RIGHT) xOffset += locContentWidth; diff --git a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js index cf20db187f..01cd6b3609 100644 --- a/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +++ b/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js @@ -43,7 +43,7 @@ proto.constructor = cc.ProgressTimer.WebGLRenderCmd; proto.transform = function (parentCmd, recursive) { - cc.Node.WebGLRenderCmd.prototype.transform.call(this, parentCmd, recursive); + this.originTransform(parentCmd, recursive); var sp = this._node._sprite; sp._renderCmd.transform(this, recursive);