Skip to main content
Known Participant
November 3, 2009
Question

Setting properties of a new (text) paragraph style

  • November 3, 2009
  • 1 reply
  • 871 views

Hello,

In the GUI it is possible to create a new paragraph style and give it a Font, Fontsize and color. How can I do this with my plugin?

Currently I do the following:

// create a new named paragraph style

newParaStyle = resources.CreateParaStyle( ai::UnicodeString( styleName, kAIPlatformCharacterEncoding).as_ASUnicode().c_str() );

IParaFeatures paraFeatures;

paraFeatures.SetJustification( kRightJustify);

// setting more features
// and apply it to newParaStyle

newParaStyle.SetFeatures( paraFeatures);

But I need to provide this newParaStyle also with some charFeatures like Font, Fontsize and a color like in the GUI.

ICharFeatures  has all the properties I need, so I can do this:

ICharFeatures charFeatures;

charFeatures.SetFontSize( pointSize );

AIFontKey fontKey;

iErr = sAIFont->FindFont( fontName, kAIAnyFontTechnology, kRomanAIScript, true, &fontKey );

if (iErr) throw (iErr);

FontRef fontRef;

iErr = sAIFont->FontFromFontKey( fontKey, &fontRef );

if (iErr) throw (iErr);

IFont iFont( fontRef);

charFeatures.SetFont( iFont);

aSwatch = sAISwatchList->GetSwatchByName( colList, ai::UnicodeString( colName) );

iErr = sAISwatchList->GetAIColor( aSwatch, &colorP);

ApplicationPaintRef paintRef = nil;

sAIATEPaint->CreateATEApplicationPaint( &colorP, &paintRef);

IApplicationPaint paint( paintRef);

charFeatures.SetFillColor( paint);

charFeatures.SetFillOverPrint( ovpFill);

iErr = sAISwatchList->GetSwatchList( docP, &colList);

But how can I attach this charFeatures to my Paragraph? In the GUI the Paragraphsdialog also takes character features. Where are these hidden charFeatures and how are they accessible?

Michael

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
November 4, 2009

The GUI's combination of the two sets of (supposedly) distinct paragraph & character properties confuses me as well. I'm not sure how that actually is reflected in their code, but as far as I can tell they're distinct in code. I think you'd just call SetLocalCharFeatures() and SetLocalParaFeatures() on your ITextRange to apply both. If that doesn't work, I'm not sure how to combine them.

Known Participant
November 4, 2009

Hello Andrew,

yes, as far as we don't see an other way to give the text the desired features thats the way I have to go. But having in the GUI a paragraph with character features that should be doable also from the SDK. Didn't Adobe telling us that near everything in Illustrator is done by plugins ;->>

So come on Adobe, how did you do it?

Michael