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

Tektronix TLA 704 Color Logic Analyzer Mainframe TLA 7L4 136 Channel LA Module
$9.99
Tektronix TLA 704 Color Logic Analyzer Mainframe TLA 7L4 136 Channel LA Module  picture PHILIPS, AGILENT TELEMETRY MAINFRAME M2604A WITH 8 RECEIVERS M2603A
$99.99
 PHILIPS, AGILENT TELEMETRY MAINFRAME M2604A WITH 8 RECEIVERS M2603A pictureLECROY 1454 HIGH VOLTAGE MAINFRAME
$1500.0
LECROY 1454 HIGH VOLTAGE MAINFRAME pictureFluke Networks Versiv Modular Mainframe TFS
$1995.0
Fluke Networks Versiv Modular Mainframe TFS picturePREFORMED LINE PRODUCTS 8001040 FIBER OPTIC MAINFRAME METALIC ORGANIZER 6.5X28
$19.99
PREFORMED LINE PRODUCTS 8001040 FIBER OPTIC MAINFRAME METALIC ORGANIZER 6.5X28 picture






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