This is a long, complex post. Sorry for its length.
Because of a unique requirement in a particular project, several years back I worked with Adobe to develop a plugin that would help detect font usage in documents. The idea was to identify the fonts used in a document by going down to the page level and actually inspecting the text. It's a long, complex process and I will try to summarize the code used here:
UID StyleUID = Paragraphs -> GetStyleUID(CurrentIndex, &ParagraphRunLength, &RunBegin);
InterfacePtr<IStrand> TheParagraphStrand(Paragraphs, IID_ISTRAND);
ParagraphRunLength = TheParagraphStrand -> GetRunLength(CurrentIndex, &RunBegin);
if(StyleUID != kInvalidUID)
{
// The paragraph style
InterfacePtr<IStyleInfo> ParagraphStyleInfo(db, StyleUID, IID_ISTYLEINFO);
FontObject *FontFromStyle = GetFontFromStyle(ParagraphStyleInfo, db, FontID, Page);
Here is the salient part in GetFontFromStyle:
InterfacePtr<IFontMgr> FontMgr(GetExecutionContextSession(), IID_IFONTMGR);
InterfacePtr<ITextAttributes> AttributeObject(StyleInfo,UseDefaultIID());
do
{
if(AttributeObject)
{
const AttributeBossList *AttributeList;
AttributeList = AttributeObject -> GetBossList();
int32 BossCount = AttributeList -> CountBosses();
// contains same info as for local overrides
int32 a;
for(a = 0; a < BossCount; a++)
{
ClassID CID = (*AttributeList).GetClassN(a);
if(CID == kTextAttrFontUIDBoss)
{
ITextAttrUID *UIDAttr = (ITextAttrUID *) (*AttributeList).QueryBossN(a, IID_ITEXTATTRUID);
if(UIDAttr != NULL)
{
FontUID = UIDAttr -> GetUIDData();
InterfacePtr<IFontFamily> font(db, FontUID, UseDefaultIID());
if(font)
{
FontName = font -> GetFamilyName().GetPlatformString();
The above was used to detect fonts used in runs. The code below was used to detect local overrides:
// Attribute overrides.
DataWrapper<AttributeBossList> AttributeList = Paragraphs -> GetLocalOverrides(CurrentIndex, NULL, NULL);
int32 AttributeBossCount = (*AttributeList).CountBosses();
int32 a;
std::string NamePart,
FacePart;
UID TempUID = kInvalidUID;
for(a = 0; a < AttributeBossCount; a++)
{
ClassID CID = (*AttributeList).GetClassN(a);
if(CID == kTextAttrFontUIDBoss)
{
FontBossFlag = kTrue;
ITextAttrUID *UIDAttr = (ITextAttrUID *) (*AttributeList).QueryBossN(a, IID_ITEXTATTRUID);
if(UIDAttr != NULL)
{
TempUID = UIDAttr -> GetUIDData();
InterfacePtr<IFontFamily> font(db, TempUID, UseDefaultIID());
if(font)
NamePart = font -> GetFamilyName().GetPlatformString();
The actual code is a lot longer than this, including a bunch of bookkeeping and duplicates for paragraph vs text runs, as well as formatting the final data for inclusion in the plugin's data storage class.
The problem is that Minion Pro, and only Minion Pro, is not getting detected, either as a run or as a local override. This happens on at least two separate machines I've tested, one a Mac, one a Windows box. I've compared the code with the original example provided by Adobe and though I have made some changes, none of them are more than changes to var names to make their usage clear.
This problem is only now being detected because in the past this code was used to identify exceptions; now it is being used to identify all fonts, and of course, is failing.
Does anyone have any idea as to what is the problem here?