# Cluster label is cut off when rendering with SVG

**URL:** <https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625>\
**Category:** Help\
**Created:** [May 26, 2023, 6:43pm UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625 "2023-05-26T18:43:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![centromere](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@centromere](https://forum.graphviz.org/u/centromere)\
**Post date:** [May 26, 2023, 6:43pm UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625/1 "2023-05-26T18:43:59Z")

</div>

The following dot code:

```auto
strict digraph cluster {
	graph [
		rankdir=LR,
	];
	subgraph "cluster_foo" {
		graph [
			bgcolor=forestgreen,
			label=<<B>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrs</B>>,
			style=bold,
		];
		"bar" [fillcolor=forestgreen,
			label="test",
			shape=box,
			style=filled,
		];
	}
}

```

renders the following image (`dot -Tsvg d -o foo.svg`):

 ![Screenshot 2023-05-26 at 14.42.51](https://global.discourse-cdn.com/graphviz/original/2X/2/2fe00b6b5580ceadfca60fe469c5f4c2868069e1.png)

Does anyone know why the “s” is cut off and how I can fix it?

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [May 26, 2023, 7:53pm UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625/2 "2023-05-26T19:53:49Z")

</div>

[Font problems are enough to drive people crazy, let’s hope that does not happen here]  
[Note, I am not encountering the problem of the cluster being to narrow. If anything, I am seeing cluster-too-wide.]  
The Font FAQ ([Font FAQ | Graphviz](https://www.graphviz.org/faq/font/)) will tell you lots about font problems.  
Here are some possible solutions to this specific problem - choose one:

- use `dot -Tsvg:cairo` ([Font FAQ | Graphviz](https://www.graphviz.org/faq/font/#what-about-svg-fonts))
- remove **style=bold,** It seems redundant with **\<B\>**
- use  
`fontname="Times-Bold"	label="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrs"`  
instead of  
label=\< **ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrs** \>,  
style=bold,
- add spaces to the end of your label text

Good luck

---

<div class="post-metadata">

**Author:** ![centromere](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@centromere](https://forum.graphviz.org/u/centromere)\
**Post date:** [May 26, 2023, 8:15pm UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625/3 "2023-05-26T20:15:53Z")

</div>

Thank you for the fast reply!

`style=bold` is not redundant, as this attribute is referring to the bounding box, not the font. Additionally, I only want part of the label to be bold, as I plan on adding additional detail to the label later.

I’ve confirmed that using `svg:cairo` fixes the issue, however I am not certain the extra overhead is worth it. Therefore, I think the only option left is for me to add additional spaces.

---

<div class="post-metadata">

**Author:** ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)\
**Post date:** [May 27, 2023, 12:21am UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625/4 "2023-05-27T00:21:25Z")

</div>

As Steve has alluded to, the problem is essentially that Graphviz’ native SVG renderer only does a limited estimation of text width. Answering “how wide is this text?” is a surprisingly complicated question. A full solution looks something like Cairo, which is why Graphviz has support for using that.

If you want to stick to using the core rendered but want more accurate estimations, the code that does it is here and we welcome improvements: [lib/common/textspan\_lut.c · main · graphviz / graphviz · GitLab](https://gitlab.com/graphviz/graphviz/-/blob/main/lib/common/textspan_lut.c)

---

<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:** [May 28, 2023, 10:41am UTC](https://forum.graphviz.org/t/cluster-label-is-cut-off-when-rendering-with-svg/1625/5 "2023-05-28T10:41:13Z")

</div>

Yes, this is good advice. Also, a start would be to confirm that Graphviz and the final renderer are loading the same font file. Graphviz prints the font binding when run with `-v`
