Monday, April 10, 2023

font, 2D drawing on linux

 Here come several basic concept for font, drawing on linux



  • font
    • Anti-aliasing and subpixel rendering, see "A Closer Look At Font Rendering" for concept introduction. 
      • black and white rendering is first generation rendering and print still use it.
      • gray-scale rending (anti-aliasing) is second generation rendering to utilize controlling the brightness of each pixel.
      • subpixel (ClearType in windows) is third generation rendering to utilize controlling pixel colors. it is for LCD on which screens, the red, green and blue subpixels that control the color and brightness of the pixel.
      • Archlinux enable Anti-aliasing and subpixel by default.
    • font configuration on Archlinux wiki introduce default configuration for Archlinux.
  • fontconfig/freetype/pango
    • Very good overview introduction: Modern text rendering with Linux: Overview
    • Text Rendering Notes
    • Font basic concept introduction, see CSS Fonts Module Level 3


    • pango
      • what pango is doing: "here's a piece of text render it in this box I don't care what you do." from link.
      • See one pango code example: link.
      • harfbuzz is text shaping engine which is incorporated into Pango .
      • pango-view --font=monospace --language=zh 1.txt or pango-view --height=300 --width=100 --font=monospace --language=zh 1.txt

  • fontconfig
    • user guideline: fonts-conf
    • pattern, element: 
      • font patterns may contain essentially any properties, fontconfig use pattern to query fonts. element is which properties are listed on output
      • basic syntax of pattern are: <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>, see "Font Names" section of fonts-conf
      • fc-list also use this pattern, see link. 
    • fc-list  lists  fonts  and  styles available on the system for applications using fontconfig. if no font match query pattern, then nothing return. If wrong pattern used, then fc-list output result of "fc-list", see link. fc-list not read configuration file.
    • fc-match  matches pattern (empty pattern by default) using the normal fontconfig matching rules to find the best font available.
    • fc-query  queries font-file(s) using the normal fontconfig rules and prints out font pattern for each face found. fc-qury not read configuration file.
    • charset
      • charset is Unicode chars encoded by the font.
      • charset from output of fc-list and fc-match is base85, not human-readable, see link for detai.  
      • The difference Between Unicode and UTF-8, see link and link.
        • Encoding translates numbers into binary. Character sets translates characters to numbers.
        • Unicode is a character set. UTF-8 is encoding. 
        • Unicode is a list of characters with unique decimal numbers (code points). A = 65, B = 66, C = 67, ....
        • This list of decimal numbers represent the string "hello": 104 101 108 108 111
        • Encoding is how these numbers are translated into binary numbers to be stored in a computer:
        • UTF-8 encoding will store "hello" like this (binary): 01101000 01100101 01101100 01101100  01101111
      • 4E00 is for one of CJK unicode charset, see link
    • lang, see CSS Fonts Module Level 3 - 6.2. Language-specific display
      • "lang causing a glyph change on the same codepoint given", see link
      • No zh, but using :lang=zh-cn

No comments: