Towards the Automation of Book Typesetting: System
2024-7-20 20:0:19 Author: hackernoon.com(查看原文) 阅读量:5 收藏

Authors:

(1) Sérgio M. Rebelo, University of Coimbra, Centre for Informatics and Systems of the University of Coimbra, Department of Informatics Engineering, Coimbra, Portugal and a Corresponding author;

(2) Tiago Martins, University of Coimbra, Centre for Informatics and Systems of the University of Coimbra, Department of Informatics Engineering, Coimbra, Portugal and a Corresponding author;

(3) Diogo Ferreira, University of Coimbra, Centre for Informatics and Systems of the University of Coimbra, Department of Informatics Engineering, Coimbra, Portugal and a Corresponding author;

(4) Artur Rebelo, University of Coimbra, Centre for Informatics and Systems of the University of Coimbra, Department of Informatics Engineering, Coimbra, Portugal.

3. System

We developed a computer system to automatically typeset books from content provided by the user. This system is developed as a computer script that operates inside Adobe InDesign software which is popular among graphic designers working in the field of typography. We idealised and implemented the system to take advantage of the typeset functionalities supplied with InDesign, which can be controlled via scripting. By integrating the system with InDesign, we allow users to generate design variations and easily edit them within a familiar working environment. One can find demonstration videos in the supplementary files. To install the system in the InDesign environment, the user only needs to copy the folder that contains the system files to the scripts folder in the application directory. To facilitate access to the system, we also made available a script that creates a dedicated tab for the system in the InDesign navigation menu. The system installation files and source code are available at https://cdv.dei.uc.pt/2019/scriptedpages. [1]

In the following subsections, we describe the user interface of the system and explain how its engine works.

2.1 Interface

Figure 2 shows different snapshots of the user interface built to enable the interactive control of the inner workings of the system. The user interface is structured in a series of five tabs. In each tab, one can set specific properties of the composition or let the system choose automatically based on a set of predefined rule-based values for those properties.

The first interface tab “Document” (Figure 2a) concerns the structural characteristics of the document. It allows the user to set the page size, margins, number of columns and gutter. There is also an option to import settings stored in a file.

In the second tab “Input” (Figure 2b), the user provides the content of the book to be typeset. To that end, the interface offers two options. The first option is to load a Microsoft Word file containing only text, text and images, or only images. The second option is to load a Microsoft Word file containing only the text and a folder containing the images. For this second option, the place where each image should be inserted must be identified in the text using a tag @imageFileName@, which will be replaced by the image with the same name contained in the loaded folder. In addition, the user can choose whether to generate a table of contents and/or colophon for the book. The last option of this tab allows the user to select the language of the input text so that it is possible to correctly hyphenate words.

The third tab “Styles” (Figure 2c) concerns the definition and mapping of paragraph styles. The user has three options to choose from. The first option is to keep the styles imported from the input Word document. The second option is to map each style of the input document to another paragraph style selected, manually or randomly, from a list created from all fonts installed on the computer, while keeping the remaining paragraph attributes. The last option is to let the system generate the styles, suggesting font combinations based on the rules entered in the system (these rules are explained in the next subsection).

In the fourth tab “Experimental” (Figure 2d), the user can toggle experimental features that can be applied to the generated book. In the presented version of the system, there are four experimental features: (i) draw a colour background on half of each book page; (ii) draw a colour gradient along the inner and/or outer margins of the pages; (iii) apply a random indentation to each text paragraph; and (iv) make the cover title as large as possible. The purpose of these features is to increase the uniqueness of the resulting designs. The user can also opt to let the system randomly choose if any experimental features should be applied by selecting the checkbox “Surprise me.” Furthermore, new features can be implemented and added to the system at any time.

After interacting with these four tabs of settings, the user can start creating book designs by clicking on the button “Create” located at the bottom right corner of the interface. This button will start the engine of the system which will automatically create a new InDesign document and typeset a new book from the content and settings chosen by the user.

Once the typeset process is complete, the result is presented to the designer as an editable InDesign document. From that moment on, the user can, for instance: (i) adopt the generated book as a final design; (ii) use the generated book as a starting design from which the designer can make any changes or refinements needed; or (iii) continue to use the system to generate more designs until a more suitable design is found.

