[TIMOB-1667] Changing label view's font.fontSize property after view is rendered has no effect.

GitHub Issuen/a
Resolution Date2011-04-15T02:58:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
Labelseventlistener, font, fontsize, label
AssigneeReggie Seagraves


Environment: Titanium Developer 1.40 and iPhone Simulator (iphone and iphone4). Also tested on iPhone4 device with same results.

Issue: Changing the fontSize property of a label after label is rendered has no effect. The following code does not work.

Example code: (notice 2 methods for defining new font size - neither work)

var w = Ti.UI.createWindow({backgroundColor:'#fff'});
var b = Ti.UI.createButton({
   title:'Click Me',
var lab = Ti.UI.createLabel({
   text: 'test',
   top: 150,
   height: 140,
   width: 300,
   color: '#c00',
   backgroundColor: '#ccc'


b.addEventListener('click', function() {
   lab.font = '{fontSize:100}'; 
  // lab.font.fontSize = 100; // this also doesn't work



  1. Brion Vibber 2011-04-15

    This should work as a workaround (it's what I've been doing, works for me on both Android and iPhone):

    lab.font = {fontSize:100};

    I think the reason the initial attempt to just assign lab.font.fontSize directly doesn't work is that the 'font' property is implemented with getters/setters that just take and return plain JSON-style objects.

    So 'lab.font' returns a plain old object which has no inherent connection back to 'lab'; changing its contents only changes the new object, and doesn't ever reach the original.

    This could probably be made to work as expected if the font property's getter returned a proxy object, which itself would have getters/setters to handle sending through the subproperties.

  2. Brion Vibber 2011-04-15

    Since we encountered this same issue while working on StatusNet Mobile, I'm assigning this to our support contact. Nolan, can you make sure it's reassigned to the appropriate people for iPhone and Android implementations? We've used the above workaround, but clearly other people are encountering the same problem... if it can't be fixed easily, could the workaround be added to API documentation perhaps?


  3. Nolan Wright 2011-04-15

    it's working as designed. Our properties use getters/setters, so there is no support for property nesting. The font property takes an object as a value, so this:

    label.font = {fontSize:20};

    is the proper way to change the value.


  4. Brion Vibber 2011-04-15

    Nolan, any comment on the feasibility of my suggested implementation for property nesting?

    Or is there a deliberate choice to not implement property nesting? If so, this should be very clearly documented; most JavaScript developers will probably be coming from web development and will be used to nested properties like 'div.style.fontSize = 100'.

  5. k00k 2011-04-15

    Thanks for the clarification Nolan. I see I was mistakenly wrapping the object in ''. I agree on needing better documentation. I also realize you guys are busy. Time to get a few interns :)

  6. Stephen Tramer 2011-04-15

    Nolan should have invalidated.

  7. Lee Morris 2017-03-09 Closing ticket as invalid.

JSON Source