In what way does Skia use DirectWrite?

753 views
Skip to first unread message

davidx...@gmail.com

unread,
Feb 22, 2016, 10:50:17 AM2/22/16
to skia-discuss
Hello all,
I am interested in whether text drawn using Skia will look the same/similar to text that is drawn using DirectWrite.
I have only just started looking at DirectWrite and Skia so apologies if my question is in fact a nonsensical question.

I can see that MSDN documents that "there are 3 ways to render using DirectWrite"

In Skia source..
I don't see any calls to "ID2D1RenderTarget::DrawText" or "IDWriteTextLayout::DrawTextLayout" as described in "Render using Direct2D"
I see implementations of "IDWriteTextRenderer::DrawGlyphRun" as described in "Render using a Customer Text Renderer" but they don't seem to implement what is requested in the MSDN article.
I don't see any use of "IDWriteBitmapRenderTarget" as described in "Render to a GDI surface"

Could anyone give an overview in what way Skia uses DirectWrite / what it uses DirectWrite for?

Also how does this compare to Chromium's use of DirectWrite, for example can I make an app that draws text using Skia that will look the same as text drawn using chromium?

Many thanks,
Dave.

Kris Cruickshank

unread,
Feb 22, 2016, 10:53:57 AM2/22/16
to skia-discuss
I am also interested in the answers to these questions.

Kind Regards

Kris

Ben Wagner

unread,
Feb 22, 2016, 11:08:09 AM2/22/16
to skia-d...@googlegroups.com
Chromium's text drawing on Windows does use Skia's DriectWrite typeface port, so when using Skia on Windows the rendering will look like Chromium's. As far as rendering glyphs, Skia only uses DirectWrite to create the glyph alpha masks (in SkScalerContext_DW::drawDWMask, using IDWriteGlyphRunAnalysis::CreateAlphaTexture). Skia handles all of the actual blitting through the glyph mask to a destination surface itself.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

davidx...@gmail.com

unread,
Feb 22, 2016, 11:20:06 AM2/22/16
to skia-discuss
Hi,
Thanks for your quick reply. Ok, thanks, I understand (I think) - Skia uses a mix of DirectWrite and Skia custom code to draw text and this is used by Chromium.
Does text drawn using Direct2D/DirectWrite potentially look different from text drawn using DirectWrite-glyphalphamask + Skia blitting? (I'd expect so?)
Thanks,
Dave.

Ben Wagner

unread,
Feb 22, 2016, 11:35:26 AM2/22/16
to skia-d...@googlegroups.com
Skia does not use any of the Direct2D side of things in DirectWrite (unless the internal glyph mask rasterization does, but that seems unlikely). So any differences between Direct2D and Skia would result in differences. In particular, Skia and Direct2D have slightly different sets of capabilities and may default to using DirectWrite in slightly different ways. As a result, I would not expect the code using Direct2D and similar code using Skia to produce pixel identical text (indeed I would find that quite unlikely). This is probably especially true of GPU text rendering. On the other hand, they should be 'mostly' similar.
Reply all
Reply to author
Forward
0 new messages