S or /

SourceEnum FontColorTransferFunction

from egui import FontColorTransferFunction
FontColorTransferFunction.DARK_MODE_DEFAULT
FontColorTransferFunction.LIGHT_MODE_DEFAULT
FontColorTransferFunction.Off
FontColorTransferFunction.TwoCoverageMinusCoverageSq

How to convert font coverage values into alpha and color values.

epaint stores all glyphs in the font atlas as white (with varying opacity), so that egui can reuse the same glyph for different text colors (with a simple color multiplication in the shader).

Because of this simplification, we need to apply a non-linear ramp to the glyph colors before writing them into the font atlas, as a way to compensate.

This whole thing is less than rigorous.

It would be better to either render all text colors into the font atlas (which would require more atlas space, but would allow for more accurate rendering of colored text and emojis), or do the color compensation in the shader, based on the active text color.

When experimenting, use https://fonts.google.com/specimen/Ubuntu to compare to a ground truth.

See https://hikogui.org/2022/10/24/the-trouble-with-anti-aliasing.html for related analysis.

Variants§

FontColorTransferFunction.DARK_MODE_DEFAULT Enum value§

FontColorTransferFunction.LIGHT_MODE_DEFAULT Enum value§

FontColorTransferFunction.Off Enum value§

FontColorTransferFunction.TwoCoverageMinusCoverageSq Enum value§

Methods§

@staticmethod def Gamma(gamma: float) -> FontColorTransferFunction§
Sourcedef alpha_from_coverage(self, /, coverage: float) -> float§

Convert coverage to alpha.

Sourcedef color_from_coverage(self, /, coverage: float) -> Color32§
def gamma_value(self, /) -> float |None§
def name(self, /) -> str§
Sourcedef to_atlas_color(self, /, input_color: Color32) -> Color32§

How to convert a white color written by the font rasterizer into a color to be written into the font atlas.

Sourcedef to_gamma(self, /) -> float§

Convert this into the closest gamma exponent