问题
Excuse my idiotic question, but I can't seem to find even one satisfying answer from the internet. I mean we can see character 'X' displayed on the screen right from the PC's start screen. But how would the computer know that the bit patterns is translated to 'x'? Who gives such definitions? Is it the BIOS, the OS, the CPU or the display driver or the apps?
回答1:
It depends at which moment, and with which operating system, and on which hardware. For Linux on a current x86 PC desktop:
At early boot time, it uses the VGA driver (and the BIOS also has some limited display functions). IIRC, the original VGA cards had some ROM containing a fixed width font, and that is still used (in some compatibility mode).
IIRC, graphics cards have a ROM for the BIOS and for their initial VGA font. But this is only used at BIOS time or during the early boot process.
But most of the time, a Linux desktop uses its X11 server Xorg. The server manages fonts, and display them using the graphics video card (which often has a GPU), probably by copying appropriate bitmaps. The X11 protocol knows about fonts, but today most applications use the client side Xft.
The future Wayland architecture would have fonts on the client side.
You might look on OsDev, it has several related pages.
Low-level graphics libraries like libSDL or OpenGL (or Xlib) have functions to draw text in an arbitrary font, e.g. XDrawText originally, or XftDrawString
with Xft.
High-level graphical user interface toolkits like Qt or Gtk provide widgets with text display, generally around their event loop.
In the gory details, things are complex and hardware specific (and sadly, some graphics cards manufacturers -e.g. Nvidia- don't publish the specification of their hardware - so it needs to be reverse engineered). This is why you use an operating system which will provide you some abstraction to code on.
来源:https://stackoverflow.com/questions/26700077/who-teaches-the-cpu-a-b-c