How do I align a multiline text inside an image?

I’m working on creating a visual novel engine. But, I’m having some problems with trying to align the text inside of an image. Any help would be appreciated.

local dialoguebox
t.drawdbox = function()
  dialoguebox = display.newImageRect( “images/dialogue.png”, 1000, 200)
  dialoguebox.x = display.contentCenterX
  dialoguebox.y = display.contentHeight - dialoguebox.height/2
  print(dialoguebox.y)
  return dialoguebox
end

t.drawtext = function(dialoguebox)
  local options =
  {
    text = “This is a test.”,
    anchorX = 0,
    anchorY = 1,
    y = dialoguebox.y - dialoguebox.height/2,
    x = 0,
    width = 120,     --required for multi-line and alignment
    font = native.systemFont,
    fontSize = 32
  }
  print(options.y)
  local text = display.newText(options)
  text:setFillColor(0.2,0.2,0.8)
  return text
end

This is what I have but for some reason the actual text is slightly higher then the dialoguebox.

You’re not setting a height on the text, so it will not clip based on height.  But even then with a 32 point font, and the the text you have, I can’t see that being much over a couple of lines which shouldn’t be anywhere near your 200px high image .

Thanks. I figured out that the problem was that the anchor points can’t be set in options. Once I set them to 0 after the instantiation of newtext it worked.

You’re not setting a height on the text, so it will not clip based on height.  But even then with a 32 point font, and the the text you have, I can’t see that being much over a couple of lines which shouldn’t be anywhere near your 200px high image .

Thanks. I figured out that the problem was that the anchor points can’t be set in options. Once I set them to 0 after the instantiation of newtext it worked.