Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:20:02+00:00 2026-06-01T14:20:02+00:00

I want to draw text on canvas., how to do it any sample example?

  • 0

I want to draw text on canvas., how to do it any sample example?
The canvas already contains some shape drawn, i want to show text on the top of that shape on canvas
How can i do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:20:04+00:00Added an answer on June 1, 2026 at 2:20 pm

    Also be aware that you need to actually have loaded a cufon font. There is no default font when using Fabric.js.

    <script src="fabric.js"></script>
    <script src="cufon.calibri.js"></script>
    

    There are so many fonts available from http://www.cufonfonts.com/

    This being the case the author is planning on removing the need for cufon. Discussed here: Fabric.js + Google Fonts

    If you’re wanting to render a block, then some text inside of that block. I would do something like this.

    //Render the block
    var block = canvas.add(new fabric.Rect({ 
        left: 100, 
        top: 100, 
        fill: 'blue'
    }));
    
    //Render the text after the block (so that it is in front of the block)
    var text = canvas.add(new fabric.Text('I love fabricjs', { 
        left: block.left, //Take the block's position
        top: block.top, 
        fill: 'white'
    }));
    
    //Render the text and block on the canvas
    //This is to get the width and height of the text element
    canvas.renderAll(); 
    
    //Set the block to be the same width and height as the text with a bit of padding
    block.set({ width: text.width + 15, height: text.height + 10 });
    
    //Update the canvas to see the text and block positioned together, 
    //with the text neatly fitting inside the block
    canvas.renderAll();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the canvas.drawText() method to draw some text frame after frame.
alt text http://www.imagechicken.com/uploads/tn1270646423002339600.png I want to draw like that. How do I draw like
I want to draw a text with different colors and the only way that
In my application I used canvas to draw the text. now I want to
I have a Canvas that i draw text on. (this is quite advanced i
I use this example that allow me to draw into the canvas. http://devfiles.myopera.com/articles/649/example2.html However,
I need to draw some text on my Canvas, and I'd really avoid hardcoding
I want to create an ImageView and then draw text on top of the
I want to draw a text with 32 bit transparency on a graphics object.
I want to draw some lines and rectangles on a panel. Sometimes it does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.