dream-num / univer

Univer is an Isomorphic Full-Stack Framework for Creating and Editing Spreadsheets, Docs, and Slides Across Web and Server
https://univer.ai
Apache License 2.0
7.15k stars 629 forks source link

[Feature Ticket] Refactor paragraph layout #1582

Closed Jocs closed 7 months ago

Jocs commented 8 months ago

[Feature Ticket] Refactor paragraph layout

Assignees:

Shaping

Resources

Problem

为了实现后续功能需求,比如段落align(left、center、right)、justify 等,段落的首行缩进、悬挂等。因此通过本需求对 Doc 的段落排版做出一些调整和重构

Time Budget

This ticket is expected to be completed in 4 weeks, released in version 0.1.5, around Apr 15th.

Solution

实现W3C 中文排版需求中关于“行内文字排版处理”的规范,对齐 Word 段落排版功能,具体需要实现和对齐的功能如下:

  1. 关于标点符号的特殊处理
    1. 行首行尾禁则:点号(顿号、逗号、句号、冒号、分号、叹号、问号)、结束引号、结束括号、结束双书名号(书名号乙式)、连接号、间隔号、分隔号不能出现在一行的开头。开始引号、开始括号、开始单双书名号等符号,不能出现在一行的结尾;
    2. 标点符号宽度调整
    3. 连续标点符号的调整:如果任意两个相邻标点符号占用2个字宽,应当缩减成1.5个字宽。在此原则上,允许排版风格进一步调整让两个符号只占1个字宽;
    4. 行首行尾标点挤压:原本占一个字宽的标点出现在行尾时,应缩减该符号末侧二分之一个汉字大小的空白;
    5. 行尾点号悬挂:通常,行尾只可悬挂一个点号;适合行尾悬挂的点号有顿号、逗号及句号。简体中文排版中,其余点号因其字面分布偏向被标注文字的一侧、字面始端,也可进行行尾悬挂配置;
  2. 中西文混排处理:汉字与西文字母、数字间使用不多于四分之一个汉字宽的字距或空白。但西文出现在行首或行尾时,则无须加入空白;
  3. 行内调整:在行超过可容纳宽度时需要进行“挤压处理”,在行宽度少于可容纳宽度并且两端对齐时,需要进行拉伸处理,具体可参考 文本排版调研
  4. 段落间距、行间距及段落首行缩进、悬挂等

Rabbit Holes

No-gos

Building

Resources

TODOs

univer-bot[bot] commented 8 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Feature Ticket] Refactor paragraph layout

Title: [Feature Ticket] Refactor paragraph layout


[Feature Ticket] Refactor paragraph layout

Assignees:

Shaping

Resources

Problem

In order to achieve subsequent functional requirements, such as paragraph align (left, center, right), justify, etc., the first line of the paragraph is indented, suspended, etc. Therefore, some adjustments and reconstructions have been made to the paragraph layout of Doc through this requirement.

Time Budget

This ticket is expected to be completed in 4 weeks, released in version 0.1.5, around Apr 15th.

Solution

Implement the specifications on "inline text formatting processing" in [W3C Chinese Typesetting Requirements] (https://www.w3.org/TR/clreq/) and align the Word paragraph typesetting function. The specific functions that need to be implemented and aligned are as follows:

  1. Special treatment of punctuation marks
    1. Prohibitions at the beginning and end of the line: period (comma, comma, period, colon, semicolon, exclamation mark, question mark), closing quotation mark, closing parenthesis, closing double book title number (book title number B format), connection number, spacer, The delimiter cannot appear at the beginning of a line. Symbols such as opening quotation marks, opening brackets, and opening odd and double book title numbers cannot appear at the end of a line;
    2. Punctuation mark width adjustment
    3. Adjustment of continuous punctuation marks: If any two adjacent punctuation marks occupy 2 words of width, they should be reduced to 1.5 words of width. In this principle, the typesetting style is allowed to be further adjusted so that the two symbols only occupy 1 word width;
    4. Extrusion of punctuation marks at the beginning and end of a line: When a punctuation mark that originally occupies one character width appears at the end of a line, the space at the end of the symbol should be reduced to one-half the size of a Chinese character;
    5. Hanging dots at the end of a line: Usually, only one dot can be hung at the end of a line; the dots suitable for hanging at the end of a line include periods, commas and periods. In Simplified Chinese typesetting, the remaining dots are distributed to one side of the marked text and to the beginning of the text due to their literal distribution, and can also be configured to be hung at the end of the line;
  2. Mixed arrangement of Chinese and Western characters: Use a kerning or blank space no more than a quarter of a Chinese character wide between Chinese characters and Western letters and numbers. However, when Spanish characters appear at the beginning or end of a line, there is no need to add a blank;
  3. In-line adjustment: When the line exceeds the accommodated width, "squeezing processing" is required. When the line width is less than the accommodated width and both ends are aligned, stretching processing is required. For details, please refer to [Text Layout Research] (https ://xyrau6itjm.feishu.cn/docx/UKOodqXcZoPW14xiRKzc3JzFnEq);
  4. Paragraph spacing, line spacing, indentation and hanging of the first line of a paragraph, etc.

Rabbit Holes

No-gos

Building

Resources

TODOs