Figure 2. Snapshots of the system, showing the five different tabs of the user interface: (a) Document, (b) Input, (c) Styles, (d) Experimental and (e) Properties. Demonstration videos of the system can be found in the supplementary files.

There is another interface tab, entitled “Properties” (Figure 2e), which not only overviews the settings used in the generation of a book but also enables the user to save those settings to a file. Later, this settings file can be imported to the system using the first interface tab, as mentioned earlier. This functionality can be useful, for example, to facilitate the typeset of different books using the same settings. This last tab is only accessible after a book is generated. After the generation, it is also made visible a button that enables the user to generate a new book, maintaining the same input document and predefined settings.

2.2 Engine

The system operates based on a series of typographic rules, styles and principles (Table 1) which were identified and collected from literature recognised in the field. This includes the work by Bringhurst [1], Müller-Brockmann [55], Haslam [56], Hochuli and Kinross [2], Hochuli [57], Lupton [58] and Tschichold [59]. The encoding of these rules into the system, enables the typeset process to go through them, one by one, and make typographic decisions on all composition attributes. The rules are stored in a JSON file, which contains the possible configurations (i.e. values or range of values) and, when applicable, their probability rate for each typographic attribute. This file enables easy access to all rules by the system and their quick editing by the designer at any time.

Table 1 Typography rules, styles and principles loaded into the system by default

Following all the encoded typographic rules, the system performs the typesetting process in order to computationally design books. This process consists of seven different sequential steps: (i) Input processing; (ii) Document size and grid definition; (iii) Typeface definition; (iv) Typographic styles definition; (v) Document typesetting; (vi) Experimental features application; and (vii) Cover design. The next subsections further describe each step.

2.2.1 Input Processing

The first step is to load and process the content provided by the user. Once the content is loaded, the system analyses it and extracts data concerning, for example, the text length, number of images and proportion of text in relation to images. This data is important since it allows the system to determine the type of book that it is typesetting, that is, the extracted data may indicate whether the task is to design a long reading book (i.e. 50,000 words or more), a short reading book (i.e. less than 50,000 words), a text and images book, or a book that only contains images. This information, in turn, will enable the system to make typographic decisions in the following steps of the typesetting process.

2.2.2 Document Size and Grid Definition

The next step is to create a new document with the page format and size based on the type of book. Thus, we encoded in the typographic styles, rules and principles a set of available book sizes as well as the probability of being selected for a certain book type. Then, the book size is selected at random based on those probability rates.

In this step, the system also defines the document grid, that is, the size of the margins, the number of columns, and the document baseline. Margins are defined randomly within a present range. The number of columns in the grid is calculated by dividing the width of the available text block by a random integer value chosen within a predefined range. Also, it considers the predefined minimum text block width. Thus, in small page sizes, it will only create one-column grids.

The template pages are defined by creating the template text boxes and placing the running header (with section name) and page numbering. The section name of a page is the last title found in the input document file. The position and size of these elements are defined empirically based on observation and analysis of examples. Currently, the system implements five different ways to compose the headers and page numbering.

2.2.3 Typeface Definition

Then, the system defines the typefaces to be used based on the preferences of the user, who can choose to (i) keep the typefaces used on the input document, (ii) map those typefaces to new ones installed on the computer, or (iii) let the system select the typefaces.

When users decide to map the typefaces of the input document to new ones, they must define the style for each typeface using a font installed on their computers. Typefaces that are not for mapping are defined with the same typeface as in the input document. Additionally, users can determine that the system should map one, or more, typefaces at random.

In the last option, the typefaces are selected from a set of pairs or combinations of fonts which are defined and encoded on the configuration file mentioned above. When selecting the fonts, the system considers the type of book (e.g. long reading or short reading). Each font pair is composed of one typeface for the titles and another for the text body, along with other typographic features that are specific to each font. Table 2 presents the typeface pairing loaded into the system by default.

Table 2. Typeface pairing data loaded into the system by default.

2.2.4 Typographic Styles Definition

The process continues with the definition of the paragraph, character and image styles. For each paragraph style, the following properties are defined: font, weight, size, leading, first line indentation, paragraph indentation, space before and after the paragraph, alignment, vertical alignment, hyphenation, language and colour.

