Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9160] Android: Font sizing should obey the ti.ui.defaultunit setting in tiapp.xml

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-08T20:58:14.000+0000
Affected Version/sRelease 2.1.0, Release 2.0.1
Fix Version/sRelease 3.0.0, Sprint 2012-20 Core, 2012 Sprint 20
ComponentsAndroid
Labelscore, module_android, parity, qe-manualtest
ReporterTim Poulsen
AssigneeBill Dawson
Created2012-05-16T17:36:43.000+0000
Updated2014-08-08T22:01:47.000+0000

Description

Expected results:

I can set the ti.ui.defaultunit property in tiapp.xml to 'dip' and have font sizes respect that setting.

Actual results:

I can explicitly set fontSize='14dip' and text will be sized appropriately. But setting the default unit in tiapp.xml and setting fontSize=14 gives px based font sizing. See the attached screen: dip is included in the tiapp.xml file, the field labels (URL, Username, etc.) are set with fontSize=## whereas the contents of the first text field is set with fontSize='14dip' Tested on my Galaxy Nexus running ICS/4.0.2. I'm using the https://github.com/gshipley/BeerShift application featured in the developer blog.

Attachments

FileDateSize
app.js2012-10-04T12:16:33.000+00001845
device-2012-05-16-173228.png2012-05-16T17:37:32.000+000052576

Comments

  1. Kevin Whinnery 2012-09-06

    +1
  2. Bill Dawson 2012-10-04

    Fail case / Test case

    **Note**: Need a high density device to test with (that's basically any device these days) or an emulator such as WVGA854.

    Create a new mobile project, leave the ti.ui.defaultunit setting in tiapp.xml at "system".

    Replace the app.js with the code from below.

    Run the app. The text is crazy small.

    Change the ti.ui.defaultunit setting in tiapp.xml to "dip".

    Run the app again. In the fail case, the text is still crazy small. When testing the fix, the text should have grown up.

    Notes: TextArea (another control that supports "font") uses the same view as TextField, so I haven't bothered to add it here. Anyways, all of our controls that support "font" use the exact same method in Java to style the text: TiUIHelper.styleText. Here's that app.js (I've also attached it since it's kinda long):
       Ti.UI.backgroundColor = "#fff";
       var win = Titanium.UI.createWindow({  
           title:'Test',
           backgroundColor:'#fff',
       	exitOnClose: true,
       	orientationModes: [Ti.UI.PORTRAIT]
       }),
       logLabel = Ti.UI.createLabel({
       	bottom: "8dp", left: "8dp", right: "8dp", height: "192dp",
       	backgroundColor: "black", color: "white",
       	font: {fontSize: 12},
       	verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP
       }),
       log = function(s, clearFirst) {
       	var current = logLabel.text;
       	if (current && !clearFirst) {
       		current += "\n";
       	} else {
       		current = "";
       	}
       	current += s;
       	logLabel.text = current;
       },
       button = Ti.UI.createButton({
       	left: "8dp", right: "8dp", top: "8dp", height: "48dp",
       	title: "A long-titled button",
       	font: {fontSize: 12}
       }),
       textField = Ti.UI.createTextField({
       	hintText: "A long-hinted text field",
       	left: "8dp", right: "8dp", top: "64dp", height: "48dp",
       	font: {fontSize: 12}
       }),
       activityIndicator = Ti.UI.createActivityIndicator({
       	style: Titanium.UI.ActivityIndicatorStyle.BIG_DARK,
       	message: "An activity indicator, dear friends.",
       	font: {fontSize: 12}, top: "120dp", left: "8dp",
       	right: "8dp", height: "96dp"
       });
       
       win.add(logLabel);
       win.add(textField);
       win.add(button);
       win.add(activityIndicator);
       
       log("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sem mauris, fringilla sed condimentum ac, tempor quis justo. Praesent vel volutpat arcu. Fusce porttitor condimentum consectetur. Suspendisse potenti. Integer pellentesque blandit ullamcorper. Ut tincidunt ante sit amet lorem scelerisque vitae rutrum turpis placerat. Integer massa odio, bibendum eu molestie et, ornare non purus. Nullam accumsan neque id sapien ornare hendrerit. Etiam lacinia diam eget ligula dictum feugiat. Sed malesuada justo vel mi luctus tempor. Proin eu porta arcu.");
       
       win.addEventListener("open", function() {activityIndicator.show();});
       win.open();
       
  3. Bill Dawson 2012-10-04

    PR ready: https://github.com/appcelerator/titanium_mobile/pull/3108
  4. Lokesh Choudhary 2012-12-06

    Verified the issue is no more occurring. Changing to 'dip' increased int font size. Titanium studio : 3.0.0.201211301903 SDK Version : 3.0.0.v20121204154658 CLI version : 3.0.19 OS : OSX 10.8.2 Android : 4.0.4 Samsung S3

JSON Source