-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't seem to be any way to use LCD font rendering? #68
Comments
Try using Surface::makeRaster version that accepts SurfaceProps. In these props, set PixelGeometry to RGB_H. Then see if it helps |
Thanks, but it didn't help. Also tried the other geometries and several tweaks to the other parameters, no difference observed. Slightly modified code and result below.
|
I can't get your example to work either, but inserting your font creation & text drawing in a project which creates a surface via |
Try new |
Those two things combined work! |
Yes, for me too! Still not sure what the exact settings should be. (PixelGeometry.BGR_H also "works" but presumably I need somehow to query the user's monitor's pixel geometry? I imagine there's something somewhere in AWT to do this). A quick question, I notice the kerning is not the same as Chrome's in all cases. For example "Wo" are closer together in Chrome. Decimal numbers e.g. 0.0 also closer together in Chrome. I had imagined kerning rules were somehow just a property of the font, but is there some external "kerning engine" in play? What are my chances of matching Chrome better? (This probably isn't a "bug" as such as I suppose Skija doesn't promise to exactly emulate e.g. Chrome. So I'm not raising it as a an Issue at this point!) |
Did you try the possible |
Yes, that’s the idea. ClearType only works when displayed 1:1 on LCD monitor with exact pixel order.
You should try for sure, but from my experience both AWT and JavaFX are consistently getting subpixel aliasing wrong, so I would not have high hopes for that. Better to go to WinAPI directly
I’m pretty sure it should be doable. I would even aim for Windows native font rendering, as it is what you really need to match. |
One bit relevant to the font rendering is: you should always render font at 1:1 scale. If you scale your canvas, it will look wrong From here https://issues.skia.org/issues/40042307:
|
NOTE: originally posted to the old (jetbrains) repository by accident: here. @tonsky replied with example which suggested that FontEdging achieves this. It does not! More below.
I couldn't find anything which looked like it would do this in the source.
I note that in SkiaSharp this is achieved via SKPaint.LcdRenderText property.
Have I missed something? Could this be added?
Is there any workaround/hack to access this?
It seems to me that getting font rendering to look exactly like it does in Chrome and other Skia based apps would be one of the biggest reasons for trying/using skija, so this seems pretty major to me.
Response in the old forum linked to an example which uses FontEdging.SUBPIXEL_ANTI_ALIAS presumably intended to force LCD rendering. (I couldn't actually figure out how to run it, but my example using FontEdging is below:)
The results are as follows, using ANTI_ALIAS top, SUBPIXEL_ANTI_ALIAS bottom:
As you can see, so-called SUBPIXEL_ANTI_ALIAS does not perform subpixel rendering. Every pixel in the image is grey. I'm not sure what it is actually doing, but it isn't subpixel rendering which uses distinct values for red, green and blue.
The SkiaSharp LcdRenderText property can be seen in action about one third way down this page and it enables real LCD subpixel rendering (there is some blown-up text demonstrating this).
Many thanks.
The text was updated successfully, but these errors were encountered: