Difference between revisions of "FontBase Constants"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> '''Defined by:''' FontBase<br/> ==== FontBase Constants ==== *FontBase.TLF_BOTTOM *FontBase.TLF_BREAKWORDS *FontBase....")
 
Line 4: Line 4:
  
 
==== FontBase Constants ====
 
==== FontBase Constants ====
*FontBase.TLF_BOTTOM
+
*'''FontBase.TLF_BOTTOM''' ''align text to the bottom''
*FontBase.TLF_BREAKWORDS
+
*'''FontBase.TLF_BREAKWORDS''' ''allow Gideros to break words that exceed required width''
*FontBase.TLF_CENTER
+
*'''FontBase.TLF_CENTER''' ''center text horizontally''
*FontBase.TLF_JUSTIFIED
+
*'''FontBase.TLF_JUSTIFIED''' ''justify text horizontally''
*FontBase.TLF_LEFT
+
*'''FontBase.TLF_LEFT''' ''align text to the left''
*FontBase.TLF_LTR
+
*'''FontBase.TLF_LTR''' ''left to right text''
*FontBase.TLF_NOBIDI
+
*'''FontBase.TLF_NOBIDI''' ''non bi-directional text''
*FontBase.TLF_NOSHAPING
+
*'''FontBase.TLF_NOSHAPING''' ''turn off HarfBuzz shaping''
*FontBase.TLF_NOWRAP
+
*'''FontBase.TLF_NOWRAP''' ''don't wrap long lines''
*FontBase.TLF_REF_ASCENT
+
*'''FontBase.TLF_REF_ASCENT''' ''use ascent of line as reference''
*FontBase.TLF_REF_BASELINE
+
*'''FontBase.TLF_REF_BASELINE''' ''use baseline as reference (default)''
*FontBase.TLF_REF_BOTTOM
+
*'''FontBase.TLF_REF_BOTTOM''' ''use bottom of line as reference''
*FontBase.TLF_REF_DESCENT
+
*'''FontBase.TLF_REF_DESCENT''' ''use descent of line as reference''
*FontBase.TLF_REF_LINETOP
+
*'''FontBase.TLF_REF_LINETOP''' ''use top of a line of text of that font, irrespective of the text actually displaying''
*FontBase.TLF_REF_MEDIAN
+
*'''FontBase.TLF_REF_MEDIAN''' ''use median of line as reference''
*FontBase.TLF_REF_MIDDLE
+
*'''FontBase.TLF_REF_MIDDLE''' ''use middle of line as reference''
*FontBase.TLF_REF_TOP
+
*'''FontBase.TLF_REF_TOP''' ''use top of line as reference''
*FontBase.TLF_RIGHT
+
*'''FontBase.TLF_RIGHT''' ''align text to the right''
*FontBase.TLF_RTL
+
*'''FontBase.TLF_RTL''' ''align text right to left''
*FontBase.TLF_TOP
+
*'''FontBase.TLF_TOP''' ''align text to the top''
*FontBase.TLF_VCENTER
+
*'''FontBase.TLF_VCENTER''' ''center text vertically''
  
 
=== Example ===
 
=== Example ===

Revision as of 18:24, 17 November 2023

Available since: Gideros 2011.6
Defined by: FontBase

FontBase Constants

  • FontBase.TLF_BOTTOM align text to the bottom
  • FontBase.TLF_BREAKWORDS allow Gideros to break words that exceed required width
  • FontBase.TLF_CENTER center text horizontally
  • FontBase.TLF_JUSTIFIED justify text horizontally
  • FontBase.TLF_LEFT align text to the left
  • FontBase.TLF_LTR left to right text
  • FontBase.TLF_NOBIDI non bi-directional text
  • FontBase.TLF_NOSHAPING turn off HarfBuzz shaping
  • FontBase.TLF_NOWRAP don't wrap long lines
  • FontBase.TLF_REF_ASCENT use ascent of line as reference
  • FontBase.TLF_REF_BASELINE use baseline as reference (default)
  • FontBase.TLF_REF_BOTTOM use bottom of line as reference
  • FontBase.TLF_REF_DESCENT use descent of line as reference
  • FontBase.TLF_REF_LINETOP use top of a line of text of that font, irrespective of the text actually displaying
  • FontBase.TLF_REF_MEDIAN use median of line as reference
  • FontBase.TLF_REF_MIDDLE use middle of line as reference
  • FontBase.TLF_REF_TOP use top of line as reference
  • FontBase.TLF_RIGHT align text to the right
  • FontBase.TLF_RTL align text right to left
  • FontBase.TLF_TOP align text to the top
  • FontBase.TLF_VCENTER center text vertically

Example

Text wrap

application:setBackgroundColor(0x6c6c6c)

-- some vars
local width = application:getContentWidth()
local height = application:getContentHeight()

local mystring = [[
Some very long text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor,
dignissim sit amet, adipiscing nec, ultricies sed, dolor.
xxxxxxxxxxxxxxxxxxxxxTLF_BREAKWORDSxxxxxxxxxxxxxxxxxxxxxxxxTLF_BREAKWORDSxxxxxxxxxxxxxxxxxxxxxxxxTLF_BREAKWORDS,
Some very long text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor,
dignissim sit amet, adipiscing nec, ultricies sed, dolor.
Some very long text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor,
dignissim sit amet, adipiscing nec, ultricies sed, dolor.
]]
local textfield = TextField.new(nil, mystring)
textfield:setSample(mystring)
textfield:setLayout( {w=width/3, h=height/2, lineSpacing=2, flags=FontBase.TLF_CENTER|FontBase.TLF_BREAKWORDS} )
textfield:setScale(2)
textfield:setPosition(8, 8)
stage:addChild(textfield)