BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links



Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
rab1 Offline
Knows Where the Search Button Is
 
Posts: 24
Join Date: Jul 2007
Model: 8300
PIN: N/A
Carrier: AT&T
Default Font scaling - 07-23-2008, 04:52 PM

I am trying to use the font API:

public Font derive(int style, int height, int units, int antialiasMode,
int effects, int[] transform)


To derive a font that is translated and scaled using the transform as shown in the following code:


String strText ="Centered Rich TEXT, multiple fonts";
Font fonts[] = new Font[5];
int one = Fixed32.toFP(1);
int two = Fixed32.toFP(2);
int n = one/2;
int m = two/3 ;

fonts[0] = Font.getDefault();
fonts[1] = Font.getDefault().derive(Font.BOLD,10,Ui.UNITS_px) ;
fonts[2] = Font.getDefault().derive(Font.BOLD | Font.ITALIC,30);
fonts[3] = Font.getDefault().derive(Font.PLAIN,10,Ui.UNITS_px );

int[] transform = new int[] { one,0,0,one,n,n };
fonts[4] = Font.getDefault().derive(Font.PLAIN,10,Ui.UNITS_px ,1,0,transform);

int offset[] = new int[5];
byte attributes[] = new byte[4];

attributes[0] = 1;//bold
attributes[1] = 3; //Plain, 10
attributes[2] = 4; //translated
attributes[3] = 2; //bold italic 30

offset[0] = 0;
offset[1] = 9;
offset[2] = 13;
offset[3] = 18;
offset[4] = strText.length();


RichTextField rtf = new RichTextField(strText,offset,attributes,fonts, RichTextField.TEXT_ALIGN_HCENTER|RichTextField.NON _FOCUSABLE);


.... etc..



I would expect the word "TEXT" to display at some offset compared to the rest of the text.

The idea here is to use the transform to translate by 1/2 and scale by 2/3. This transformation will display the text as superscript. In the example above I am not scaling as this may not find the font and the derive will return the default one. So I am doing just the translation which ( according to my undestanding ) should work all the time.

But it is not working.
Does any one has a suggestion on what is not done right?

Thanks
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On






Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1