Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to curve / arc text using CSS3 / Canvas

I'm trying to make a curved text effect using CSS3, HTML Canvas, or even SVG (see image below for example)? Is this possible? If so, how can I achieve this effect?

Update: To clarify: The text that will be styled this way will be dynamic.

Arched or Curved Text Example

like image 892
gabriel Avatar asked May 15 '10 16:05

gabriel


People also ask

How do you make text curve in CSS?

Here we just write the characters of a text one by one and start applying the CSS transform properties to make the whole text look curved (or shaped like an arc). However, one advantage of this method is that you can select the text and even perform copy-paste.

How do I curve text in HTML5?

Curving text using Canvas: The canvas element is part of HTML5 and allows for dynamic, scriptable rendering of 2D shapes and bitmap images. This is a relatively easier method to curve text using a bit of JavaScript for manipulating the canvas element and styling it.

How to draw a curved line in an SVG file?

Imagine we draw a curved line in SVG and give it an ID called curve. Then, we drop content into the SVG using the <text> tag and give it a width that matches the SVG viewBox dimensions.

Is it possible to apply inline CSS to SVG?

We could also do this in CSS, but we’re applying it inline directly in the SVG markup for the sake of this example. The rest is CSS!


1 Answers

SVG supports text-on-a-path directly, though it does not 'bend' the individual glyphs along the path. Here's an example of how you create it:

... <defs>   <path id="textPath" d="M10 50 C10 0 90 0 90 50"/> </defs> <text fill="red">   <textPath xlink:href="#textPath">Text on a Path</textPath> </text> ... 
like image 92
Phrogz Avatar answered Sep 19 '22 21:09

Phrogz