diff --git a/composer.json b/composer.json
index 97000e6..b371ef0 100644
--- a/composer.json
+++ b/composer.json
@@ -35,6 +35,7 @@
"php": "^8.1",
"ext-gd": "*",
"ext-simplexml": "*",
+ "cybercog/php-svg-font": "^1.0",
"kartsims/easysvg": "^2.5",
"symfony/console": "^5.0 || ^6.0 || ^7.0"
},
diff --git a/spec/PUGX/Poser/Calculator/GDTextSizeCalculatorSpec.php b/spec/PUGX/Poser/Calculator/GDTextSizeCalculatorSpec.php
new file mode 100644
index 0000000..64e1127
--- /dev/null
+++ b/spec/PUGX/Poser/Calculator/GDTextSizeCalculatorSpec.php
@@ -0,0 +1,15 @@
+calculateWidth('MIT', 8)->shouldBeLike(24.0);
+ $this->calculateWidth('MIT', 10)->shouldBeLike(29.0);
+ $this->calculateWidth('MIT', 14)->shouldBeLike(34.0);
+ }
+}
diff --git a/spec/PUGX/Poser/Calculator/SvgTextSizeCalculatorSpec.php b/spec/PUGX/Poser/Calculator/SvgTextSizeCalculatorSpec.php
new file mode 100644
index 0000000..7930d3b
--- /dev/null
+++ b/spec/PUGX/Poser/Calculator/SvgTextSizeCalculatorSpec.php
@@ -0,0 +1,15 @@
+calculateWidth('MIT', 8)->shouldBeLike(24.1);
+ $this->calculateWidth('MIT', 10)->shouldBeLike(27.7);
+ $this->calculateWidth('MIT', 14)->shouldBeLike(34.8);
+ }
+}
diff --git a/src/Calculator/Font/DejaVuSans.svg b/src/Calculator/Font/DejaVuSans.svg
new file mode 100644
index 0000000..984b0ac
--- /dev/null
+++ b/src/Calculator/Font/DejaVuSans.svg
@@ -0,0 +1,251 @@
+
+
+
diff --git a/src/Calculator/SvgTextSizeCalculator.php b/src/Calculator/SvgTextSizeCalculator.php
new file mode 100644
index 0000000..887fa3c
--- /dev/null
+++ b/src/Calculator/SvgTextSizeCalculator.php
@@ -0,0 +1,41 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace PUGX\Poser\Calculator;
+
+use Cog\SvgFont\FontList;
+use Cog\Unicode\UnicodeString;
+
+/**
+ * @author Anton Komarev
+ */
+class SvgTextSizeCalculator implements TextSizeCalculatorInterface
+{
+ /**
+ * Calculate the width of the text box.
+ */
+ public function calculateWidth(string $text, int $size = self::TEXT_SIZE): float
+ {
+ $font = FontList::ofFile(__DIR__ . '/Font/DejaVuSans.svg')->getById('DejaVuSansBook');
+
+ $letterSpacing = 0.0;
+
+ $width = $font->computeStringWidth(
+ UnicodeString::of($text),
+ $size,
+ $letterSpacing,
+ );
+
+ $shieldPaddingX = self::SHIELD_PADDING_EXTERNAL + self::SHIELD_PADDING_INTERNAL;
+
+ return \round($width + $shieldPaddingX, 1);
+ }
+}