diff --git a/kitty/cell_fragment.glsl b/kitty/cell_fragment.glsl index 8803ef5d4..976660290 100644 --- a/kitty/cell_fragment.glsl +++ b/kitty/cell_fragment.glsl @@ -103,17 +103,18 @@ vec4 vec4_premul(vec4 rgba) { #ifdef NEEDS_FOREGROUND // sRGB luminance values const vec3 Y = vec3(0.2126, 0.7152, 0.0722); +const float gamma_factor = 2.2; // Scaling factor for the extra text-alpha adjustment for luminance-difference. const float text_gamma_scaling = 0.5; float linear2srgb(float x) { // Approximation of linear-to-sRGB conversion - return pow(x, 1.0 / 2.2); + return pow(x, 1.0 / gamma_factor); } float srgb2linear(float x) { // Approximation of sRGB-to-linear conversion - return pow(x, 2.2); + return pow(x, gamma_factor); } float clamp_to_unit_float(float x) { diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 7a92ef0b1..358044b5c 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -236,8 +236,8 @@ the curl will peak once per character, with dense twice. opt('text_old_gamma', 'no', option_type='to_bool', ctype='bool', long_text=''' -If to simulate the old gamma-incorrect blending for the text alpha-channel, this -will make some text appear like the strokes are uneven. Dark text on bright backgrounds +Revert to using the old (pre 0.28) gamma correction algorithm when rendering text. +This will make some text appear like the strokes are uneven. Dark text on bright backgrounds will also look thicker while lighter text on darker backgrounds will look thinner. ''' ) @@ -245,26 +245,22 @@ will also look thicker while lighter text on darker backgrounds will look thinne opt('text_gamma_adjustment', '1.0', option_type='positive_float', ctype='float', long_text=''' -This setting adjusts the thickness of darker text on lighter backgrounds. Increasing the value +Adjust the thickness of darker text on lighter backgrounds. Increasing the value setting will make the text appear thicker while decreasing the value will make it thinner. It can compensate for some fonts looking too-thin when using the gamma-correct alpha blending. The result is scaled based on the luminance difference between the background and the foreground. Dark text on light backgrounds receive the full impact of the curve while light text on dark -backgrounds are affected very little. - -Range: >=0.01 -MacOS: 1.7 +backgrounds are affected very little. Valid values are 0.01 and above. For macOS like text rendering, +a value of ~1.7 usually works well. ''' ) opt('text_contrast', '0', option_type='positive_float', ctype='float', long_text=''' -Additional multiplicative text contrast as a percentage, will saturate and cause jagged edges if set too high. - -Range: >=0.0 -MacOS: 30 +Increase text contrast further. This will cause jagged edges due to over saturation if set too high. +The value is a percentage from 0 to 100. For macOS like text rendering, a value of 30 usually works well. ''' ) egr() # }}} diff --git a/kitty/shaders.c b/kitty/shaders.c index 3af305e7d..4594e980f 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -30,12 +30,12 @@ typedef struct { static const SpriteMap NEW_SPRITE_MAP = { .xnum = 1, .ynum = 1, .last_num_of_layers = 1, .last_ynum = -1 }; static GLint max_texture_size = 0, max_array_texture_layers = 0; -GLfloat +static GLfloat srgb_color(uint8_t color) { return srgb_lut[color]; } -void +static void color_vec3(GLint location, color_type color) { glUniform3f(location, srgb_lut[(color >> 16) & 0xFF], srgb_lut[(color >> 8) & 0xFF], srgb_lut[color & 0xFF]); } @@ -234,7 +234,7 @@ init_cell_program(void) { #define CELL_BUFFERS enum { cell_data_buffer, selection_buffer, uniform_buffer }; ssize_t -create_cell_vao() { +create_cell_vao(void) { ssize_t vao_idx = create_vao(); #define A(name, size, dtype, offset, stride) \ add_attribute_to_vao(CELL_PROGRAM, vao_idx, #name, \ @@ -257,7 +257,7 @@ create_cell_vao() { } ssize_t -create_graphics_vao() { +create_graphics_vao(void) { ssize_t vao_idx = create_vao(); add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER); add_attribute_to_vao(GRAPHICS_PROGRAM, vao_idx, "src", 4, GL_FLOAT, 0, NULL, 0);