Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix label blur when using dark font color #3949

Merged
merged 1 commit into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cocos2d/core/CCNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ var Node = cc.Class({

// OVERRIDES

_onSiblingIndexChanged (index) {
_onSiblingIndexChanged () {
// update rendering scene graph, sort them by arrivalOrder
var parent = this._parent;
var siblings = parent._children;
Expand Down
6 changes: 3 additions & 3 deletions cocos2d/core/renderer/utils/label/ttf.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let _color = null;
let _fontFamily = '';
let _overflow = Overflow.NONE;
let _isWrapText = false;
let _backgroundStyle = 'rgba(255, 255, 255, 0.005)';
const _invisibleAlpha = (1 / 255).toFixed(3);

// outline
let _isOutlined = false;
Expand Down Expand Up @@ -210,15 +210,15 @@ module.exports = {
_context.clearRect(0, 0, _canvas.width, _canvas.height);
//Add a white background to avoid black edges.
//TODO: it is best to add alphaTest to filter out the background color.
_context.fillStyle = _backgroundStyle;
_context.fillStyle = `rgba(${_color.r}, ${_color.g}, ${_color.b}, ${_invisibleAlpha})`;
_context.fillRect(0, 0, _canvas.width, _canvas.height);
_context.font = _fontDesc;

let startPosition = this._calculateFillTextStartPosition();
let lineHeight = this._getLineHeight();
//use round for line join to avoid sharp intersect point
_context.lineJoin = 'round';
_context.fillStyle = `rgba(${_color.r}, ${_color.g}, ${_color.b}, ${1})`;
_context.fillStyle = `rgba(${_color.r}, ${_color.g}, ${_color.b}, 1)`;

let underlineStartPosition;
//do real rendering
Expand Down