Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rethish

macrumors member
Original poster
Oct 16, 2008
41
0
Hi all,


problem:

I have some text(in textview) with different combination of fonts. If i select some range of text (combination of different fonts) to change its size , the size changes with a change in font (which was last selected from the popupbutton pop1).


I want to change the fontsize without affecting the font . (AS IN TEXTEDIT AND WORD)


I use all the fonts and fontsize through a popupbutton:
pop1 : font
pop2 : fontsize



NSArray *path=[[NSFontManager alloc] availableFonts];

[pop1 addItemsWithTitles:path];


I use this code to change the fontsize:

NSFont *font1 = [NSFont fontWithName:[pop1 titleOfSelectedItem] size:[[pop2 titleOfSelectedItem] doubleValue]];


if([[txt string] isEqualToString:mad:""])
{
[txt setFont:font1];
}

else
{
NSRange range= [txt rangeForUserCharacterAttributeChange];
NSDictionary *attrs=[NSDictionary dictionaryWithObjectsAndKeys:font1, NSFontAttributeName ,txt , NSTextViewDidChangeTypingAttributesNotification, nil];
[txt setTypingAttributes:attrs];
[txt setFont:font1 range: range];


}





Thank you
regards
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.