Sunday, March 28, 2010

Font type with font name...

Hi,

I want to get the font types (True type, Open type, Type1 font )?with the font name in illustrator document cs2.?Im using one method its not working properly... For some files (*.ai) its not working properly... Loop is breaked because of fontkey is not return correctly...

Here is that code... If anyone known means pls help me...

AIArtHandle path=NULL;
?short artType;?AILayerHandle layer;
?ADMItemRef?ItemRef;?ADMListRef?theItemList;?
?
?
?AIErr error;

?char FilePath[5000];
?SPPlatformFileSpecification file;?
?FILE *File;
?ADMItemRef item;

?strcpy(ErrorReportString,''\0'');

?char ConcatFont[5000];
?int cnt=0;

?long count;?
?char buf[128],fonttext[128];

?BBValuesStruct.CheckOpenTypeFontFlag=0;
?
?bool OpenTypeFontExists;
?
?int idx;
?ADMEntryRef entry;

?AIArtHandle textPath=NULL;
?AIFontStyle faceStyle;
?AIFontKey fontKey;
?short forfont;


?AIArtSet artSet;

?unsigned char title[150];

?long numLayers;

?sAIMatchingArt-%26gt;DeselectAll();

?error = sAILayer-%26gt;CountLayers( %26amp;numLayers );

?ItemRef = sADMDialog-%26gt;GetItem(g-%26gt;qcGuide , lstDifferences);
?theItemList = sADMItem-%26gt;GetList(ItemRef);?
?
?for ( int i = 0; i %26lt; numLayers; i++ )
?{
?
?error = sAILayer-%26gt;GetNthLayer( i, %26amp;layer ); //extracting layer by layer?

?error = sAILayer-%26gt;GetLayerTitle( layer, title );

?if(strstr((char*)title,''SCAN'')==0 %26amp;%26amp; strstr((char*)title,''Bounding Box'')==0)
?{
?
?error=sAIArtSet-%26gt;NewArtSet(%26amp;artSet);

?error=sAIArtSet-%26gt;LayerArtSet (layer,artSet );
?
?error=sAIArtSet-%26gt;CountArtSet (artSet, %26amp;count );

?sprintf(buf,''%d'',count);
?
?for(long j=0;j%26lt;count;j++)
?{

?error=sAIArtSet-%26gt;IndexArtSet (artSet,j,%26amp;path );
?error = sAIArt-%26gt;GetArtType(path,%26amp;artType);
?OpenTypeFontExists=false;

?if(artType==kTextFrameArt)
?{
?//MessageBox(NULL,''INSIDE'',''TEXTFRAME'',0);

?char buf[250];

?
?TextRangeRef textRange;
?
?sAITextFrame-%26gt;GetATETextRange(path,%26amp;textRange);
?
?if ( error ) throw( error );

?ITextRange itext( textRange );
?
?ICharFeatures features=itext.GetUniqueCharFeatures();
?
?bool isValid = false;

?IFont textfont=features.GetFont(%26amp;isValid);
?
?FontRef FntRef=textfont.GetRef();

?sAIFont-%26gt;FontKeyFromFont(FntRef,%26amp;fontKey);

?sAIFont-%26gt;GetFontInfo(fontKey,%26amp;faceStyle);

?sAIFont-%26gt;GetUserFontName(fontKey,fonttext,forfont);?
?sprintf(buf,''%s'',(char*)fonttext);
?//MessageBox(NULL,buf,''opentype'',0);
?
?if(faceStyle.isOTF==true)
?{
?cnt++;
?if(strstr(ConcatFont,(char*)fonttext)==NULL)
?{
?strcat(ConcatFont,(char*)fonttext);
?//cnt++;
?}
?OpenTypeFontExists=true;
?
?}?

?if(isValid)
?{
?
?if(OpenTypeFontExists==true)
?{
?
?item = sADMDialog-%26gt;GetItem( g-%26gt;GeneralArtDialog, CHK_GeneralBatchConversion );
?if ( sADMItem-%26gt;GetBooleanValue( item ) )
?{
?}
?
?
?}

?
?}//end of isValid
?
?
?}//end of artType
?
?
?}
?}
?}


if(cnt%26gt;0)
{
?sprintf(GeneralArtCSVReport,''In %d places Open Type Font (%s) was encountered'',cnt,ConcatFont);
}

Font type with font name...

Your code looks fine, we just need to figure out the problem with the font key from the other thread.

Font type with font name...

I am new for ''Illustrator CS3 SDK''. Could you please advice me how to run the above code also which header file is needed for this code. I have a vc++ editor. But i don't know how to use the above code. Kindly advice and help me. I am also need to get the font type information.

The code he posted requires AIFont.h but you can't just drop that code into a cpp and compile. You should be using one of the skeleton projects that came with the CS3 SDK, or failing that modify one of the existing sample code projects.

Hi,

?In tat code , While debugging i found it stop in the line

''FontRef FntRef=textfont.GetRef();''

for specific files in the same version.?Dont know why?

If you got any idea pls suggest me.

We were discussing this in your other thread here:

http://forums.adobe.com/thread/485572?tstart=0

Did you ever try the couple of things I suggested there?

No comments:

Post a Comment