43#include "MagickCore/studio.h"
44#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
45#include "MagickCore/cache.h"
46#include "MagickCore/colorspace.h"
47#include "MagickCore/colorspace-private.h"
48#include "MagickCore/draw.h"
49#include "MagickCore/exception.h"
50#include "MagickCore/exception-private.h"
51#include "MagickCore/image-private.h"
52#include "MagickCore/locale-private.h"
53#include "MagickCore/memory_.h"
54#include "MagickCore/memory-private.h"
55#include "MagickCore/monitor.h"
56#include "MagickCore/monitor-private.h"
57#include "MagickCore/nt-base.h"
58#include "MagickCore/nt-base-private.h"
59#include "MagickCore/nt-feature.h"
60#include "MagickCore/pixel-accessor.h"
61#include "MagickCore/quantum.h"
62#include "MagickCore/string_.h"
63#include "MagickCore/token.h"
64#include "MagickCore/splay-tree.h"
65#include "MagickCore/utility.h"
66#if defined(__CYGWIN__)
67#define WIN32_LEAN_AND_MEAN
95MagickExport MagickBooleanType NTIsMagickConflict(
const char *magick)
100 assert(magick != (
char *) NULL);
101 if (strlen(magick) > 1)
103 status=(GetLogicalDrives() & (1 << ((LocaleToUppercase((
int)
104 (*magick)))-
'A'))) != 0 ? MagickTrue : MagickFalse;
130MagickExport MagickBooleanType NTAcquireTypeCache(
SplayTreeInfo *type_cache,
143 buffer[MagickPathExtent],
144 font_root[MagickPathExtent];
158 reg_key=(HKEY) INVALID_HANDLE_VALUE;
159 res=RegOpenKeyExA(HKEY_LOCAL_MACHINE,
160 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",0,KEY_READ,®_key);
161 length=
sizeof(font_root)-1;
162 if (res == ERROR_SUCCESS)
163 res=RegQueryValueExA(reg_key,
"SystemRoot",NULL,&type,(BYTE*) font_root,
165 if (res != ERROR_SUCCESS)
167 res=RegOpenKeyExA(HKEY_LOCAL_MACHINE,
168 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion",0,KEY_READ,®_key);
169 if (res == ERROR_SUCCESS)
170 res=RegQueryValueExA(reg_key,
"SystemRoot",NULL,&type,(BYTE*) font_root,
173 if (res == ERROR_SUCCESS)
174 res=RegOpenKeyExA(reg_key,
"Fonts",0,KEY_READ,®_key);
175 if (res != ERROR_SUCCESS)
177 (void) ConcatenateMagickString(font_root,
"\\fonts\\arial.ttf",
179 if (IsPathAccessible(font_root) != MagickFalse)
181 font_root[length-1]=0;
182 (void) ConcatenateMagickString(font_root,
"\\fonts\\",MagickPathExtent);
186 font_root[length-1]=0;
187 (void) ConcatenateMagickString(font_root,
"\\",MagickPathExtent);
198 utf8[MagickPathExtent];
201 wide_name[MagickPathExtent],
202 wide_value[MagickPathExtent];
206 while (res != ERROR_NO_MORE_ITEMS)
217 name_length=MagickPathExtent-1;
218 value_length=MagickPathExtent-1;
219 res=RegEnumValueW(reg_key,registry_index,(
wchar_t *) wide_name,
220 &name_length,0,&type,(BYTE *) wide_value,&value_length);
222 if (res != ERROR_SUCCESS)
224 WideCharToMultiByte(CP_UTF8,0,wide_name,-1,utf8,
sizeof(utf8),NULL,
226 if ((pos=strstr(utf8,
" (TrueType)")) == (
char*) NULL)
229 type_info=(
TypeInfo *) AcquireCriticalMemory(
sizeof(*type_info));
230 (void) memset(type_info,0,
sizeof(
TypeInfo));
231 type_info->path=ConstantString(
"Windows Fonts");
232 type_info->signature=MagickCoreSignature;
233 (void) CopyMagickString(buffer,utf8,MagickPathExtent);
234 for (pos=buffer; *pos != 0; pos++)
237 type_info->name=ConstantString(buffer);
238 type_info->description=ConstantString(utf8);
239 type_info->format=ConstantString(
"truetype");
240 type_info->stretch=NormalStretch;
241 type_info->style=NormalStyle;
242 type_info->weight=400;
244 if ((LocaleCompare(type_info->name,
"Symbol") == 0) ||
245 (LocaleCompare(type_info->name,
"Wingdings") == 0) ||
246 (LocaleCompare(type_info->name,
"Wingdings-2") == 0) ||
247 (LocaleCompare(type_info->name,
"Wingdings-3") == 0))
248 type_info->encoding=ConstantString(
"AppleRoman");
250 for (q=utf8; *q !=
'\0'; )
253 token[MagickPathExtent];
255 (void) GetNextToken(q,(
const char **) &q,MagickPathExtent,token);
258 if (LocaleCompare(token,
"Italic") == 0)
259 type_info->style=ItalicStyle;
260 else if (LocaleCompare(token,
"Oblique") == 0)
261 type_info->style=ObliqueStyle;
262 else if (LocaleCompare(token,
"Bold") == 0)
263 type_info->weight=700;
264 else if (LocaleCompare(token,
"Thin") == 0)
265 type_info->weight=100;
266 else if ((LocaleCompare(token,
"ExtraLight") == 0) ||
267 (LocaleCompare(token,
"UltraLight") == 0))
268 type_info->weight=200;
269 else if (LocaleCompare(token,
"Light") == 0)
270 type_info->weight=300;
271 else if ((LocaleCompare(token,
"Normal") == 0) ||
272 (LocaleCompare(token,
"Regular") == 0))
273 type_info->weight=400;
274 else if (LocaleCompare(token,
"Medium") == 0)
275 type_info->weight=500;
276 else if ((LocaleCompare(token,
"SemiBold") == 0) ||
277 (LocaleCompare(token,
"DemiBold") == 0))
278 type_info->weight=600;
279 else if ((LocaleCompare(token,
"ExtraBold") == 0) ||
280 (LocaleCompare(token,
"UltraBold") == 0))
281 type_info->weight=800;
282 else if ((LocaleCompare(token,
"Heavy") == 0) ||
283 (LocaleCompare(token,
"Black") == 0))
284 type_info->weight=900;
285 else if (LocaleCompare(token,
"Condensed") == 0)
286 type_info->stretch = CondensedStretch;
287 else if (LocaleCompare(token,
"Expanded") == 0)
288 type_info->stretch = ExpandedStretch;
289 else if (LocaleCompare(token,
"ExtraCondensed") == 0)
290 type_info->stretch = ExtraCondensedStretch;
291 else if (LocaleCompare(token,
"ExtraExpanded") == 0)
292 type_info->stretch = ExtraExpandedStretch;
293 else if (LocaleCompare(token,
"SemiCondensed") == 0)
294 type_info->stretch = SemiCondensedStretch;
295 else if (LocaleCompare(token,
"SemiExpanded") == 0)
296 type_info->stretch = SemiExpandedStretch;
297 else if (LocaleCompare(token,
"UltraCondensed") == 0)
298 type_info->stretch = UltraCondensedStretch;
299 else if (LocaleCompare(token,
"UltraExpanded") == 0)
300 type_info->stretch = UltraExpandedStretch;
304 (void) CopyMagickString(buffer,utf8,family_extent-utf8+1);
305 (void) StripMagickString(buffer);
306 type_info->family=ConstantString(buffer);
307 WideCharToMultiByte(CP_UTF8,0,wide_value,-1,utf8,
sizeof(utf8),NULL,
309 if (strchr(utf8,
'\\') != (
char *) NULL)
310 (void) CopyMagickString(buffer,utf8,MagickPathExtent);
313 (void) CopyMagickString(buffer,font_root,MagickPathExtent);
314 (void) ConcatenateMagickString(buffer,utf8,MagickPathExtent);
317 type_info->glyphs=ConstantString(buffer);
319 status=AddValueToSplayTree(type_cache,type_info->name,type_info);
320 if (status == MagickFalse)
321 (void) ThrowMagickException(exception,GetMagickModule(),
322 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",type_info->name);
325 RegCloseKey(reg_key);