geometer / FBReaderJ

Official FBReaderJ project repository
http://www.fbreader.org/FBReaderJ/
1.83k stars 802 forks source link

Only last "dc:title" is used when multiple are present in metadata. #502

Open outis opened 2 years ago

outis commented 2 years ago

Synopsis

When there are multiple dc:title elements in an epub's publication metadata (in the OPF Package Document), FBReader uses the last one (in source order) as the book title, which doesn't match what's done in publications and is incorrect according to standards.

Description

The current Epub standard supports multiple titles, but FBReader does not. The following is valid in an epub:

    <dc:title id="maintitle">Main Title</dc:title>
    <meta property="title-type" refines="#maintitle">main</meta>
    <meta property="display-seq" refines="#maintitle">1</meta>
    <dc:title id="subtitle">Subtitle</dc:title>
    <meta property="title-type" refines="#subtitle">subtitle</meta>
    <meta property="display-seq" refines="#subtitle">2</meta>

FBReader won't use "Main Title" but rather "Subtitle" as the book's title, despite the former having a title-type of "main" and occurring first in the document order.

Something similar to the example occurs in various books I've read, but since they're copyrighted, I can't attach those. Instead, I can do one better: reprexes. The following epubs (submitted as ZIPs, since GitHub doesn't allow epub), one with #maintitle last, the other with #subtitle last, demonstrate this behavior:

Expected result

The first dc:title, or the dc:title with title-type of "main" (and the lowest display-seq) is displayed as the book's title wherever the book's title is used (e.g. the library, book info, the reader's title bar). Additional titles might (or might not) be displayed as well as part of the title.

Actual result

The dc:title that appears last in the source is used as the book's title.

System Info

Platform: Android FBReader version: 3.0.35

geometer commented 2 years ago

Thanks. Implemented in 2.0 for desktops and will be ported to Android and iOS sooner or later.