on SOME devices my text is too large
Posted on Mon, 2013-01-21 14:05
My text is showing up in different sizes. On most devices it fits perfectly. On some (this screen is from the iPhone 4s) it seems a little large. What do I do?
anyone have a quick fix for this? help!
here is an image:
http://www.questlord.com/screenshots/TextTooBig.jpg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | local ui = require("ui") ------------------------------------------- -- General event handler for fields ------------------------------------------- -- You could also assign different handlers for each textfield local defaultField local fields = display.newGroup() local function fieldHandler( event ) if ( "began" == event.phase ) then -- This is the "keyboard has appeared" event -- In some cases you may want to adjust the interface when the keyboard appears. elseif ( "ended" == event.phase ) then -- This event is called when the user stops editing a field: for example, when they touch a different field elseif ( "submitted" == event.phase ) then -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard -- Hide keyboard playerName = defaultField.text fields:removeSelf() verifyName() end end -- Predefine local objects for use later ------------------------------------------- -- *** Buttons Presses *** ------------------------------------------- -- Default Button Pressed --defaultField:removeSelf() -- fields:remove( defaultField ) -- Number Button Pressed ------------------------------------------ -- *** Create native input textfields *** ------------------------------------------- -- Note: currently this feature works in device builds or Xcode simulator builds only -- Note: currently this feature works in device builds only local isAndroid = "Android" == system.getInfo("platformName") local inputFontSize = 18 local inputFontHeight = 30 if isAndroid then -- Android text fields have more chrome. It's either make them bigger, or make the font smaller. -- We'll do both inputFontSize = 14 inputFontHeight = 42 end defaultField = native.newTextField( 10, 120, 300, 30, fieldHandler ) -- o:addEventListener( 'userInput', listener ) -- WARNING: The 'listener' argument to native.newTextField( left, top, width, height [, listener] ) is deprecated. Call the object method o:addEventListener( 'userInput', listener ) instead. defaultField.font = native.newFont( "Quadrat Serial", inputFontSize / display.contentScaleX ) defaultField.align = "center" -- Add fields to our new group fields:insert(defaultField) native.setKeyboardFocus( defaultField ) local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight ) bkgd:setFillColor( 0, 0, 0, 0 ) -- set Alpha = 0 so it doesn't cover up our buttons/fields end |
Does this have to do with the issue of text not aligning right on -some ios- devices when not using exact coords?

No, it has to do with native fonts not scaling like images and display.newText does. A 20 point font on a 3GS will be much larger than a 20 point native font on a Retina iPad, but it looks like you're trying to scale it. Look for setting your font size like this:
http://docs.coronalabs.com/api/type/TextField/size.html