I am developing a text editor in which I use to set the font name and font size by selecting it from popup buttons.

Fonts obtained using the code:
NSArray *path=[[NSFontManager alloc] availableFonts];
[fontList addItemsWithTitlesath];

I use to set font using :
NSFont *font = [NSFont fontWithNamefontList titleOfSelectedItem] size[fontSize titleOfSelectedItem] doubleValue]];

NSRange selectedRange= [textView rangeForUserCharacterAttributeChange];
[textView setFont:font range:selectedRange ];

This works properly if the selected text is composed of single font.
But if i select the text which is composed of multiple fonts, then font of entire text is set to the font, that is last selected from the popupbutton.

How can I resize the font size without affecting the fonts in it?

Thank you in advance