@readium/navigator
Version:
Next generation SDK for publications in Web Apps
20 lines (19 loc) • 999 B
TypeScript
import { Metadata } from "@readium/shared";
export type ScriptMode = 'ltr' | 'rtl' | 'cjk-horizontal' | 'cjk-vertical' | 'mongolian-vertical';
/**
* Derives the script mode from publication metadata.
*
* Rules:
* - Only the first language in the array is used. A Latin book containing
* some Japanese is still Latin.
* - For CJK (zh/ja/ko): both language AND explicit reading progression are
* required. CJK vertical = explicit rtl + CJK language. CJK horizontal =
* CJK language with ltr or unset progression.
* - For RTL (ar/fa/he): language wins. If the primary language is a RTL
* script, RTL mode is applied regardless of the explicit progression
* direction declared in the OPF.
* - For Mongolian (mn): Traditional Mongolian script (mn-Mong) uses
* writing-mode: vertical-lr. Cyrillic Mongolian (mn-Cyrl) is standard LTR.
* An explicit script subtag is required; bare `mn` defaults to LTR.
*/
export declare function getScriptMode(metadata: Metadata): ScriptMode;