score:0

Indeed, getComputedTextLength() is ignoring the letter space.

You could try getBBox() instead:

textsElements.each(function(d){
  var el = d3.select(this);
  d.labelToLong= false;
if(( d.hiddenArcLength - this.getBBox().width) < 5) {
  el.style("opacity",0);
  d.labelToLong = true;
 }
}); 

Unfortunately, this will not help you because you are dealing with inclined paths, not a horizontal text. So, you can try to tweak getComputedTextLength with a given value, according to your kerning:

textsElements.each(function(d){
  var el = d3.select(this);
  var tweak = 1.2;//you can make this value >1 or <1, according to the kerning
  d.labelToLong= false;
if(( d.hiddenArcLength - this.getComputedTextLength()*tweak) < 5) {
  el.style("opacity",0);
  d.labelToLong = true;
 }
}); 

Related Query

More Query from same tag