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

Any idea?

-Jim
#2
I know only API functions to get properties of installed fonts by font name.
Did you find how they do it in C++?
#3
All I found was this...have no idea how to do in QM
http://stackoverflow.com/questions/1188 ... f-ttf-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)
#5
Big Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)