newText - make first letter Bigger and different color

Hi all, I have been trying to google how to format a single letter in a text string and so far I cannot find any solution

How is it possible to create a new text and have a different format on the first letter?

local animalName = newText (“Alligator”, display.contentCenterX, display,contentCenterY, native.systemFontBold, 50)

How can I get the “A” in a different size and different color? Example fontSize 90.

Hope someone advanced can help me! :slight_smile:

Corona SDK does not support formatting of text that way.  You would need to make your first letter as it’s own text object, then the rest of the text as necessary.

Rob

Corona SDK does not support formatting of text that way.  You would need to make your first letter as it’s own text object, then the rest of the text as necessary.

Rob

Small function i’ve made to accomplish that:

it still needs works, need to insert color params, at least, but i’ve to leave now so this is what i could make in 20m.

local randomText="Alligator" local function firstLetterBigger(textIn, paramsIn) local text=textIn local params=paramsIn or {} local group=display.newGroup() local flf=params.firstLetterFont or native.systemFontBold local flfs=params.firstLetterFontSize or 16 local font=params.font or native.systemFont local fontSize=params.fontSize or 1 local x=params.x or 0 -- x position of the text local y=params.y or 0 -- y positon of the text local top=params.top or 0 -- we need this variable because of the difference between the sizes of the first letter and the rest of the text local left=params.left or 0 -- the space from the first letter to the rest of the text local firstLetter=string.sub(text,1,1) local restText=string.sub(text,2,string.len(text)) local paramsFirstLetter={ text=firstLetter, font=flf, fontSize=flfs, x=x, y=y } local firstLetterScreen=display.newText(paramsFirstLetter) firstLetterScreen.anchorX=0 firstLetterScreen.anchorY=0 group:insert(firstLetterScreen) -------------------------------------- local paramsRestText={ text=restText, font=font, fontSize=fontSize, x=firstLetterScreen.x+firstLetterScreen.contentWidth+left, y=y+firstLetterScreen.contentHeight+top } local restTextScreen=display.newText(paramsRestText) restTextScreen.anchorX=0 restTextScreen.anchorY=1 group:insert(restTextScreen) return group end local text=firstLetterBigger(randomText,{firstLetterFont="Times New Roman",firstLetterFontSize=80,font="Times New Roman",fontSize=20,top=-14,left=0,x=0,y=0}) text.x=display.contentWidth\*.5 text.y=display.contentHeight\*.5

Small function i’ve made to accomplish that:

it still needs works, need to insert color params, at least, but i’ve to leave now so this is what i could make in 20m.

local randomText="Alligator" local function firstLetterBigger(textIn, paramsIn) local text=textIn local params=paramsIn or {} local group=display.newGroup() local flf=params.firstLetterFont or native.systemFontBold local flfs=params.firstLetterFontSize or 16 local font=params.font or native.systemFont local fontSize=params.fontSize or 1 local x=params.x or 0 -- x position of the text local y=params.y or 0 -- y positon of the text local top=params.top or 0 -- we need this variable because of the difference between the sizes of the first letter and the rest of the text local left=params.left or 0 -- the space from the first letter to the rest of the text local firstLetter=string.sub(text,1,1) local restText=string.sub(text,2,string.len(text)) local paramsFirstLetter={ text=firstLetter, font=flf, fontSize=flfs, x=x, y=y } local firstLetterScreen=display.newText(paramsFirstLetter) firstLetterScreen.anchorX=0 firstLetterScreen.anchorY=0 group:insert(firstLetterScreen) -------------------------------------- local paramsRestText={ text=restText, font=font, fontSize=fontSize, x=firstLetterScreen.x+firstLetterScreen.contentWidth+left, y=y+firstLetterScreen.contentHeight+top } local restTextScreen=display.newText(paramsRestText) restTextScreen.anchorX=0 restTextScreen.anchorY=1 group:insert(restTextScreen) return group end local text=firstLetterBigger(randomText,{firstLetterFont="Times New Roman",firstLetterFontSize=80,font="Times New Roman",fontSize=20,top=-14,left=0,x=0,y=0}) text.x=display.contentWidth\*.5 text.y=display.contentHeight\*.5