Skip to content

Commit

Permalink
use canvas api (#6975)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatriceJiang committed Jul 16, 2020
1 parent 8feb4d0 commit d8f4d61
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cocos2d/core/components/CCLabel.js
Expand Up @@ -773,8 +773,10 @@ let Label = cc.Class({
BlendFunc.prototype._updateMaterial.call(this);
},

_forceUseCanvas: false,

_nativeTTF() {
return !!this._assembler && !!this._assembler._updateTTFMaterial
return !this._forceUseCanvas && !!this._assembler && !!this._assembler._updateTTFMaterial;
},

_forceUpdateRenderData () {
Expand Down
1 change: 1 addition & 0 deletions cocos2d/core/components/CCRichText.js
Expand Up @@ -96,6 +96,7 @@ pool.get = function (string, richtext) {
labelComponent.string = "";
labelComponent.horizontalAlign = HorizontalAlign.LEFT;
labelComponent.verticalAlign = VerticalAlign.CENTER;
labelComponent._forceUseCanvas = true;

return labelNode;
};
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/renderer/webgl/assemblers/label/index.js
Expand Up @@ -77,7 +77,7 @@ Assembler.register(cc.Label, {
ctor = is3DNode ? Bmfont3D : Bmfont;
} else if (label.cacheMode === Label.CacheMode.CHAR) {

if(CC_JSB && !is3DNode && !!jsb.LabelRenderer && label.font instanceof cc.TTFFont){
if(CC_JSB && !is3DNode && !!jsb.LabelRenderer && label.font instanceof cc.TTFFont && !label._forceUseCanvas){
ctor = NativeTTF;
} else if (cc.sys.platform === cc.sys.WECHAT_GAME_SUB) {
cc.warn('sorry, subdomain does not support CHAR mode currently!');
Expand Down

0 comments on commit d8f4d61

Please sign in to comment.