-3

On Windows 10, I am trying to write VBA code to list the Unicode code point ranges in a font.

I was able to use GetFontUnicodeRanges in gdi32.dll, but it does not handle code points beyond xFFFF.

Further research uncovered GetUnicodeRanges (as part of DirectWrite), in Dwrite_1.dll, which should handle all Unicode code points, but that is not on my system (although I have Dwrite.dll which does NOT contain GetFontUnicodeRanges.

I searched SO, the internet at large and Microsoft's web sites but could not find that dll.

Question: Does anyone know how/where I can get a copy of Dwrite_1.dll?

RDan
  • 25
  • 5
  • You don't need the DLL. It's already built into Windows. You just need to use COM to instantiate the DWrite objects and enumerate for the IDWriteFont interface. Everything you need is in the Windows SDK. – selbie Mar 22 '20 at 04:41
  • selbie - Thanks for gettng back to me so quickly. I have spent the day parsing out your answer and applogize for being new to COM. Here is what I am – RDan Mar 23 '20 at 23:08
  • ...here is what I am researching (for the past several hours): 1) What the DWrite objects are and how to instantiate one in VBA. 2) What it means to "enumerate to a particular interface. I found documentation on the DirectWrite API (but no mention of objects unless an interface is an object). Within that API I found the IDWriteFont1 interface and within that interface I found the GetUnicodeRanges Method which is the method I want to use in VBA7. Any further direction on how to use that method in VBA7 code would be much appreciated. – RDan Mar 23 '20 at 23:13
  • What are you really trying to do? Most Windows 10 fonts support a good range of unicode out of box. – selbie Mar 23 '20 at 23:24
  • I am trying to dump out (into a spreadsheet) the code point ranges in each font that is installed on my Windows 10 PC. I can then search that spreasheet to do a couple of things: 1) determine which fonts have a certain character/code point, 2) determine which fonts have certain Unicode "blocks" such as Arrows, Box Drawing. – RDan Mar 24 '20 at 14:34

1 Answers1

1

There is no DWrite_1.dll. You're mixing up the dll with the header file: the GetUnicodeRanges method is implemented in the IDWriteFont1 and IDWriteFontFace1 interfaces, which are supported in the DWrite_1.h header file.

DWrite makes use of COM. You start by calling the DWriteCreateFactory function to get a factory interface — that is, an object that implements the requested factory interface. DWrite has multiple factory interfaces which correspond to different versions --- IDWriteFactory (v1), IDWriteFactory1 (v2), etc., each adding new functionality.

IIRC, VBA makes use of COM, but I've never tried to call into DWrite.dll from VBA. I'd search for discussions on VBA calling into COM interfaces.

Do you really need to do this programmatically? There are tools you can use to inspect fonts. I've long used SIL ViewGlyph; also check out BabelMap.

Peter Constable
  • 2,707
  • 10
  • 23
  • Peter – Thanks so much for getting back to me. I wanted to research the tools you mentioned before responding. Looks like ViewGlyph handles only 1 font at a time. However, BabelMap might actually scan through all the fonts on a PC, so that may do some of what I want. In any case, one or both of those utilities would be valuable to have on my system, so thanks again for that. The other aspect of what I am trying to do with fonts is basically to continue to expand my VBA skills by writing code to do things that I find interesting. – RDan Mar 29 '20 at 00:15
  • In this case, writing code to extract whatever information (data) I can get out of the fonts on my PC. As I mentioned in one of my previous responses, I ultimately envision ending up with a spreadsheet that has information on all the fonts on my Windows 10 PC. That would involve having multiple rows for each font where each row might have a given code point range (i.e., a given font can have multiple code point ranges). – RDan Mar 29 '20 at 00:16
  • I will close out this question as being answered since the responses I have gotten seem to indicate there is no DWrite_1.dll either available (or that maybe ever existed) even though the following Microsoft webpage mentions it in the “Requirements, DLL” area: https://learn.microsoft.com/en-us/windows/win32/api/dwrite_1/nf-dwrite_1-idwritefont1-getunicoderanges. Instead, I will re-open an SO question about writing VBA7 code to access the GetUnicodeRanges method in the IDWriteFont1 interface (through the DWriteCreateFactory function exposed in the DWrite.dll). – RDan Mar 29 '20 at 00:16
  • Peter - To finish, I will also try to use your discussion about VBA, COM and the DWriteCreateFactory which I started looking into (and may have a challenge with REFIID iid parameter). Thanks again. – RDan Mar 29 '20 at 00:20
  • RDan: Huh! That MSDN page is wrong. There is a dwrite_1.h file, but there really has never been a dwrite_1.dll. – Peter Constable Mar 29 '20 at 01:56
  • RDan: As for your project, I started the same thnig a number of years ago: I was working on Indic shaping in GDI (code that is now used in DWrite), and we needed to re-engineer OpenType Layout data in some of the Indic fonts, but we didn't have sources for the 'GSUB' data in a Tamil font. I also wanted something to learn the OT structures in detail. So I wrote routines in Excel VBA to parse the 'GSUB' data into an Excel worksheet. Over the years, I added support for more OpenType tables. The worst part: I never worked out a performant way to write the results into the worksheets. – Peter Constable Mar 29 '20 at 02:04
  • Peter - Nothing like having a problem to solve or a goal in mind to force one into learning new techniques. Those kinds of situations are what has driven my continual learning about VBA. For example, I have a music collection of 7,000+ MP3 files, so I wrote VBA code to pull out the metadata from those binary files....Same for Jpeg files... – RDan Mar 30 '20 at 05:23