Skip to content

Conversation

@philipanda
Copy link
Contributor

@philipanda philipanda commented Jul 3, 2025

Description

image
  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

qemu-system-x86_64 -machine q35,smm=on -drive if=pflash,format=raw,unit=0,file=qemu_q35_v0.2.1-rc1.rom

Integration Instructions

@philipanda philipanda changed the title WIP Make most color values into PCDs Setup menu color customization Jul 3, 2025
@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

I just wondered recently when someone will dare to touch CustomizedDisplayLib and play with it :)

We would have to somehow match the Dasharo green colour (on dasharo.com page the hex color for green is #38d430). Of course white and black should also be present.

If I color pick the green from the picture you posted, it gives me #009800 which is not the right one.

@philipanda
Copy link
Contributor Author

I just wondered recently when someone will dare to touch CustomizedDisplayLib and play with it :)

We would have to somehow match the Dasharo green colour (on dasharo.com page the hex color for green is #38d430). Of course white and black should also be present.

If I color pick the green from the picture you posted, it gives me #009800 which is not the right one.

CustomizedDisplayLib only supports a small color palette which looks similar to VGA color palette. There are a total of 8 possible background colors and 16 text colors, so sadly there is little possibilities to play with.

There are only two green shades possible for text - green and light green, for backgrounds its only the green you see.

I can't tell if it would be feasible to extend the color palette. It might be more challenging than just exposing the colors as PSDs.

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

I think it will be inevitable to change mGraphicsEfiColors table in MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

Also we have to take care of serial terminal colors in TerminalConOutSetAttribute (MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c)

Also you may try to change the font to something more close to what we use on dasharo.com (I believe it is oswald font regular-400 or a Font Awesome 6 regular-400)

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 3, 2025

Colors taken from dasharo.com that I suggest that may be suitable:

DARKGRAY - #29363b
LIGHTGRAY - #808080
LIGHTGREEN - #38d430

@philipanda
Copy link
Contributor Author

philipanda commented Jul 5, 2025

I've exposed the hex color palette as PCDs too and come up with this color scheme in graphics mode using the hex values you've given:
image

There are only 8 possible background colors, so I had to do some non-obvious "reshades":

  • EFI_LIGHTCYAN -> #FFFFFF
  • EFI_LIGHTGREEN -> #38d430
  • EFI_BROWN -> #29363b
  • EFI_LIGHTGRAY -> #808080

For now it doesn't look that great via serial though ;)
image

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 7, 2025

For now it doesn't look that great via serial though ;)

Of course it doesn't :) Check out this: https://gist.github.com/viniciusdaniel/53a98cbb1d8cac1bb473da23f5708836
Maybe the 88/256 colors are supported. If not, then it would have to be implemented in TerminalConOutSetAttribute
Currently I believe we use 8/16 colors only as they are widely supported. The 88/256 palette seem to be supported by just a handful of terminals. There is also 24bit color: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit (then maybe the same graphics RGB notations could be used in serial terminal)

@miczyg1
Copy link
Contributor

miczyg1 commented Jul 7, 2025

Couple more suggestions to the color selection:

  1. Option text (Intel ME mode) and simple text (Press ESC to exit) colors maybe should be reversed? Options green and text gray. Help text is good though.
  2. Originally the hotkey help section had a black foreground to stand out a bit differently. Can it stay black? It would probably look good with green hotkey help strings.
  3. Help section should be darker. It barely stands out from the foreground:

image

@philipanda
Copy link
Contributor Author

I think it will be inevitable to change mGraphicsEfiColors table in MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

Also we have to take care of serial terminal colors in TerminalConOutSetAttribute (MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c)

Also you may try to change the font to something more close to what we use on dasharo.com (I believe it is oswald font regular-400 or a Font Awesome 6 regular-400)

That might be more troublesome than expected 😆
It seems that the font used by GraphicsConsole.c is defined at /MdeModulePkg/Universal/Console/GraphicsConsoleDxe/LaffStd.c. That is a huge array that maps Unicode glyphs to bitmaps made of hex bytes.

Adding a support for vector fonts might be a little too much for now, but maybe it could be feasible to create a tool that could convert vector fonts into bitmaps like the one defined in LaffStd.c.

@philipanda
Copy link
Contributor Author

philipanda commented Jul 12, 2025

I've been fiddling around with converting the Oswald font to bitmaps. The results seemed promising, but in the end I think it will not be possible to properly display a proper vector font in 19x8 resolution.

That's the best results I was able to achieve. While it's possible to do some postprocessing to fix jagged edges, losing detail is inevitable. Creating such a small font requires working with pixel art.

image

The scripts for the conversion are on a separate branch as I will scrap that idea for now.

@macpijan
Copy link
Contributor

macpijan commented Jul 14, 2025

Yeah the font does not look great and would require more work.

The colors look interesting, though.

@philipanda philipanda force-pushed the setup-menu-color-customization branch from aa35540 to cb616c6 Compare September 12, 2025 10:22
@philipanda philipanda force-pushed the setup-menu-color-customization branch from cb616c6 to 145ff2b Compare September 16, 2025 07:44
@philipanda
Copy link
Contributor Author

Looks like the 256 colors mode might work easily on terminals that support it.
It's enough to modify the escape codes produced by the TerminalConOutSetAttribute. I don't think there would be a simple way of knowing what color modes the client terminal understands though, so the compatibility with simple terminals might get worse.

I've tried hardcoding this pinkish color for every printed character. I think I've messed something up with the escape codes, but the color definitely looks like the one I've requested (213).
image

@philipanda
Copy link
Contributor Author

philipanda commented Sep 21, 2025

And the 24 bit mode works perfectly too, at least on Gnome terminal.
The amount of work that would be needed to implement any of them seem to be similarly low. It would require only modifying how TerminalConOutSetAttribute encodes the 16 color EFI color palette into escape codes.

The color used here is the Dasharo green #38d430.
The only little issue is that the color needs to be convered from hex to decimal to use in an escape code.
image

When accessing the serial without the 24b truecolor support using xterm:

xterm -cm

Nothing is broken, just that there are no colors:
image

I think 24b color would be the best solution. I had a hard time trying to stop my terminal from interpreting them, so that makes me believe that most potential users won't have issues with that and it won't break tests via serial in OSFV.

@philipanda
Copy link
Contributor Author

Using the 24b escape codes the colors work great via on a serial console via telnet on Qemu:
image

Some of the colors, like most of the gray/white text, don't exactly match. I suspect it's an issue with mapping the RGB colors into the 16 EFI colors along the way. Maybe the bright bit is not interpreted correctly when mapping the colors.

@philipanda philipanda force-pushed the setup-menu-color-customization branch from cfd0e7a to 4483433 Compare September 21, 2025 12:13
@philipanda philipanda force-pushed the setup-menu-color-customization branch from 4483433 to 2473d00 Compare September 21, 2025 12:17
@miczyg1
Copy link
Contributor

miczyg1 commented Sep 24, 2025

The only little issue is that the color needs to be convered from hex to decimal to use in an escape code.

Should be easy with %02u formatter for printf.

Some of the colors, like most of the gray/white text, don't exactly match. I suspect it's an issue with mapping the RGB colors into the 16 EFI colors along the way. Maybe the bright bit is not interpreted correctly when mapping the colors.

Yeah, the letters in the top section are far from being white... But hey, it looks neat already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philipanda another mistakenly added change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out. I've commited some random files before too. I think that I'm commiting some artifacts from the build process that I am unaware of. I certainly did not search&replaced something in a binary file 😆. I'll check twice before adding a whole directory next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants