Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Ticket] Refactor paragraph layout #1582

Closed
18 tasks done
Jocs opened this issue Mar 14, 2024 · 1 comment · Fixed by #1675
Closed
18 tasks done

[Feature Ticket] Refactor paragraph layout #1582

Jocs opened this issue Mar 14, 2024 · 1 comment · Fixed by #1675
Assignees
Labels
feature request New feature or request scope:editor scope:layout font & layout related issues ticket

Comments

@Jocs
Copy link
Contributor

Jocs commented Mar 14, 2024

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

Rabbit Holes

No-gos

  • 本需求不包括 float layout,这会在之后的 Feature Ticket 中

Building

Resources

TODOs

@Jocs Jocs self-assigned this Mar 14, 2024
@univer-bot univer-bot bot added the ticket label Mar 14, 2024
@Jocs Jocs added feature request New feature or request scope:editor labels Mar 14, 2024
@Jocs Jocs changed the title [Feature Ticket] Refactor paragraph layout to support justify and other features [Feature Ticket] Refactor paragraph layout Mar 14, 2024
@univer-bot
Copy link

univer-bot bot commented Mar 15, 2024

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
  2. 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;
  3. Punctuation mark width adjustment
    1. 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;
    2. 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;
  4. 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;
  5. 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;
  6. 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);
  7. Paragraph spacing, line spacing, indentation and hanging of the first line of a paragraph, etc.

Rabbit Holes

No-gos

  • This requirement does not include float layout, which will be included in the Feature Ticket later.

Building

Resources

TODOs

  • Some data structure adjustments and designs
  • Special treatment of punctuation marks [Quick Ticket] Punctuation adjustment #1626
    • Line start and end prohibitions (already supported in linebreak, just need to verify)
    • Adjustment of continuous punctuation marks
    • punctuation extrusion at the beginning and end of the line
    • hanging dot at end of line
  • Mixed Chinese and Western text (this has been implemented before, and needs to be adjusted and optimized according to this requirement) [Quick Ticket] Punctuation adjustment #1626
    • Use no more than a quarter of a Chinese character's width or space between Chinese characters and Western letters and numbers.
  • Inline adjustments
    • paragraph align typesetting
    • Paragraph align menu function
    • Alignment
  • Paragraph style (this requirement is only for typesetting, not including functions)
    • First line indent
    • suspension
    • Before paragraph, after paragraph, line spacing

@Jocs Jocs added the scope:layout font & layout related issues label Mar 21, 2024
@Jocs Jocs closed this as completed in #1675 Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request scope:editor scope:layout font & layout related issues ticket
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant