BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-23-2008, 04:52 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 8300
PIN: N/A
Carrier: AT&T
Posts: 25
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Font scaling

Please Login to Remove!

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
Offline  
Closed Thread


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

New Numatics Pneumatic Valve Model 32DX4410 With Solenoid 237-221B
$149.0
New Numatics Pneumatic Valve Model 32DX4410 With Solenoid 237-221B pictureTacmina Solenoid Driven Metering Pump PZ_31-VFC-TW-UL3 .47GPH 145 PSI
$90.0
Tacmina Solenoid Driven Metering Pump PZ_31-VFC-TW-UL3  .47GPH 145 PSI  picture12V Fuel Shut Off Solenoid for Ford 5.9L 8.3L Cummins 3927152 3832211 3934972
$52.17
12V Fuel Shut Off Solenoid for Ford 5.9L 8.3L Cummins 3927152 3832211 3934972 pictureAsco Red-Hat II 3/8" Solenoid 8263G206 NC 120V NIB
$61.0
Asco Red-Hat II 3/8Sporlan solenoid valve B6S1 1/2" ODF
$20.0
Sporlan solenoid valve B6S1   1/2






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.