The font, weight, text leading, language initial text size and colour are defined based on the preferences expressed beforehand by the user. The final text size is determined based on the chosen document grid. In this process, the system checks whether the initial typeface size is within the limits defined by the loaded rules and then it composes a text box and confirms that its median number of characters per line is within a predefined range. When the median number of characters is lower or higher than the limits, the system decreases or increases the text size, respectively. This process will continue until a proper text size is reached. When those values are achieved, if yet necessary, the document grid is also modified, namely the margins area and the number of columns. Finally, the first line indentation, paragraph indentation, space before and after the paragraph, text alignment, vertical alignment and hyphenation are defined at random based on the type of book.

The character styles are then defined based on the input document and the paragraph styles, which will be useful for using italics, bolds, small caps, among others. Also, the styles for the images are decided based on the input document and the paragraph style, thus determining their positioning, size, text wrap and effects.

2.2.5 Document Typesetting

Once the base document is created and all the styles are defined, the system proceeds to the actual typesetting of the book. It starts by typesetting the inside of the book. The typesetting of the inside of the book includes a sequence of steps. First, the system positions the body text. Then, the typographic styles defined earlier are applied to the entire content of the document.

The titles on the document are formatted considering three levels of hierarchies defined based on their text size on the input document: (i) chapters titles, i.e. titles in the biggest size and preceded by a page break; (ii) section titles, i.e. titles in a size bigger than the main text font and preceded by a page or a column break; and (iii) subsection titles, i.e. titles in the same size that the body text. Chapter titles are composed isolated on one page. Section titles are typeset on the following page of the document. In multi-column documents, they are placed isolated on the first column; otherwise, they are placed at the beginning of the page. Subsection titles are composed inline on the text of the same size as body text.

Once the typographic styles are applied, the images and the corresponding captions are created automatically. Initially, images are placed inline, with the same width as the column where they are placed. If the book has a multi-column grid and the image is placed on the leftmost column of the document, the system randomly decides whether to change its size to fulfil more than a column. The captions are created automatically based on the name of the input images. For each document, the system determines a caption style based on the available inner space on margins as well as the existence of headers and page numbers. By default, captions can be placed below the images, aligned to the left, or aside the images, centred and vertically rotated 90º.

Finally, the table of contents and colophon are created. As mentioned before, the system interface allows the user to choose whether to create a table of contents and/or colophon. When these options are activated, a table of contents is created based on the titles on the input document and with the same paragraph style as the titles. On the other hand, the colophon with information about the generated book is typeset at the end of the book in the same style as that body text. This information includes a description of this project and parametric details about the specific design of that book, such as size, margins, and the number of columns, among others.

2.2.6 Experimental Features

The use of experimental features is optionally and performed when selected by the user through the interface. As mentioned earlier, new features can be developed and added to the system. The presented version of the system presents the following experimental features regarding the inside of the book. The first one draws a colour background on half of each book page, in a specific layer under the text. The second feature draws a gradient along the inner and/or outer margins of the pages. The margins where the gradient is drawn are defined randomly, being possible for the system to create gradients in both margins. In both experimental features, the background colour is defined randomly based on a set of predefined colours, as soon as the first feature is used. By default, the set of colours includes the following seven CMYK colours: cyan (100,0,0,0); light orange (0,40,100,0); orange (0,60,100,0); red (0,100,100,0); pink (0,39,3,0); yellow (0,0,100,0); and beige (2,14,38,0). Finally, the last feature applies a random indentation to each text paragraph.

2.2.7 Cover design

The last step is the design of the book cover. We developed a method that generates simple typographic compositions with the title of the book (aligned to the top margin) and its author (aligned to the bottom margin) in uppercase letters and in the same font used in the text. The back cover includes information about the computer system that generated the book. The cover background colour is randomly selected from a set of predefined colours. The book title and author(s) need to be defined in the input document using a specific paragraph style. Alternatively, when this information is not specified, the system automatically sets the title to the first sentence of the paragraph composed in the biggest text size in the input document.

Experimental features also can be developed and applied to the covers. For instance, the presented version of the system includes experimental features that typeset the cover title in the largest font size possible.


[1] We also made available supplementary materials, including demonstration videos and examples of books designed with the proposed system.


文章来源: https://hackernoon.com/towards-the-automation-of-book-typesetting-system?source=rss
如有侵权请联系:admin#unsafe.sh