Language

Some formats include a declaration of which language is being used for a given piece of text. This can be used to influence aspects of the text layout, including the exact choice of glyphs used in a given font. While we make relatively little use of this at present, we try to preserve the information as part of our philosophy of not losing any information unnecessarily.

Accordingly, we use ISO 639 language specification strings, for example:


\begin{lstlisting}
typedef enum fz_text_language_e
{
FZ_LANG_UNSET = 0,
FZ_LAN...
...Z_LANG_zh_Hant = FZ_LANG_TAG3('z','h','t'),
} fz_text_language;
\end{lstlisting}

To save space we pack these into 15 bits. Accordingly, we provide a way to pack/unpack these to/from the more normal string representations:


\begin{lstlisting}
/*
Convert ISO 639 (639-{1,2,3,5}) language specification
s...
...fz_text_language fz_text_language_from_string(const char *str);
\end{lstlisting}

\begin{lstlisting}
/*
Recover ISO 639 (639-{1,2,3,5}) language specification
s...
..._string_from_text_language(char str[8], fz_text_language lang);
\end{lstlisting}