Repository navigation
The Reader now marks each part of a document in the language the document declares for it, and lets you choose a document's language when the file has it wrong — as six of the seven tagged Romanian public PDFs measured do. Text with control characters in it now copies and pastes in full.
What changes for a reader
The language a document is read in
- Parts of a document are marked in their own language (#49). A tagged PDF can declare a language for any heading, paragraph, cell or run of text, and that declaration now reaches the page as
lang, where it differs from the text around it. An English document exported from a Japanese Word — which saysjafor the whole file andenon every run — was read in a Japanese voice from end to end. - Declarations the text cannot bear out are not followed. Word declares a language on every run, and not every declaration is the author's: in the Japanese Word documents measured, digits say English and plain Japanese says Chinese. Marked as declared, a date would be read in three voices. So text with no letters is never marked, Japanese text declared English is not marked English, Han characters declared Chinese inside Japanese are not marked Chinese, and English words declared Japanese are not marked Japanese.
- A document whose every passage declares one language is read in it, when its tags carry most of the page text: the article, the title at the top, and the inferred reading too, which cannot see a passage's language of its own.
- Choose the language of one document, from Document language in the toolbar, in the Reader view (#57, #62). Its first choice, Automatic, says which language that is right now. A language you choose also overrules the file's declarations for its parts, except where the text's writing system shows another language. It is kept for the tab — through a reload — until the tab is closed, when the PDF has an address; nothing about it is synced or kept after that.
- A usual document language, in the settings, off by default (#57). It applies only to a PDF that gives no language beyond the one declared for the whole file, or none at all, and only when the text is written in that language's alphabet. Where the file's language uses the same alphabet —
en-USover what may be Romanian — or the file declares none and the usual language is written in the Latin alphabet, the text must also show letters the usual language has and English does not: ă, ș, ț for Romanian. A language without such letters cannot overrule a declaration in its own alphabet. Measured with Romanian as the usual language, on ten Romanian public PDFs: eight of the nine whose declaration was wrong or missing were read as Romanian; the ninth declares languages for its parts and keeps them. All six English test documents stayed English. - Document information says which language the Reader uses, and why ("Read as"): the PDF's declaration, detection, the structure tags, your usual language, or your choice. The "Language" row beside it is still the PDF's own value.
- The Reader's own words inside a document keep the interface's language: a link's "opens in a new tab", a figure's notice, a page label. Inside a paragraph marked English, a Japanese notice was read in an English voice.
Checked with NVDA on Windows, with automatic language switching on: in Firefox and Chrome, the English Word document above is read in English (in Chrome, its title and the inferred reading too), and a Japanese Word press release stays Japanese through its dates and figures, switching only for its English words. In Chrome, choosing Romanian for a Romanian PDF declared en-US reaches NVDA as a switch to Romanian, and the choice survives a reload; this was checked with the choice in Document information, before it moved to the toolbar (#64). The toolbar control itself was checked on screen only, at narrow window widths. The choice and the usual language were also checked on screen in Firefox. Not heard in a Romanian voice: the machine had none.
Copying text
- Control characters no longer cut a copy short (#51, #53). A Word document whose logos' alternative text ended in a NUL character pasted only its first few lines from "Copy Markdown", because the Windows clipboard ends text at a NUL. Control characters are now removed from everything the Reader shows — body text, headings, tables, captions, alternative text, the title — and from the Markdown view, as shown and as copied. Line breaks and tabs are kept.
- The Markdown view follows the interface language when it is switched with the view open.
Firefox
- The view switch's list is readable in the light theme (#55). The highlighted entry was dark text on a dark background.
Not changed yet
- A PDF whose only language declaration is wrong is read in that language until you choose another. Detecting the language from the text (#56) and recognising a Japanese document declared English (#54) are not done.
- Bullets drawn from the Symbol or Wingdings font show as a box, beside the list's own marker; with NVDA in Chrome, one such document was heard reading them as an extra bullet (#59).
- In some fonts, the inferred reading loses the letters "ti" where the font draws them as one glyph (#60).
- The interface is in English and Japanese only (#61).
Under the hood
- Each run of text keeps what the file declared for it apart from the language it is shown in, so a document can be settled again when its language changes.
- One function decides a document's language and where it came from (
chooseDocumentLanguages), for every reading. - The usual document language is one more setting in the browser's sync storage; the per-document choice is in the Reader tab's session storage, with the document's address, until the tab closes.
Pull requests: #50, #51, #53, #55, #58, #64.
日本語
文書の各部分に、その文書が宣言している言語を付けるようにしました。ファイルの言語の宣言が誤っているときは、利用者が文書の言語を選べるようになりました。手元で測ったルーマニア語の公開 PDF のうち、構造タグ付きの 7 個では、6 個の宣言が誤っていました。また、制御文字を含む文書も、最後までコピーして貼り付けられるようになりました。
文書を読む言語
- 文書の各部分に、その部分の言語を付けるようにしました(#49)。構造タグ付きの PDF は、見出し、段落、表のセル、文中の一部分ごとに言語を宣言できます。その宣言を、周りと言語が違う部分にだけ
langとして付けます。日本語版の Word で書き出した英語の文書は、文書全体をja、各部分をenと宣言しています。これまでは、最初から最後まで日本語の音声で読まれていました。 - 文字と矛盾する宣言には従いません。 Word は文中のすべての部分に言語を宣言しますが、その全部が作成者の意図とは限りません。測った日本語の Word 文書では、数字に英語が、普通の日本語に中国語が宣言されていました。宣言どおりに付けると、日付が 3 つの音声で読まれます。そこで、文字(字母)を含まない部分には付けず、英語と宣言された日本語の文や、日本語の中で中国語と宣言された漢字、日本語と宣言された英字の語にも付けません。
- 文書のすべての部分が同じ言語を宣言していれば、その言語で読みます。 構造タグがページの文字の大部分を覆っている場合に限ります。記事全体、上部の題名、推測の読み取り(部分ごとの言語がわからない読み取り方)も、その言語になります。
- 文書ごとに言語を選べるようになりました(#57、#62)。ツールバーの「文書の言語」から選べます(リーダーの表示のとき)。最初の選択肢の「自動」には、今使っている言語が表示されます。言語を選ぶと、ファイル側の部分ごとの宣言も使わなくなります。ただし、文字の種類で明らかに別の言語とわかる部分は残します。選んだ言語は、PDF にアドレスがあれば、再読み込みしてもタブを閉じるまで使います。同期はせず、タブを閉じたあとには残りません。
- 設定に「よく読む文書の言語」を加えました(#57)。既定は「自動」で、何も変わりません。当てるのは、文書全体の宣言のほかに言語の手がかりがない PDF と、宣言のない PDF だけで、本文がその言語の文字で書かれている場合に限ります。ファイルの言語が同じ文字を使う場合(たとえば
en-USと宣言された、ルーマニア語かもしれない文書)と、宣言がなく、よく読む文書の言語が英字の言語の場合は、その言語特有の文字(ルーマニア語なら ă、ș、ț)が本文にあることも条件です。そうした文字のない言語では、同じ文字を使う言語の宣言を上書きできません。ルーマニア語を設定して、ルーマニア語の公開 PDF 10 個で測りました。宣言が誤っているかない 9 個のうち 8 個がルーマニア語になりました。残る 1 個は部分ごとに言語を宣言しているので、その宣言のままです。英語のテスト用文書 6 個は、すべて英語のままでした。 - 「文書情報」に、Reader が使っている言語と、その理由を表示します(「読み上げの言語」)。理由は、PDF の宣言、推定、構造タグ、よく読む文書の言語、利用者の指定のいずれかです。隣の「言語」の行は、これまでどおり PDF 自身の宣言です。
- 文書の中にある Reader 自身の言葉は、画面の言語で伝えます。 対象は、リンクの「新しいタブで開きます」、図の注記、ページ番号です。これまでは、英語と宣言された段落の中の日本語の注記が、英語の音声で読まれていました。
Windows の NVDA で、言語の自動切り替えをオンにして確かめました。Firefox と Chrome の両方で、上の英語の Word 文書は英語で読まれました(Chrome では、題名と推測の読み取りも確かめています)。日本語の Word の報道発表は、日付や数字も日本語のまま読まれ、英字の語のところだけ英語に切り替わりました。Chrome では、en-US と宣言されたルーマニア語の PDF でルーマニア語を選ぶと、NVDA にルーマニア語への切り替えが伝わり、再読み込み後も選択が残りました。これは、一覧がツールバーに移る前(#64 の前)に、「文書情報」から選んで確かめたものです。ツールバーの一覧そのものは、画面の幅を狭めたときの表示を確かめただけです。文書ごとの指定とよく読む文書の言語は、Firefox でも画面で確かめています。ルーマニア語の音声では聞いていません。確かめたパソコンに、ルーマニア語の音声がなかったためです。
テキストのコピー
- 制御文字のところでコピーが途切れなくなりました(#51、#53)。ロゴの代替テキストが NUL という制御文字で終わっている Word の文書では、「マークダウンをコピー」で貼り付けると、最初の数行しか入りませんでした。Windows のクリップボードは、NUL で文が終わったものとみなすためです。今後は、本文、見出し、表、図の説明、代替テキスト、題名など、Reader に表示するすべての文字と、マークダウン表示(表示もコピーも)から制御文字を取り除きます。改行とタブは残します。
- マークダウン表示を開いたまま表示言語を切り替えると、マークダウンも新しい言語になります。
Firefox
- ライトテーマで、「表示」の一覧が読めるようになりました(#55)。選択中の項目が、暗い背景に暗い文字で表示されていました。
まだ変えていないこと:
- PDF の言語の宣言が誤っていて、ほかに手がかりがない場合は、利用者が選ぶまでその言語で読みます。 本文から言語を推定すること(#56)や、英語と宣言された日本語の文書を見分けること(#54)は、まだできません。
- Symbol や Wingdings のフォントの箇条書き記号は、四角で表示されます。 箇条書き本来の記号と並んで表示されます。NVDA と Chrome で 1 つの文書を聞いたところ、記号が余分に読まれていました(#59)。
- 一部のフォントでは、推測の読み取りで「ti」の文字が抜けます。 フォントが「ti」を 1 つの字形で描いている場合です(#60)。
- 画面の表示言語は、英語と日本語だけです(#61)。