# Unwanted space around html font tags

**URL:** https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460
**Category:** Help
**Created:** [November 26, 2020, 12:01pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460 "2020-11-26T12:01:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![robinm](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/robinm/32/274_2.png) [@robinm](https://forum.graphviz.org/u/robinm)
#### Post date: [November 26, 2020, 12:01pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/1 "2020-11-26T12:01:22Z")

</div>

Hello 🙂

```auto
digraph {
   node [shape=none]
   color=none

   main [
       label=<<font color='red'>main</font>( _1: <font color='darkgreen'>impl Fn()</font>, _2: <font color='darkgreen'>usize</font> )>
   ]
}

```

When using `dot -Txlib my_graph.dot` I got exactly the output I want (I’m not including the image because of the beginner limitation).

But when using `dot -Tsvg my_graph.dot > my_graph.svg`, there is extra spacing around the font labels (it’s especially visible before the parenthesis and the comma). Do you know how I could remove them?  
 ![my_graph](https://global.discourse-cdn.com/graphviz/original/1X/299b654522b61c9dbe5444abae8f350459d2032f.svg)

---

<div class="post-metadata">

### Author: ![robinm](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/robinm/32/274_2.png) [@robinm](https://forum.graphviz.org/u/robinm)
#### Post date: [November 26, 2020, 12:02pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/2 "2020-11-26T12:02:02Z")

</div>

The output of `dot -Txlib`

![image](https://global.discourse-cdn.com/graphviz/original/1X/4c58d1e6a8d82ed4ec546ed9fe4f3470e0dc8d68.png)

---

<div class="post-metadata">

### Author: ![magjac](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/magjac/32/16_2.png) [@magjac](https://forum.graphviz.org/u/magjac)
#### Post date: [November 26, 2020, 9:45pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/3 "2020-11-26T21:45:31Z")

</div>

> I’m not including the image because of the beginner limitation

You don’t have to upload your SVG images. You can render them inline in this forum directly using only DOT source code as described in [Render Graphviz graphs directly in your posts](https://forum.graphviz.org/t/render-graphviz-graphs-directly-in-your-posts/125).

Here is your graph rendered just like that.

[dot verbose=true]

```auto
digraph {
   node [shape=none]
   color=none

   main [
       label=<<font color='red'>main</font>( _1: <font color='darkgreen'>impl Fn()</font>, _2: <font color='darkgreen'>usize</font> )>
   ]
}

```

[/dot]

From what I can see there’s no extra spaces. Maybe you are using an old version of Graphviz?

---

<div class="post-metadata">

### Author: ![robinm](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/robinm/32/274_2.png) [@robinm](https://forum.graphviz.org/u/robinm)
#### Post date: [November 26, 2020, 10:45pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/4 "2020-11-26T22:45:50Z")

</div>

```auto
$ dot -V
dot - graphviz version 2.44.1

```

The inline rendering is very nice indeed. The output you got is the same than what I get with `dot -Txlib` as you can see in the second post. However, you can see in the image in the first post that there are extra spaces between `main` and the opening parenthesis, as well as between `Fn()` and the comma, and between `usize` and the closing parenthesis.

---

<div class="post-metadata">

### Author: ![magjac](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/magjac/32/16_2.png) [@magjac](https://forum.graphviz.org/u/magjac)
#### Post date: [November 28, 2020, 4:09pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/5 "2020-11-28T16:09:17Z")

</div>

I can reproduce your problem with `dot - graphviz version 2.44.2~dev.20201126.1914 (20201126.1914)` when using `-Tsvg`, but not with `-Tpng`. I suggest you report it as an issue at [https://gitlab.com/graphviz/graphviz/-/issues/new](https://gitlab.com/graphviz/graphviz/-/issues/new)

---

<div class="post-metadata">

### Author: ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)
#### Post date: [November 29, 2020, 12:41pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/6 "2020-11-29T12:41:41Z")

</div>

We’ve talked about this kind of problem several times before. If results differ between -Tsvg and -Tpng, then the problem is usually that SVG generated by the Graphviz default SVG driver is underspecified. If fonts are not embedded in SVG, there’s really no way of knowing if graphviz and the downstream renderer are loading the same font for “Times-Roman”. So, use -Tsvg:cairo (or -Tsvg:quartz on a Mac) to get embedded fonts. The SVG is much more complicated but also much more likely to render the same everywhere. This problem is a little like noticing that web pages can sometimes look different in Microsoft Edge, Safari, Firefox or Chrome.

The sizing and layout of text in Graphviz doesn’t depend on the selection of output renderer. (Depending how graphviz was built, the preference is still to use cairopango at layout time to resolve fonts and to get the size of text, but if not available Graphviz could fall back to freetype/fontconfig/libgd. Run with -v to see what is happening.) An advantage of the simple SVG driver is that the output is more easily parsable by downstream tools, and we were able to implement features not in the cairopango API.

---

<div class="post-metadata">

### Author: ![robinm](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/robinm/32/274_2.png) [@robinm](https://forum.graphviz.org/u/robinm)
#### Post date: [November 29, 2020, 5:02pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/7 "2020-11-29T17:02:38Z")

</div>

I forgot to add a link when I created the [bug report](https://gitlab.com/graphviz/graphviz/-/issues/1891).

---

<div class="post-metadata">

### Author: ![robinm](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/robinm/32/274_2.png) [@robinm](https://forum.graphviz.org/u/robinm)
#### Post date: [November 29, 2020, 5:08pm UTC](https://forum.graphviz.org/t/unwanted-space-around-html-font-tags/460/8 "2020-11-29T17:08:15Z")

</div>

Thanks, using `dot -Tsvg:cairo` totally solved the issue. And the rationals make sense.
