Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LinYunMo committed Sep 15, 2023
1 parent ec97648 commit 33bc9d1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
3 changes: 2 additions & 1 deletion cocos/2d/assembler/label/ttfUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { TextOutputLayoutData, TextOutputRenderData } from './text-output-data';
import { TextStyle } from './text-style';
import { TextLayout } from './text-layout';
import { view } from '../../../ui/view';
import { approx } from '../../../core';

const Overflow = Label.Overflow;

Expand Down Expand Up @@ -78,7 +79,7 @@ export const ttfUtils = {
}

// shadow// both
const isShadow = comp.enableShadow && (comp.shadowBlur > 0 || comp.shadowOffset.x !== 0 || comp.shadowOffset.y !== 0);
const isShadow = comp.enableShadow && (comp.shadowBlur > 0 || !approx(comp.shadowOffset.x, 0) || !approx(comp.shadowOffset.y, 0));
if (isShadow) {
style.hasShadow = true;
style.shadowColor.set(comp.shadowColor);
Expand Down
11 changes: 0 additions & 11 deletions cocos/2d/components/label-outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ export class LabelOutline extends Component {
assertIsTrue(label, 'Required Label component to work, please add Label component.');
label.enableOutline = false;
}

/**
* @deprecated since v3.8.2, please use [[Label.enableOutline]] instead.
*/
public onLoad (): void {
const label = this.node.getComponent(Label);
assertIsTrue(label, 'Required Label component to work, please add Label component.');
if (this.enabledInHierarchy) {
label.enableOutline = true;
}
}
}

cclegacy.LabelOutline = LabelOutline;
11 changes: 0 additions & 11 deletions cocos/2d/components/label-shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,4 @@ export class LabelShadow extends Component {
assertIsTrue(label, 'Required Label component to work, please add Label component.');
label.enableShadow = false;
}

/**
* @deprecated since v3.8.2, please use [[Label.enableShadow]] instead.
*/
public onLoad (): void {
const label = this.node.getComponent(Label);
assertIsTrue(label, 'Required Label component to work, please add Label component.');
if (this.enabledInHierarchy) {
label.enableShadow = true;
}
}
}
4 changes: 2 additions & 2 deletions tests/ui/label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('labelOutline.setter', () => {
node.addComponent(LabelOutline);
let labelOutline = node.getComponent(LabelOutline) as LabelOutline;
node._setActiveInHierarchy(true);
labelOutline.onLoad();
labelOutline.onEnable();
expect(label.enableOutline).toStrictEqual(true);
labelOutline.color = new Color(255, 0, 0, 255);
expect(label.outlineColor).toStrictEqual(new Color(255, 0, 0, 255));
Expand All @@ -58,7 +58,7 @@ test('labelShadow.setter', () => {
node.addComponent(LabelShadow);
let labelShadow = node.getComponent(LabelShadow) as LabelShadow;
node._setActiveInHierarchy(true);
labelShadow.onLoad();
labelShadow.onEnable();
expect(label.enableShadow).toStrictEqual(true);
labelShadow.color = new Color(255, 0, 0, 255);
expect(label.shadowColor).toStrictEqual(new Color(255, 0, 0, 255));
Expand Down

0 comments on commit 33bc9d1

Please sign in to comment.