Skip to content

bbox() returns zeros for text elems? #104

Open
@matehegedus

Description

@matehegedus

Hi,

I have the following problem, when I am using bbox()-es for some calculations, in my node.js environment it returns only zeros (although in web it works well)

this is my minimal reproduction:

 config.setFontDir("src/fonts/Roboto");
  config.setFontFamilyMappings({
    Roboto: "Roboto-Black.ttf",
    "sans-serif": "Roboto-Black.ttf",
    "Roboto-Bold": "Roboto-Bold.ttf",
  });
  config.preloadFonts();
  const window = createSVGWindow();
  const { document } = window;
  registerWindow(window, document);
  const draw = SVG(document.documentElement);

  draw.attr({
    width: 200,
    height: 200,
  });

  const group = draw.group().id(`txtGroup-example`);
  const textELem = group
    .text("label")
    .fill("red")
    .attr({
      x: 50,
      y: 50,
      "text-anchor": "middle",
      "dominant-baseline": "auto",
      transform: `rotate(${90},${50},${50})`,
      "font-size": `${16}px`,
      "font-family": `Roboto`,
    });

  const bbox = textELem.bbox();
  console.log("group :>> ", bbox); //every element inside bbox will be zero

Am I doing something wrong ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions