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
ath];
I use this code to change the fontsize:
NSFont *font1 = [NSFont fontWithName:[pop1 titleOfSelectedItem] size:[[pop2 titleOfSelectedItem] doubleValue]];
if([[txt string] isEqualToString
""])
{
[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
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
I use this code to change the fontsize:
NSFont *font1 = [NSFont fontWithName:[pop1 titleOfSelectedItem] size:[[pop2 titleOfSelectedItem] doubleValue]];
if([[txt string] isEqualToString
{
[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