The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Create label with specified font

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
azazell0 Posted - 05/01/2005 : 6:05:31 PM
No, it's not that simple. Suppose I have a graph, and from different fits I get equations displayed as labels. They get the names Text, Text1, Text2 etc. I want them to have automatically a) the same font type and b) the same text size as the XB label.

Note that you don't know the name of the latest label that the

label ... %z;

command somewhere in pr.ogs just created.

Problems:
1. There is no text size switch for the label commmand (and the -f doesn't seem to work either)
2. Yes, before the label command, I could temporarily set the system.font.labelSize to XB.fSize. But I can't convert the number returned by XB.font to the font name required by system.font.labelName$ . (As far as I know, there is no fontnumber -> fontname function.)

thanks in advance,
azazell0
6   L A T E S T    R E P L I E S    (Newest First)
azazell0 Posted - 05/03/2005 : 11:27:36 AM
quote:
But you wanted to find the number that corresponds to an arbitrary font name


No! I wanted to do the reverse: get the font name from the font number, so that I can set system.font.labelName$ (that's the default font name) to XB's font name.
Mike Buess Posted - 05/03/2005 : 11:03:58 AM
quote:
The xb.font returns the font number directly
Of course... I was just setting an initial value for ii. But you wanted to find the number that corresponds to an arbitrary font name and the only way to do that is to select a name on the list and then find out what ii is. But your solution using a text label should work fine.

Mike Buess
Origin WebRing Member
azazell0 Posted - 05/03/2005 : 10:49:26 AM
Thank you. I don't have Origin 7, though. (I'm using 4.1 and 6.1, sorry for not telling this.)

I asked someone and he suggested me to store the number of labels created in a hidden label on the graph. This trick even enables me to assign any custom name to my equations:


if(EquationNumber.show == 0/0) /* create the hidden label if it doesn't exist */
{
label -d 300 300 -n EquationNumber 0;
EquationNumber.show = 0;
}

%A = EquationNumber.text$;
EqNumber = $(%A);
EqNumber++;
EquationNumber.text$ = $(EqNumber);

label -p 10 0 -s -n Equation$(EqNumber) %Z;
Equation$(EqNumber).font = XB.font;
Equation$(EqNumber).fSize = XB.fSize;


I think I'll use this.

quote:

And the only LabTalk method for getting the font number from the font name is with the getnumber dialog...

ii=xb.font;
getn ( ) ii:@T (Select a font);
ii=;
font number



I needed a fontcode -> fontname conversion method. Getting the font number from the font name can be done a lot easier, without getnumber: for example, ff=font(Verdana). (But I guess you knew that.) By the way, as far as I can see, in your code the getn is unneccessary. The xb.font returns the font number directly.

Thanks, anyway.
Mike Buess Posted - 05/02/2005 : 4:47:21 PM
quote:
every time a new label is created you have to run the whole parsing script again and again.
So? Unless you will be doing hundreds of fits in the same graph you won't notice the extra time. And the only LabTalk method for getting the font number from the font name is with the getnumber dialog...

ii=xb.font;
getn ( ) ii:@T (Select a font);
ii=;
font number

I think you can only do what you want with Origin C. If you have Origin 7 or 7.5 then add the following function to your OC Workspace and build. Then open pr.ogs, search for 'label -' (it only occurs once) and insert the command 'FormatNewLabel;' on the line after it. The function looks for the last created object in the layer (which will be the text label) and formats it appropriately.
void FormatNewLabel()
{
Layer gl = Project.ActiveLayer();
int fType = LabTalk.XB.font;
int fSize = LabTalk.XB.fsize;
int nObj = gl.GraphObjects.Count();
GraphObject go;
go = gl.GraphObjects(nObj-1);
string sCmd;
sCmd.Format("%s.font=%d; %s.fsize=%d",go.GetName(),fType,go.GetName(),fSize);
gl.LT_execute(sCmd);
}
...Here's a variation of my LT script that might be acceptable. It only formats the first and last text label. (Still has to find the name of the last label, though.)

ff=xb.font; fs=xb.fsize;
if(text.show) {
text.font=ff; text.fsize=fs; // format 1st label
};
for(i=1;i>0;i++) {
%A=text$(i); if(%A.show!=1) break;
};
%A=text$(i-1);
if( %A.show ) {
%A.font=ff; %A.fsize=fs; // format last label
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 05/02/2005 4:52:50 PM

Edited by - Mike Buess on 05/02/2005 5:13:50 PM
azazell0 Posted - 05/02/2005 : 3:35:25 PM
Thanks. I thought about something like this myself (except I didn't know about the show property), but it's not so good since every time a new label is created you have to run the whole parsing script again and again. OK, this is definetely a solution, but isn't there a simpler way?

I could do it if there was a method to convert between the list# and the name of the font. Suppose I just want to set a font obtained using getnumber as default. How could I do that?
Mike Buess Posted - 05/02/2005 : 06:50:33 AM
ff=xb.font; fs=xb.fsize;
if(text.show) {
text.font=ff; text.fsize=fs; // format 1st label
};
for(i=1;i>0;i++) {
%A=text$(i); if(%A.show!=1) break;
%A.font=ff; %A.fsize=fs; // format later labels
};

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000