% MagickCore Image Type Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% May 2001 %
% %
% %
-% Copyright 1999-2007 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
#endif
#endif
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+# include "MagickCore/nt-feature.h"
+#endif
\f
/*
Define declarations.
static SemaphoreInfo
*type_semaphore = (SemaphoreInfo *) NULL;
-static volatile MagickBooleanType
- instantiate_type = MagickFalse;
-
static SplayTreeInfo
- *type_list = (SplayTreeInfo *) NULL;
+ *type_cache = (SplayTreeInfo *) NULL;
\f
/*
Forward declarations.
*/
static MagickBooleanType
- InitializeTypeList(ExceptionInfo *),
- LoadTypeLists(const char *,ExceptionInfo *);
+ IsTypeTreeInstantiated(ExceptionInfo *),
+ LoadTypeCache(SplayTreeInfo *,const char *,const char *,const size_t,
+ ExceptionInfo *);
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% A c q u i r e T y p e S p l a y T r e e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% AcquireTypeCache() caches one or more type configuration files which
+% provides a mapping between type attributes and a type name.
+%
+% The format of the AcquireTypeCache method is:
+%
+% SplayTreeInfo *AcquireTypeCache(const char *filename,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o filename: the font file name.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+
+static void *DestroyTypeNode(void *type_info)
+{
+ register TypeInfo
+ *p;
+
+ p=(TypeInfo *) type_info;
+ if (p->path != (char *) NULL)
+ p->path=DestroyString(p->path);
+ if (p->name != (char *) NULL)
+ p->name=DestroyString(p->name);
+ if (p->description != (char *) NULL)
+ p->description=DestroyString(p->description);
+ if (p->family != (char *) NULL)
+ p->family=DestroyString(p->family);
+ if (p->encoding != (char *) NULL)
+ p->encoding=DestroyString(p->encoding);
+ if (p->foundry != (char *) NULL)
+ p->foundry=DestroyString(p->foundry);
+ if (p->format != (char *) NULL)
+ p->format=DestroyString(p->format);
+ if (p->metrics != (char *) NULL)
+ p->metrics=DestroyString(p->metrics);
+ if (p->glyphs != (char *) NULL)
+ p->glyphs=DestroyString(p->glyphs);
+ return(RelinquishMagickMemory(p));
+}
+
+static SplayTreeInfo *AcquireTypeCache(const char *filename,
+ ExceptionInfo *exception)
+{
+ MagickStatusType
+ status;
+
+ SplayTreeInfo
+ *type_cache;
+
+ type_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
+ DestroyTypeNode);
+ if (type_cache == (SplayTreeInfo *) NULL)
+ ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+ status=MagickTrue;
+#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
+ {
+ char
+ *font_path,
+ path[MaxTextExtent];
+
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ *path='\0';
+ options=GetConfigureOptions(filename,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
+ status&=LoadTypeCache(type_cache,(const char *)
+ GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
+ font_path=GetEnvironmentValue("MAGICK_FONT_PATH");
+ if (font_path != (char *) NULL)
+ {
+ char
+ *option;
+
+ /*
+ Search MAGICK_FONT_PATH.
+ */
+ (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",font_path,
+ DirectorySeparator,filename);
+ option=FileToString(path,~0UL,exception);
+ if (option != (void *) NULL)
+ {
+ status&=LoadTypeCache(type_cache,option,path,0,exception);
+ option=DestroyString(option);
+ }
+ font_path=DestroyString(font_path);
+ }
+ }
+#endif
+ if (GetNumberOfNodesInSplayTree(type_cache) == 0)
+ status&=LoadTypeCache(type_cache,TypeMap,"built-in",0,exception);
+ return(type_cache);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MagickExport const TypeInfo *GetTypeInfo(const char *name,
ExceptionInfo *exception)
{
+ const TypeInfo
+ *type_info;
+
assert(exception != (ExceptionInfo *) NULL);
- if ((type_list == (SplayTreeInfo *) NULL) ||
- (instantiate_type == MagickFalse))
- if (InitializeTypeList(exception) == MagickFalse)
- return((const TypeInfo *) NULL);
- if ((type_list == (SplayTreeInfo *) NULL) ||
- (GetNumberOfNodesInSplayTree(type_list) == 0))
+ if (IsTypeTreeInstantiated(exception) == MagickFalse)
return((const TypeInfo *) NULL);
+ LockSemaphoreInfo(type_semaphore);
if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
{
- ResetSplayTreeIterator(type_list);
- return((const TypeInfo *) GetNextValueInSplayTree(type_list));
+ ResetSplayTreeIterator(type_cache);
+ type_info=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
+ UnlockSemaphoreInfo(type_semaphore);
+ return(type_info);
}
- return((const TypeInfo *) GetValueFromSplayTree(type_list,name));
+ type_info=(const TypeInfo *) GetValueFromSplayTree(type_cache,name);
+ UnlockSemaphoreInfo(type_semaphore);
+ return(type_info);
}
\f
/*
Check for an exact type match.
*/
(void) GetTypeInfo("*",exception);
- if (type_list == (SplayTreeInfo *) NULL)
+ if (type_cache == (SplayTreeInfo *) NULL)
return((TypeInfo *) NULL);
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
+ ResetSplayTreeIterator(type_cache);
type_info=(const TypeInfo *) NULL;
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
while (p != (const TypeInfo *) NULL)
{
if (p->family == (char *) NULL)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if (family == (const char *) NULL)
if ((LocaleCompare(p->family,"arial") != 0) &&
(LocaleCompare(p->family,"helvetica") != 0))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
}
else
if (LocaleCompare(p->family,family) != 0)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((style != UndefinedStyle) && (style != AnyStyle) && (p->style != style))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((stretch != UndefinedStretch) && (stretch != AnyStretch) &&
(p->stretch != stretch))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if ((weight != 0) && (p->weight != weight))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
type_info=p;
*/
max_score=0;
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
while (p != (const TypeInfo *) NULL)
{
if (p->family == (char *) NULL)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
if (family == (const char *) NULL)
if ((LocaleCompare(p->family,"arial") != 0) &&
(LocaleCompare(p->family,"helvetica") != 0))
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
}
else
if (LocaleCompare(p->family,family) != 0)
{
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
continue;
}
score=0;
max_score=score;
type_info=p;
}
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
if (type_info != (const TypeInfo *) NULL)
if (p == (const TypeInfo *) NULL)
return((const TypeInfo **) NULL);
fonts=(const TypeInfo **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(type_list)+1UL,sizeof(*fonts));
+ GetNumberOfNodesInSplayTree(type_cache)+1UL,sizeof(*fonts));
if (fonts == (const TypeInfo **) NULL)
return((const TypeInfo **) NULL);
/*
Generate type list.
*/
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
for (i=0; p != (const TypeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
fonts[i++]=p;
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeInfoCompare);
if (p == (const TypeInfo *) NULL)
return((char **) NULL);
fonts=(char **) AcquireQuantumMemory((size_t)
- GetNumberOfNodesInSplayTree(type_list)+1UL,sizeof(*fonts));
+ GetNumberOfNodesInSplayTree(type_cache)+1UL,sizeof(*fonts));
if (fonts == (char **) NULL)
return((char **) NULL);
/*
Generate type list.
*/
LockSemaphoreInfo(type_semaphore);
- ResetSplayTreeIterator(type_list);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ ResetSplayTreeIterator(type_cache);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
for (i=0; p != (const TypeInfo *) NULL; )
{
if ((p->stealth == MagickFalse) &&
(GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
fonts[i++]=ConstantString(p->name);
- p=(const TypeInfo *) GetNextValueInSplayTree(type_list);
+ p=(const TypeInfo *) GetNextValueInSplayTree(type_cache);
}
UnlockSemaphoreInfo(type_semaphore);
qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeCompare);
% %
% %
% %
-+ I n i t i a l i z e T y p e L i s t %
++ I s T y p e T r e e I n s t a n t i a t e d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% InitializeTypeList() initializes the type list.
+% IsTypeTreeInstantiated() determines if the type tree is instantiated. If
+% not, it instantiates the tree and returns it.
%
-% The format of the InitializeTypeList method is:
+% The format of the IsTypeInstantiated method is:
%
-% MagickBooleanType InitializeTypeList(ExceptionInfo *exception)
+% MagickBooleanType IsTypeTreeInstantiated(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
*/
#if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
-MagickExport MagickBooleanType LoadFontConfigFonts(SplayTreeInfo *type_list,
+MagickExport MagickBooleanType LoadFontConfigFonts(SplayTreeInfo *type_cache,
ExceptionInfo *exception)
{
+#if !defined(FC_FULLNAME)
+#define FC_FULLNAME "fullname"
+#endif
+
char
extension[MaxTextExtent],
name[MaxTextExtent];
FcChar8
*family,
*file,
+ *fullname,
*style;
FcConfig
if (font_config == (FcConfig *) NULL)
return(MagickFalse);
font_set=(FcFontSet *) NULL;
- object_set=FcObjectSetBuild(FC_FAMILY,FC_STYLE,FC_SLANT,FC_WIDTH,FC_WEIGHT,
- FC_FILE,(char *) NULL);
+ object_set=FcObjectSetBuild(FC_FULLNAME,FC_FAMILY,FC_STYLE,FC_SLANT,
+ FC_WIDTH,FC_WEIGHT,FC_FILE,(char *) NULL);
if (object_set != (FcObjectSet *) NULL)
{
pattern=FcPatternCreate();
(void) ResetMagickMemory(type_info,0,sizeof(*type_info));
type_info->path=ConstantString("System Fonts");
type_info->signature=MagickSignature;
- (void) CopyMagickString(name,(const char *) family,MaxTextExtent);
- (void) ConcatenateMagickString(name," ",MaxTextExtent);
- status=FcPatternGetString(font_set->fonts[i],FC_STYLE,0,&style);
- if (status == FcResultMatch)
- (void) ConcatenateMagickString(name,(const char *) style,MaxTextExtent);
+ (void) CopyMagickString(name,"Unknown",MaxTextExtent);
+ status=FcPatternGetString(font_set->fonts[i],FC_FULLNAME,0,&fullname);
+ if ((status == FcResultMatch) && (fullname != (FcChar8 *) NULL))
+ (void) CopyMagickString(name,(const char *) fullname,MaxTextExtent);
+ else
+ {
+ if (family != (FcChar8 *) NULL)
+ (void) CopyMagickString(name,(const char *) family,MaxTextExtent);
+ status=FcPatternGetString(font_set->fonts[i],FC_STYLE,0,&style);
+ if ((status == FcResultMatch) && (style != (FcChar8 *) NULL) &&
+ (LocaleCompare((const char *) style,"Regular") != 0))
+ {
+ (void) ConcatenateMagickString(name," ",MaxTextExtent);
+ (void) ConcatenateMagickString(name,(const char *) style,
+ MaxTextExtent);
+ }
+ }
type_info->name=ConstantString(name);
(void) SubstituteString(&type_info->name," ","-");
- (void) SubstituteString(&type_info->name,"-L-","-");
- (void) SubstituteString(&type_info->name,"semicondensed","SemiCondensed");
type_info->family=ConstantString((const char *) family);
- (void) SubstituteString(&type_info->family," L","");
status=FcPatternGetInteger(font_set->fonts[i],FC_SLANT,0,&slant);
type_info->style=NormalStyle;
if (slant == FC_SLANT_ITALIC)
if (weight >= FC_WEIGHT_BLACK)
type_info->weight=900;
type_info->glyphs=ConstantString((const char *) file);
- (void) AddValueToSplayTree(type_list,type_info->name,type_info);
+ (void) AddValueToSplayTree(type_cache,type_info->name,type_info);
}
FcFontSetDestroy(font_set);
FcConfigDestroy(font_config);
}
#endif
-static MagickBooleanType InitializeTypeList(ExceptionInfo *exception)
+static MagickBooleanType IsTypeTreeInstantiated(ExceptionInfo *exception)
{
- if ((type_list == (SplayTreeInfo *) NULL) &&
- (instantiate_type == MagickFalse))
+ if (type_cache == (SplayTreeInfo *) NULL)
{
if (type_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&type_semaphore);
+ ActivateSemaphoreInfo(&type_semaphore);
LockSemaphoreInfo(type_semaphore);
- if ((type_list == (SplayTreeInfo *) NULL) &&
- (instantiate_type == MagickFalse))
+ if (type_cache == (SplayTreeInfo *) NULL)
{
- (void) LoadTypeLists(MagickTypeFilename,exception);
+ type_cache=AcquireTypeCache(MagickTypeFilename,exception);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
- (void) NTLoadTypeLists(type_list,exception);
+ (void) NTAcquireTypeCache(type_cache,exception);
#endif
#if defined(MAGICKCORE_FONTCONFIG_DELEGATE)
- (void) LoadFontConfigFonts(type_list,exception);
+ (void) LoadFontConfigFonts(type_cache,exception);
#endif
- instantiate_type=MagickTrue;
}
UnlockSemaphoreInfo(type_semaphore);
}
- return(type_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
+ return(type_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% LoadTypeList() loads the type configuration file which provides a mapping
+% LoadTypeCache() loads the type configurations which provides a mapping
% between type attributes and a type name.
%
-% The format of the LoadTypeList method is:
+% The format of the LoadTypeCache method is:
%
-% MagickBooleanType LoadTypeList(const char *xml,const char *filename,
-% const size_t depth,ExceptionInfo *exception)
+% MagickBooleanType LoadTypeCache(SplayTreeInfo *type_cache,
+% const char *xml,const char *filename,const size_t depth,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
*/
-static void *DestroyTypeNode(void *type_info)
+static inline MagickBooleanType SetTypeNodePath(const char *filename,
+ char *font_path,const char *token,char **target)
{
- register TypeInfo
- *p;
+ char
+ *path;
- p=(TypeInfo *) type_info;
- if (p->path != (char *) NULL)
- p->path=DestroyString(p->path);
- if (p->name != (char *) NULL)
- p->name=DestroyString(p->name);
- if (p->description != (char *) NULL)
- p->description=DestroyString(p->description);
- if (p->family != (char *) NULL)
- p->family=DestroyString(p->family);
- if (p->encoding != (char *) NULL)
- p->encoding=DestroyString(p->encoding);
- if (p->foundry != (char *) NULL)
- p->foundry=DestroyString(p->foundry);
- if (p->format != (char *) NULL)
- p->format=DestroyString(p->format);
- if (p->metrics != (char *) NULL)
- p->metrics=DestroyString(p->metrics);
- if (p->glyphs != (char *) NULL)
- p->glyphs=DestroyString(p->glyphs);
- return(RelinquishMagickMemory(p));
+ path=ConstantString(token);
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+ if (strchr(path,'@') != (char *) NULL)
+ SubstituteString(&path,"@ghostscript_font_path@",font_path);
+#endif
+ if (IsPathAccessible(path) == MagickFalse)
+ {
+ /*
+ Relative path.
+ */
+ path=DestroyString(path);
+ GetPathComponent(filename,HeadPath,font_path);
+ (void) ConcatenateMagickString(font_path,DirectorySeparator,
+ MaxTextExtent);
+ (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
+ path=ConstantString(font_path);
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+ if (strchr(path,'@') != (char *) NULL)
+ SubstituteString(&path,"@ghostscript_font_path@","");
+#endif
+ if (IsPathAccessible(path) == MagickFalse)
+ {
+ path=DestroyString(path);
+ return(MagickFalse);
+ }
+ }
+
+ *target=path;
+ return(MagickTrue);
}
-static MagickBooleanType LoadTypeList(const char *xml,const char *filename,
- const size_t depth,ExceptionInfo *exception)
+static MagickBooleanType LoadTypeCache(SplayTreeInfo *type_cache,
+ const char *xml,const char *filename,const size_t depth,
+ ExceptionInfo *exception)
{
char
font_path[MaxTextExtent],
"Loading type configure file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (type_list == (SplayTreeInfo *) NULL)
- {
- type_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
- DestroyTypeNode);
- if (type_list == (SplayTreeInfo *) NULL)
- {
- ThrowFileException(exception,ResourceLimitError,
- "MemoryAllocationFailed",filename);
- return(MagickFalse);
- }
- }
status=MagickTrue;
type_info=(TypeInfo *) NULL;
token=AcquireString(xml);
else
(void) ConcatenateMagickString(path,token,MaxTextExtent);
sans_exception=AcquireExceptionInfo();
- xml=FileToString(path,~0,sans_exception);
+ xml=FileToString(path,~0UL,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (xml != (char *) NULL)
{
- status=LoadTypeList(xml,path,depth+1,exception);
+ status&=LoadTypeCache(type_cache,xml,path,depth+1,
+ exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
- status=AddValueToSplayTree(type_list,type_info->name,type_info);
+ status=AddValueToSplayTree(type_cache,type_info->name,type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",type_info->name);
type_info=(TypeInfo *) NULL;
+ continue;
}
GetMagickToken(q,(const char **) NULL,token);
if (*token != '=')
{
if (LocaleCompare((char *) keyword,"glyphs") == 0)
{
- char
- *path;
-
- path=ConstantString(token);
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
- if (strchr(path,'@') != (char *) NULL)
- SubstituteString(&path,"@ghostscript_font_path@",font_path);
-#endif
- if (IsPathAccessible(path) == MagickFalse)
- {
- /*
- Relative path.
- */
- path=DestroyString(path);
- GetPathComponent(filename,HeadPath,font_path);
- (void) ConcatenateMagickString(font_path,DirectorySeparator,
- MaxTextExtent);
- (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
- path=ConstantString(font_path);
- if (IsPathAccessible(path) == MagickFalse)
- {
- path=DestroyString(path);
- path=ConstantString(token);
- }
- }
- type_info->glyphs=path;
+ if (SetTypeNodePath(filename,font_path,token,&type_info->glyphs) ==
+ MagickFalse)
+ type_info=(TypeInfo *) DestroyTypeNode(type_info);
break;
}
break;
{
if (LocaleCompare((char *) keyword,"metrics") == 0)
{
- char
- *path;
-
- path=ConstantString(token);
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
- if (strchr(path,'@') != (char *) NULL)
- SubstituteString(&path,"@ghostscript_font_path@",font_path);
-#endif
- if (IsPathAccessible(path) == MagickFalse)
- {
- /*
- Relative path.
- */
- path=DestroyString(path);
- GetPathComponent(filename,HeadPath,font_path);
- (void) ConcatenateMagickString(font_path,DirectorySeparator,
- MaxTextExtent);
- (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
- path=ConstantString(font_path);
- }
- type_info->metrics=path;
+ if (SetTypeNodePath(filename,font_path,token,&type_info->metrics) ==
+ MagickFalse)
+ type_info=(TypeInfo *) DestroyTypeNode(type_info);
break;
}
break;
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
- type_info->stealth=IsMagickTrue(token);
+ type_info->stealth=IsStringTrue(token);
break;
}
if (LocaleCompare((char *) keyword,"stretch") == 0)
% %
% %
% %
-% L o a d T y p e L i s t s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% LoadTypeList() loads one or more type configuration files which provides a
-% mapping between type attributes and a type name.
-%
-% The format of the LoadTypeLists method is:
-%
-% MagickBooleanType LoadTypeLists(const char *filename,
-% ExceptionInfo *exception)
-%
-% A description of each parameter follows:
-%
-% o filename: the font file name.
-%
-% o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType LoadTypeLists(const char *filename,
- ExceptionInfo *exception)
-{
-#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- return(LoadTypeList(TypeMap,"built-in",0,exception));
-#else
- char
- *font_path,
- path[MaxTextExtent];
-
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
- MagickStatusType
- status;
-
- status=MagickFalse;
- *path='\0';
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
- {
- (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent);
- status|=LoadTypeList((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
- options=DestroyConfigureOptions(options);
- font_path=GetEnvironmentValue("MAGICK_FONT_PATH");
- if (font_path != (char *) NULL)
- {
- char
- *option;
-
- /*
- Search MAGICK_FONT_PATH.
- */
- (void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",font_path,
- DirectorySeparator,filename);
- option=FileToString(path,~0,exception);
- if (option != (void *) NULL)
- {
- status|=LoadTypeList(option,path,0,exception);
- option=DestroyString(option);
- }
- font_path=DestroyString(font_path);
- }
- if ((type_list == (SplayTreeInfo *) NULL) ||
- (GetNumberOfNodesInSplayTree(type_list) == 0))
- status|=LoadTypeList(TypeMap,"built-in",0,exception);
- return(status != 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
+ T y p e C o m p o n e n t G e n e s i s %
% %
% %
*/
MagickPrivate MagickBooleanType TypeComponentGenesis(void)
{
- AcquireSemaphoreInfo(&type_semaphore);
+ if (type_semaphore == (SemaphoreInfo *) NULL)
+ type_semaphore=AcquireSemaphoreInfo();
return(MagickTrue);
}
\f
MagickPrivate void TypeComponentTerminus(void)
{
if (type_semaphore == (SemaphoreInfo *) NULL)
- AcquireSemaphoreInfo(&type_semaphore);
+ ActivateSemaphoreInfo(&type_semaphore);
LockSemaphoreInfo(type_semaphore);
- if (type_list != (SplayTreeInfo *) NULL)
- type_list=DestroySplayTree(type_list);
- instantiate_type=MagickFalse;
+ if (type_cache != (SplayTreeInfo *) NULL)
+ type_cache=DestroySplayTree(type_cache);
UnlockSemaphoreInfo(type_semaphore);
- DestroySemaphoreInfo(&type_semaphore);
+ RelinquishSemaphoreInfo(&type_semaphore);
}