Just pushed two big changes - deferred clipping and much better support for custom fonts.
Turns out the renderer was doing quite a bit of unnecessary clipping of areas that were already clipped. Now, the renderer consolidates the clipping regions and only applies the clipping when instructed to actually draw something. This makes a significant difference if you have a complex UI with many components, especially if the components have many siblings.
I also received several bug reports about handling custom fonts. Turns out that much of the DirectWrite code in JUCE was just using the system font collection, which did not include any custom fonts. Now, any custom fonts are aggregated together with the system font collection. That means if you create your custom typeface as usual:
auto hindTypeface = Typeface::createSystemTypefaceFor(BinaryData::HindRegular_ttf, BinaryData::HindRegular_ttfSize);
you should then see that same font listed if you call Font::findAllTypefaceNames and so forth. That should resolve a lot of the custom font issues.
Would this help in getting textlayout fallback font working with custom font ?
Right now custom font were not considered as d2d fonts hence would not support fallback when glyph were not found
I really appreciate your work. However, I find some very strange behaviours (seems to be related to clipping). The test repo is here (I build it with github actions):
This is how it looks like without direct2D:
Let’s look at the ellipse at the left hand side. I saveState, setup a clip region and draw a bright shadow (left-top corner) and a dark shadow (right-bottom corner). Then I restoreState and draw the ellipse at the center.
Thanks for the quick fix. Now the shadow looks much better I can’t wait to render the FFT spectrum with it so that I won’t freeze the DAW UI with previous CPU rendering.
I have just tried teh direct2d on the spectrum: AWESOME, fast and no more frozen UI.
However, some components look kind of blurry. I look at my code, and they are components with setBufferedToImage(true). And it seems that it cause more problems.
I am not sure whether it is related to the monitor setting (I am using Windows VM on Intel macOS right now):
Without setBufferedToImage(true) or without direct2d:
On the left hand side, you can drag a button and two sliders will move with the button. On the right hand side, if you click the black rectangle on the top, a CallOutBox which contains two sliders pops up. Everything looks correct.
First, everything becomes blurry a little bit. Second, when I drag the button on the left side, it leaves some black pixels on the white background. What’s more, the first slider also disappears (randomly).
Hi @zsliu98 - Please try the latest commit on the direct2d branch.
I tried it at 250% DPI scaling and it looked good to me. I still see some ghost lines at 125% DPI scaling, but those also show up if I build with the JUCE develop branch, so it’s probably not related to Direct2D.
Hi, I have just updated the test repo to the latest commit on direct2d.
Unfortunately, the dragger disappears randomly and the two sliders (on the left panel) become invisible. The two sliders (on the right panel) also look strange. And they are still blurry.