~eliasnaur/gio

2 2

Update on the font rendering issue

Details
Message ID
<7c02a900-b099-811f-e324-fc7783e86b95@meessen.net>
DKIM signature
pass
Download raw message
Hello,

Thanks to Egon Elbre, I managed to do a font rendering test.

As some of you have  noticed, text displayed in GIO does appear as crisp 
as it should. A comparison of text rendered with GIO and Nigel Tao’s 
golang.org/x/image/font makes the difference clearly visible. [1]

The text from GIO is obtained from a screen capture, and the text from 
Nigel Tao’s render is obtained from a png. The later is linear in color 
rendering. I don’t know if a screen capture gets a linear colored image. 
I’m using opengl with a cheap graphic card (AMD R5 230) on Ubuntu 20.04 
with a 72 DPI LCD.

The test I did consist in using Nigel Tao’s algorithms to generate the 
paths of the text as polylines. This avoids the use of the bézier curve 
functions of GIO. The result is here [2]. The top text (a) is produced 
by the font render of GIO. The middle text (b) is produced by the GIO 
rendering of the polylines generated by Nigel Tao’s algorithm. The 
bottom text (c) is produced by the Nigel Tao’s font rendering engine.

The differences between a and b are negligible. We can thus conclude 
that the problem does not result from an error in bézier curve 
processing. We can also exclude a problem resulting from misaligned 
text. All texts have the same alignment to pixels.

The three remaining cause I see are:

1. rasterization error

2. gamma correction error

3. opacity management error

A rasterization error seam unlikely but can’t be ruled out. The gamma 
correction would indeed render gray pixel more luminous. But the amount 
here seam big for such an error. An error in opacity management 
(pre-multiplied/non-pre-multiplied opacity) could also be a cause.

I publish this modest intermediate result so that experts in opengl and 
GIO internals could eventually catch on. As a total beginner in opengl 
and GIO, I progress very slowly.

https://imgur.com/jPmpgPy

https://imgur.com/jPmpgPy

https://imgur.com/jPmpgPy

[1] https://imgur.com/jPmpgPy

[2] https://imgur.com/99mPNr0

https://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPyhttps://imgur.com/jPmpgPy

-- 
Bien cordialement,
Ch.Meessen
Details
Message ID
<CASPOI7VR0QC.3N67TXXP5BCJI@themachine>
In-Reply-To
<7c02a900-b099-811f-e324-fc7783e86b95@meessen.net> (view parent)
DKIM signature
fail
Download raw message
Patch: +2 -1 DKIM signature: fail
Thanks for investigating.

You can bypass gamma-correction on Linux (X11, Wayland) and Android with
the following patch:

diff --git internal/egl/egl.go internal/egl/egl.go
index ef59e8dc..5de49bd3 100644
--- internal/egl/egl.go
@@ -204,6 +204,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
	// sRGB framebuffer support on EGL 1.5 or if EGL_KHR_gl_colorspace is supported.
	exts := strings.Split(eglQueryString(disp, _EGL_EXTENSIONS), " ")
	srgb := major > 1 || minor >= 5 || hasExtension(exts, "EGL_KHR_gl_colorspace")
	srgb = true
	attribs := []_EGLint{
		_EGL_RENDERABLE_TYPE, _EGL_OPENGL_ES2_BIT,
		_EGL_SURFACE_TYPE, _EGL_WINDOW_BIT,
@@ -270,7 +271,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
func createSurface(disp _EGLDisplay, eglCtx *eglContext, win NativeWindowType) (_EGLSurface, error) {
	var surfAttribs []_EGLint
	if eglCtx.srgb {
		surfAttribs = append(surfAttribs, _EGL_GL_COLORSPACE_KHR, _EGL_GL_COLORSPACE_SRGB_KHR)
		//surfAttribs = append(surfAttribs, _EGL_GL_COLORSPACE_KHR, _EGL_GL_COLORSPACE_SRGB_KHR)
	}
	surfAttribs = append(surfAttribs, _EGL_NONE)
	eglSurf := eglCreateWindowSurface(disp, eglCtx.config, win, surfAttribs)

Elias

Re: Update on the font rendering issue (fixed !)

Details
Message ID
<a1a276a0-4bc9-8c5d-e698-00821e23cafd@meessen.net>
In-Reply-To
<CASPOI7VR0QC.3N67TXXP5BCJI@themachine> (view parent)
DKIM signature
pass
Download raw message
Hello,

disabling the gamma correction fixes the problem as can be seen here 
[1]. We can see some tiny differences, but that is nothing compared to 
what we had before.

[1] https://imgur.com/5qmYDTk


Le 20/04/2021 à 19:02, Elias Naur a écrit :
> Thanks for investigating.
>
> You can bypass gamma-correction on Linux (X11, Wayland) and Android with
> the following patch:
>
> diff --git internal/egl/egl.go internal/egl/egl.go
> index ef59e8dc..5de49bd3 100644
> --- internal/egl/egl.go
> +++ internal/egl/egl.go
> @@ -204,6 +204,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
>   	// sRGB framebuffer support on EGL 1.5 or if EGL_KHR_gl_colorspace is supported.
>   	exts := strings.Split(eglQueryString(disp, _EGL_EXTENSIONS), " ")
>   	srgb := major > 1 || minor >= 5 || hasExtension(exts, "EGL_KHR_gl_colorspace")
> +	srgb = true
>   	attribs := []_EGLint{
>   		_EGL_RENDERABLE_TYPE, _EGL_OPENGL_ES2_BIT,
>   		_EGL_SURFACE_TYPE, _EGL_WINDOW_BIT,
> @@ -270,7 +271,7 @@ func createContext(disp _EGLDisplay) (*eglContext, error) {
>   func createSurface(disp _EGLDisplay, eglCtx *eglContext, win NativeWindowType) (_EGLSurface, error) {
>   	var surfAttribs []_EGLint
>   	if eglCtx.srgb {
> -		surfAttribs = append(surfAttribs, _EGL_GL_COLORSPACE_KHR, _EGL_GL_COLORSPACE_SRGB_KHR)
> +		//surfAttribs = append(surfAttribs, _EGL_GL_COLORSPACE_KHR, _EGL_GL_COLORSPACE_SRGB_KHR)
>   	}
>   	surfAttribs = append(surfAttribs, _EGL_NONE)
>   	eglSurf := eglCreateWindowSurface(disp, eglCtx.config, win, surfAttribs)
>
> Elias

-- 
Bien cordialement,
Ch.Meessen
Reply to thread Export thread (mbox)