How to use variable in closure functions in php?

I am using intervention for php for image manipulations.
Is it possible to apply font size and color to text through a variable like this?
I have calculated $fontsize and $color above this but it says undefined variable