Question

In the X11 protocol specification, a type called CHAR2B is defined, which is just a struct of two bytes: byte1 and byte2. The type is used in only two requests, QueryTextExtents and ImageText16, both to specify the name of fonts.

My question is this: what is the point of CHAR2B and how is it used? The type seems pointless to me because:

  • There's a request called ImageText8 which takes just string of bytes as font name as opposed to string of CHAR2B in ImageText16.
  • Many other requests take common "string of bytes" as input rather than "string of CHAR2B", such as QueryExtension, InternAtom, OpenFont, etc.
  • CHAR2B is only used in 2 requests.

Given that CHAR2B is part of the X11 protocol, how does one go about using it? What is the encoding? UTF16? Some other type of two-byte encoding?

Was it helpful?

Solution

  1. It is used to specify the text to be displayed, not any font name.
  2. It is used in 3 requests (PolyText16). These requests, and their 8-bit counterparts, are the only requests that deal with displaying text.
  3. CHAR2Bs are indices in the font being used to display text. The document you link very clearly states that

    The primary interpretation of large characters in a STRING16 is that they are composed of two bytes used to index a two-dimensional matrix, hence, the use of CHAR2B rather than CARD16. This corresponds to the JIS/ISO method of indexing 2-byte characters. It is expected that most large fonts will be defined with 2-byte matrix indexing. For large fonts constructed with linear indexing, a CHAR2B can be interpreted as a 16-bit number by treating byte1 as the most significant byte. This means that clients should always transmit such 16-bit character values most significant byte first, as the server will never byte-swap CHAR2B quantities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top