Intervention/image Change text size/font mid-phrase
<p>I've got this image where I want to put right-aligned text, but the text is formed as follow :</p>

<ul>
<li>a label, very small in size, with a fixed content</li>
<li>a value, which can change in length (an integer between 0 and 100)</li>
</ul>

<p>For the moment, i managed to make two <code>text</code> calls, but when the value lengths changes, the two texs overlap.</p>

<p>Is there a way to tell intervention/image to change font &amp; size mid-phrase ? Or is my approach the bad one ?</p>

<p>Edit #1:</p>

<p>My current code :</p>

<pre><code>&lt;?php
/**
 * StackOverflow test
 *
 * @param  int                  $int
 * @return Intervention\Image
 */
public function stackOverflow($int)
{
    $img = Image::canvas(200, 50, '#FF0000');

    $img-&gt;text('Label', 130, 30, function ($font) {
        $font-&gt;file(resource_path('assets/fonts/futura-medium.ttf'));
        $font-&gt;size(18);
    });

    $img-&gt;text($int, 190, 30, function ($font) {
        $font-&gt;file(resource_path('assets/fonts/futura-medium.ttf'));
        $font-&gt;size(30);
        $font-&gt;align('right');
    });

    return $img-&gt;response('png');
}
</code></pre>

<p>With a $int parameter of 10, the display is correct :</p>

<p><a href="https://i.stack.imgur.com/yvYMe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yvYMe.png" alt="Two-digit int is okay"></a></p>

<p>When the $int parameter exceeds 99, the number overlaps the label :</p>

<p><a href="https://i.stack.imgur.com/kZsig.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kZsig.png" alt="With a three-digit number, it overlaps the label"></a></p>

<p>And whe the $int parameter is below 10, the label is too far away from its value :</p>

<p><a href="https://i.stack.imgur.com/0ZoFf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ZoFf.png" alt="enter image description here"></a></p>

<p>I'd want to find a way to keep the label at the same distance of the integer value (Maybe by knowing the integer width after display ?)</p>

<p>Edit #2</p>

<p>Checking the string length would be a workaround, but as I work with non fixed-width font, the results are still inconsistent :</p>

<p><a href="https://i.stack.imgur.com/LFydw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LFydw.png" alt="With narrow numbers, the label is far from them"></a></p>

<p><a href="https://i.stack.imgur.com/DsRr0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DsRr0.png" alt="With wide numbers, the label is very near"></a></p>