Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Font Name from font file
#4
.NET uses GDI+ for this, and we can.

Macro Macro2240
Code:
Copy      Help
str fontFile="$desktop$\calibri.ttf"

GDIP.GdiplusStartupInput gi.GdiplusVersion=1
GDIP.GdiplusStartup(&_i &gi 0)
atend GDIP.GdiplusShutdown _i

int r
GDIP.GpFontCollection* c
r=GDIP.GdipNewPrivateFontCollection(&c); if(r) end F"error {r}"
r=GDIP.GdipPrivateAddFontFile(c @_s.expandpath(fontFile))
if r
,out F"failed to load font file, error {r}"
else
,int i n
,GDIP.GdipGetFontCollectionFamilyCount(c &n)
,ARRAY(GDIP.GpFontFamily*) a.create(n)
,GDIP.GdipGetFontCollectionFamilyList(c n &a[0] &n)
,
,BSTR b.alloc(100)
,for(i 0 n)
,,if(GDIP.GdipGetFamilyName(a[i] b 0)) out "failed"
,,else _s.ansi(b); out _s
,
,;for(i 0 n) GDIP.GdipDeleteFontFamily(a[i]) ;;don't

GDIP.GdipDeletePrivateFontCollection(&c)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)