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

[Bug]: shadow appears on the upper side, and the underline displays on the backside of a Textbox when objectcaching is false #9866

Closed
7 tasks done
niketaOptimumnbrew opened this issue May 7, 2024 · 8 comments

Comments

@niketaOptimumnbrew
Copy link

niketaOptimumnbrew commented May 7, 2024

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

5.3.0

In What environments are you experiencing the problem?

Firefox, Chrome, Safari

Node Version (if applicable)

14.20.0

Link To Reproduction

https://jsfiddle.net/Niketa_patel/as5evzt2/58/

Steps To Reproduce

  1. Please check above fiddle to reproduce the issue.
  2. shadow will display on text.

Expected Behavior

  • should show shadow text backside of text, don't show shadow text over the text or over the underline.


image

Actual Behavior

  • shadow text show over the text underline rather than displaying backside of text

image

Error Message & Stack Trace

No response

@niketaOptimumnbrew niketaOptimumnbrew changed the title [Bug]: shadow show upper side and line show backside in Textbox [Bug]: shadow show upper side and underline show backside in Textbox May 7, 2024
@niketaOptimumnbrew niketaOptimumnbrew changed the title [Bug]: shadow show upper side and underline show backside in Textbox [Bug]: shadow appears on the upper side, and the underline displays on the backside of a Textbox May 7, 2024
@niketaOptimumnbrew niketaOptimumnbrew changed the title [Bug]: shadow appears on the upper side, and the underline displays on the backside of a Textbox [Bug]: shadow appears on the upper side, and the underline displays on the backside of a Textbox when objectcaching is false May 8, 2024
@asturur
Copy link
Member

asturur commented Jul 3, 2024

@niketaOptimumnbrew when drawing without caching the drawing operations are one by one, and the shadow is applied each time. You need caching ( isolation ) enabled if you want shadow to appear correctly.
What is the issue with enabling caching?

@asturur asturur closed this as completed Jul 3, 2024
@niketaOptimumnbrew
Copy link
Author

niketaOptimumnbrew commented Jul 5, 2024

@niketaOptimumnbrew when drawing without caching the drawing operations are one by one, and the shadow is applied each time. You need caching ( isolation ) enabled if you want shadow to appear correctly. What is the issue with enabling caching?

with enable caching object not update on each and every action.
I want to update object with all the action of object like scale , zoom etc.

font also show blur with enable caching.

@asturur is their any solution for disable caching?

@asturur
Copy link
Member

asturur commented Jul 5, 2024

@niketaOptimumnbrew you are putting yourself in a series of issues because you don't use caching.
Please which are those things that do not update cache?
Let's fix caching, not using time on things that can't work without caching.

@niketaOptimumnbrew
Copy link
Author

niketaOptimumnbrew commented Jul 8, 2024

@niketaOptimumnbrew you are putting yourself in a series of issues because you don't use caching. Please which are those things that do not update cache? Let's fix caching, not using time on things that can't work without caching.

  • Text with enable caching.

image

  • Text with disable caching.

image

I'm using textbox for text rendering.
@asturur Please check above two images with caching enable and disable.

@asturur
Copy link
Member

asturur commented Jul 8, 2024

I havew no idea how you are creating that text and why in your opinion caching is at the heart of the issue.
You are probably not triggering a cache invalidation in some way.

@niketaOptimumnbrew
Copy link
Author

I havew no idea how you are creating that text and why in your opinion caching is at the heart of the issue. You are probably not triggering a cache invalidation in some way.

Let me explain to you about how i render text on canvas.

Steps:

  1. First I render text on canvas.
  2. load font after text render.
  3. Update textbox width according font and fontfamily.

Example:

obj = {
                left: Math.round(element.xPos),
                top: Math.round(element.yPos),
                fontWeight: element.fontWeight,
                fill: element.color,
                opacity: element.opacity / 100,
                cursorColor: "blue",
                fontSize: Math.round(element.size),
                textAlign: alignment,
                lockScalingX: false,
                lockScalingY: false,
                hasRotatingPoint: false,
                transparentCorners: true,
                centeredRotation: true,
                lineHeight: 1.16,
                charSpacing: 0,
                shadow: {
                    "color": element.shadowColor,
                    "blur": element.shadowRadius,
                    "offsetX": element.shadowDistance,
                    "offsetY": element.shadowDistance
                },
                fontFamily: tmp_fontName,
                isLocked: false,
                index: element.index,
                isTextwidthmdfy: false,
                isObjectcenter:false,
                lockScalingFlip:true,
                iswimdfybymcontrol:true,
            }
let iTextSample = new fabric.Textbox(element.text, obj);
 let wid_ = this.calcTextboxwidth(iTextSample);
        iTextSample.set({
            width:wid_
        })
this.canvas.add(iTextSample);
let json = this.canvas.toJSON(CUSTOM_ATTRIBUTES);
 this.loopAllFontFirst({ canvasJSON: json }).then(async (result) => {
 this.reRenderServerTextProperty();
this.canvas.renderAll.bind(this.canvas);
})

// Caculate text width
    calcTextboxwidth(object)
    {
    latestFabric.fabric.util.clearFabricFontCache();
    var tempText = new latestFabric.fabric.Text(object.text, {
        fontSize: object.fontSize,
        fontWeight: object.fontWeight,
        fontFamily: object.fontFamily,
        charSpacing: object.charSpacing,
        textBackgroundColor:object.textBackgroundColor,
        fill:object.fill,
        stroke:object.stroke,
        strokeWidth:object.strokeWidth,
        objectCaching:false,
        scaleX:object.scaleX,
        scaleY:object.scaleY,
        shadow:object.shadow,
        borderColor:object.borderColor,
        shadow_theme_index:object.shadow_theme_index,
        height:object.height,
        textAlign:object.textAlign,
        lineHeight:object.lineHeight,

    });
    // Calculate the width of the text
    var textWidth = this.isSafariBrowser ? tempText.calcTextWidth() + 1 : tempText.calcTextWidth() + 1;
    tempText = null;
    return textWidth;
    }
    reRenderServerTextProperty() {
        this.canvas.getObjects('textbox').forEach(async object => {
            let wid_ = await this.calcTextboxwidth(object);
            object.width = wid_;
        });
        this.canvas.renderAll();
    }

With this scenario , I'm getting issue with enable caching as you can see in above screenshot.

@asturur Please help if I missing anything in it.

@asturur
Copy link
Member

asturur commented Jul 9, 2024

What you show seems to be a text width + wrapping issue. I m not sure why object caching should play a role there

@niketaOptimumnbrew
Copy link
Author

What you show seems to be a text width + wrapping issue. I m not sure why object caching should play a role there

@asturur Is it possible when I update object width with enable caching then object update but not the text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants