What is the definition of size in native.newFont()

Hi

According the explain for font size from docs for native.newFont() is :

=================================================================================
size (optional)
Number. The point size of the font to use. By default, it will be the standard system font size of the device.

My question is :

What is the definition of point size of the font to use ? Point size is pixels in inch ? or screen resolution ?

I need this information to select proper font size for different mobile screen.

The native.newfont() document link:

http://docs.coronalabs.com/legacy/api/library/native/newFont.html

Thanks.

The point size that you feed this function will be *scaled* if your app is set up to use content scaling such as “letterbox”, “zoomEvent”, or “zoomStretch”.  So, what I recommend that you do is choose a point size that looks to be the appropriate size in the Corona Simulator.  Your text will then be roughly the same size on all other devices of various screen resolutions.  I say roughly because it’s always going to vary slightly between different DPIs (this is an issue everyone has including Apple, Google, and Microsoft).  You can improve the text size accuracy between different devices/platforms by using your own custom font.  Or for near perfect text rendering scaling accuracy, use bitmap font via sprite sheets, which is how the AAA game studios do it.

Regarding the default font point size of the system, that will vary between devices.  In fact, it varies wildly on Android devices.  The default point size is set by the manufacturer and depends on the DPI of the display.  Manufacturers typically set the default point size to something so that the rendered text is roughly the same physical size (in inches) between devices.  This way the resulting text is readable to the end-user between low/high resolution displays.

Does this help?

Hi

Could you explain more the fontsize difference between display.newText and native.newFont() ? If we want to get same display result in display.newText and native.newFont(), how can we do that ?

Thanks,

You would only use the native.newFont() function if you want to *change* the font type/style/size of an existing text object or the font of a native object (TextField/TextBox).  This is rarely used by Corona developers though because you would typically set the font when you initially create the text object via the display.newText() function.

   http://docs.coronalabs.com/api/library/display/newText.html

   http://docs.coronalabs.com/api/library/native/newFont.html

The key thing here is that display.newText() create a bitmap which has text rendered to it.  The native.newFont() just creates font settings that you can pass to other objects.  You can pass in the same font settings into display.newText() as you can into native.newFont(), so there is really no point in calling native.newFont() unless you want to change an existing text object’s rendered font.

The point size that you feed this function will be *scaled* if your app is set up to use content scaling such as “letterbox”, “zoomEvent”, or “zoomStretch”.  So, what I recommend that you do is choose a point size that looks to be the appropriate size in the Corona Simulator.  Your text will then be roughly the same size on all other devices of various screen resolutions.  I say roughly because it’s always going to vary slightly between different DPIs (this is an issue everyone has including Apple, Google, and Microsoft).  You can improve the text size accuracy between different devices/platforms by using your own custom font.  Or for near perfect text rendering scaling accuracy, use bitmap font via sprite sheets, which is how the AAA game studios do it.

Regarding the default font point size of the system, that will vary between devices.  In fact, it varies wildly on Android devices.  The default point size is set by the manufacturer and depends on the DPI of the display.  Manufacturers typically set the default point size to something so that the rendered text is roughly the same physical size (in inches) between devices.  This way the resulting text is readable to the end-user between low/high resolution displays.

Does this help?

Hi

Could you explain more the fontsize difference between display.newText and native.newFont() ? If we want to get same display result in display.newText and native.newFont(), how can we do that ?

Thanks,

You would only use the native.newFont() function if you want to *change* the font type/style/size of an existing text object or the font of a native object (TextField/TextBox).  This is rarely used by Corona developers though because you would typically set the font when you initially create the text object via the display.newText() function.

   http://docs.coronalabs.com/api/library/display/newText.html

   http://docs.coronalabs.com/api/library/native/newFont.html

The key thing here is that display.newText() create a bitmap which has text rendered to it.  The native.newFont() just creates font settings that you can pass to other objects.  You can pass in the same font settings into display.newText() as you can into native.newFont(), so there is really no point in calling native.newFont() unless you want to change an existing text object’s rendered font.