Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Font Name from font file
I need to get the font name from fonts in a directory.

Any idea?

I know only API functions to get properties of installed fonts by font name.
Did you find how they do it in C++?
All I found was this...have no idea how to do in QM ... f-ttf-file
.NET uses GDI+ for this, and we can.

Macro Macro2240
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}"
,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

Big Thanks!

Forum Jump:

Users browsing this thread: 1 Guest(s)