[HarfBuzz] DirectWrite backend for HarfBuzz

Nikolay Sivov bunglehead at gmail.com
Fri Sep 11 14:45:17 PDT 2015


On 12.09.2015 0:12, Ebrahim Byagowi wrote:
> On Fri, Sep 11, 2015 at 4:53 PM, Bas Schouten <bas at basschouten.com
> <mailto:bas at basschouten.com>> wrote:
>
>     Harfbuzz is MIT licensed right? I have no problem with that code
>     being used and distributed under the MIT license.
>
> Thank you very much :)
>
>
> On Fri, Sep 11, 2015 at 11:41 AM, Nikolay Sivov <bunglehead at gmail.com
> <mailto:bunglehead at gmail.com>> wrote:
>
>     The only reason to use GdiInterop is to enable GDI font
>     substitution/resolution. If you don't need that dwrite way would be
>     to get system font collection, locate family by name, and use
>     GetFirstMatchingFont() with desired weight/style/stretch triple.
>
> I think in order to use fonts given to harfbuzz by hb_blob I can't query
> system font collection and some fonts may not even available on the
> system, I am missing something here?

If the goal is to use memory buffers for fonts you'll need custom 
IDWriteFontFileLoader and memory based IDWriteFontFileStream 
implementation. After that you'll need to register your loader within 
factory context using RegisterFontFileLoader(). Later you can use 
CreateCustomFontFileReference() to get IDWriteFontFile and finally 
CreateFontFace() using this file to get back fontface instance pointer. 
That's I believe is a proper way to use fonts that are no installed 
system wide, and it should be preferred so you don't have to rely on how 
gdi with realize select font.

>
>     Why do you need this? Dwrite input is supposed to be in WCHARs.
>
> As far as I know dwrite WCHAR is not playing well with non-BMP
> characters and harfbuzz codepoints can not be used as wchar simply, and
> this also being done on uniscribe backend. But am I missing another
> thing here?

Yes, sorry, I guess I glanced quickly and was too fast to comment. 
You're doing hb text buffer to WCHAR text buffer conversion, for some 
reason I thought it was the other way around.

>
>
>         +  hr = analyzer->GetGlyphs(pchars, length,
>         +    fontFace, FALSE,
>         +    buffer->props.direction,
>         +    &runHead->mScript, NULL, NULL, NULL, NULL, 0,
>         +    maxGlyphs, clusters, textProperties,
>         +    glyphs, glyphProperties, &actualGlyphs);
>
>
>     How can this work if you never pass run text to it? Not to mention
>     locale. Also looks like you only try with runHead, so the rest of
>     runs are ignored?
>
> Well, it works, but may I don't know how also :) Locale done
> <https://github.com/ebraminio/harfbuzz/commit/99183a34e5f7e0a7c87281789e97a04d7e7cf16a>,
> while being a little ugly but is working for now. Yes I just assumed
> that we have one run, not pretty but assumption I guess for now.

Yeah, again I was too eager to comment, and being used to C most of the 
time when dealing with COM method calls I didn't spot that you pass text 
and length. The remaining problem is that you pass all of it at once, 
but what actually should happen is that you should pass text pointer and 
length that corresponds to a run you're about to shape - now you use 
script ID for first run assuming that it's the same for the rest of the 
text, which is not necessary true of course. Same goes for direction and 
locale - those should be specific to each run.

>
> Thank you for the reviews :)
>
>
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>



More information about the HarfBuzz mailing list