mirror of
https://github.com/dolanmiu/docx.git
synced 2026-12-01 16:55:59 +01:00
dec22f535db0ca55d17b0dc220106ba01e702a00
330
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3aaeff48b8 |
fix: start a numbered heading's table of contents entry with its number, with page numbers from docx/layout (#1130) (#3800)
* fix: start a numbered heading's table of contents entry with its number, with page numbers from docx/layout (#1130) When Word fills in a table of contents, the entry of a numbered heading starts with the heading's number, then a tab, with a tab stop past the number. docx wrote the entries without the numbers. With page numbers from docx/layout, the table is written clean, so Word shows it as it is written and doesn't update it: the numbers were never shown. Word for Mac opened such a document with "Main 2" where its own entry is "1 Main 2". A page number estimator can now work out the list numbers of the paragraphs bookmarks start (listNumbers), which docx asks for once it has bookmarked the headings, before it writes the entries. estimatePageNumbers, and estimatePageNumbersWith's estimators, read them as docx/layout numbers its lists, without laying out the pages. A numbered heading's entry then starts with its number and a tab, or its number and a space when its list follows the number with a space or nothing, as Word writes it, and the pages are laid out with them. A number docx/layout doesn't write as Word does is left out. Word places the tab stop by its Normal template, not the document: past the number, measured in Aptos 12 pt, by 240 twips, and 240 more a level below the first, at the next multiple of 240 up to 1920, and where it falls past that. docx places it the same way. The probes are scripts/layout-probes/word-toc-numbers.ts and the documents Word saved once it had updated their tables. After entries at levels 7 to 9, Word places the stops after them on multiples of 200 instead, which docx doesn't follow. Checked in Word for Mac 16.114: Word opens the docs' example without asking to update it, with "1 Introduction 2" to "2.1 Results 3", and writes the same entries, tab stops and page numbers when it updates the table itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: don't name the TOC number probes .word.docx, which the layout comparison lays out scripts/compare-layout.sh lays out every scripts/layout-probes/*.word.docx and compares the page of each heading with the pages Word marked in it, failing for a committed one whose marks don't have all its pages. The TOC number probes' documents are what Word saved once it had updated their tables, saved before Word had laid out all their pages, and aren't for laying out: the shape demos workflow failed on word-toc-numbers.word.docx, "its marks have 2 of its 3 pages". They are now word-toc-numbers.docx and word-toc-numbers-font.docx, as the other probes' documents are named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f0a176ec0b | fix: don't write a table row with no cells, which Word can't open (#2724) (#3799) | ||
|
|
69fc2da10d | fix: stop an index entry field scrambling the document in Word (#1546) (#3792) | ||
|
|
ea08b9677c |
feat: write macro-enabled documents with VBA macros, from docx/macros (#471) (#3791)
* feat: write macro-enabled documents with VBA macros, from docx/macros (#471) A document's macros, the macros option, make it a macro-enabled document (.docm): its main part has the macro-enabled content type, it has the VBA project, word/vbaProject.bin, and Packer gives it a .docm's MIME type. The events of the document the macros handle, such as Document_Open, are listed in word/vbaData.xml, as Word only runs the handlers of the events listed there. createMacros, in a new entry, docx/macros, writes the macros from VBA code: ThisDocument's, modules and class modules. It writes the VBA project as [MS-OVBA] describes, in a compound file ([MS-CFB]), without a compiled cache, so Word compiles the code when it first runs it, and lists the events ThisDocument has handlers for. A vbaProject.bin from a .docm Word saved goes in macros too, with the events it handles. Checked in Word for Mac 16.114: Document_Open runs when the document opens, and so do macros in modules that use class modules and Office's library. LibreOffice imports the modules, and the Open XML SDK validator passes the demos for each version of Office since 2010. The demos workflow now validates a .docm as it does a .docx. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * fix: give a character beyond U+FFFF as two ChrW in createMacros' error createMacros' error for a character Windows-1252 doesn't have said to write it with ChrW and its code point, such as ChrW(&H1F600) for an emoji. ChrW only takes a UTF-16 code unit, up to &HFFFF, so that fails in Word. The error now gives one ChrW for each code unit: the surrogate pair, ChrW(&HD83D) & ChrW(&HDE00), which Word for Mac turns into the emoji. The docs say so too. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * docs: say how to run the macros of a .docm downloaded in Word for Windows The macros docs said Word asks whether to enable a .docm's macros when it opens. Word for Windows doesn't for a file from the internet, such as a .docm a web page made with docx and the browser downloaded: it blocks its macros without an Enable Content button. The docs now say to unblock the file in its Properties, that an organization's policy can still block macros, and that Word for Mac isn't affected. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7b08eacce9 |
fix: read an image's type from its data when it isn't given (#2952) (#3789)
TypeScript requires an ImageRun's type, but JavaScript can leave it out, as the code in #2952 and #3305 did. The image was then written to word/media/<hash>.undefined, which has no content type, so Word said the document had unreadable content and Word Online wouldn't open it. An image without a type now has it read from the bytes its data starts with, for PNG, JPEG, GIF and BMP files, and so does an SVG image's fallback. Data that isn't one of those is an error that says to give the type, rather than a document Word can't read. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0ffd27a95d |
docs: explain why TOC entries keep a heading's bold, and how to avoid it (#1369) (#3787)
When Word updates a table of contents, it copies the formatting set on a heading's text, such as bold: true on a TextRun, onto the entry. That takes priority over the TOC1 style, so bold: false there can't remove it. Formatting from the heading's style isn't copied, so the fix is to make the heading style bold instead. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3b4f7777cd | fix: patch a template read from a stream (#2321) (#3786) | ||
|
|
8f0a8532e4 | fix: cells added below a rowSpan cell take its formatting and paragraph alignment (#1219) (#3784) | ||
|
|
c08ec0ae8a | feat: two lines in one and horizontal in vertical with eastAsianLayout (#1943) (#3783) | ||
|
|
65d97ee0dd | docs: show how to add SVG images with a fallback (#3315) (#3782) | ||
|
|
225e8c8cbb | feat: restart a numbered list with numbering.restart (#3780) | ||
|
|
be1b7d460a |
docs: point text frame users to ShapeRun text boxes (#3778)
* docs: point text frame users to ShapeRun text boxes Text frames are positioned paragraphs (w:framePr), not the text box Word makes when you insert one, which is a shape with text in it. The text box page still recommended frames for most uses. Explain the difference on the text frames page, with a floating ShapeRun example, and recommend ShapeRun on the text box page. Closes #866 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK * docs: say how Google Docs shows text frames Checked by converting a test document in Google Docs: the frame stays in line, full width, and a floating ShapeRun text box is placed where it should be. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3bbc2d10b6 |
fix: restart every level of a numbering instance, not only the first (#3768)
* fix: restart every level of a numbering instance, not only the first (#2877) * refactor: Type the numbering's level configurations, so a new instance reads them without a cast Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: Restart each level of a new list instance at the number its level is written with A level's w:start is its start floored, or 1, so a start of 2.5 is written as 2. A new instance now starts the level at that number too, rather than at 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: Cover a new instance of the default bullet list, which restarts only its first level Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: Give a new instance's levels out of order, so the test checks each override is of the level its `level` names Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: Say that a new list instance restarts every level, each from its own start Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dolan Miu <dolan_miu@hotmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1fb5e15729 |
fix: Size rows below a merged cell with its margins, and show how to merge cells by hand (#3766)
Word makes a row below a cell merged down rows as tall as the merged cell's margins in it, as word-merged-cell-margins.docx shows: with rowSpan, the cells docx adds take the table's margins, so the rows below are as tall as the table's margins above and below and a line. docx/layout left those cells out of the row's height, and now counts their margins. The table docs now show merging cells by hand with verticalMerge, which gives the merged cell's part in each row settings of its own, such as no margins, which keeps the rows below to a line. That is what #668 asked for besides keeping rows together. Claude-Session: https://claude.ai/code/session_0121RHRfmgN8jDksNAdAWKnK Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8b8f5b1083 | fix: Keep merged rows together with TableRow keepNext, and indent the numbering demo's numbers (#3765) | ||
|
|
7f6de64474 |
fix: Let a table's style give its borders (#3760)
A table always wrote `w:tblBorders` with a thin single line on every side it wasn't given, which covered the borders of its table style. A table with a `style` now writes only the sides `borders` gives, and none without `borders`, so the style's borders show. Tables without a style keep their thin single borders. Fixes #1497 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a61c85d64e | feat: docx/html, HTML as a document's content (#2632) (#3752) | ||
|
|
677a44edd3 | fix: write specVanish from its own option instead of vanish (#3746) | ||
|
|
fb965994ba | fix: headings in patchDocument keep their style in templates without it (#3751) | ||
|
|
f5b7cea8bc | fix: numbered and bulleted paragraphs in patchDocument (#3750) | ||
|
|
7826217f8d | docs: fix mistakes found while answering discussions (#3748) | ||
|
|
b53aca8a3d |
docs: explain that only header rows at the top of a table repeat (#3745)
Word repeats a table's first row and the rows straight after it that set tableHeader, and ignores tableHeader on rows further down. Document this, and show how to give each part of a long table its own repeating header by making each part a table of its own. Closes #2425 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b40cf4940d |
feat(fonts): embed the bold and italic faces of a font (#3736)
* feat(fonts): embed the bold and italic faces of a font FontOptions takes optional bold, italic and boldItalic files beside data, the regular face. Each face is embedded as a file of its own, with its own relationship and key, and the font table refers to it with w:embedBold, w:embedItalic or w:embedBoldItalic. docx/layout measures text in a face from that face's file. * docs(fonts): make the bold and italic faces example live Embed the four faces of Crimson Text (OFL, licence included) from demo/assets so the example runs in the docs, and show a run in each face. Mark FontWrapper.fontOptionsWithKey deprecated in favour of files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dolan Miu <dolan_miu@hotmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
46494c5363 |
docs: explain placeholder discovery before building patches (#3713)
* docs: explain placeholder discovery before building patches * docs: clarify placeholder detector delimiter support --------- Co-authored-by: vhinayindia <281186805+vhinayindia@users.noreply.github.com> |
||
|
|
a0e2756524 | fix: make frame width and height optional (#3717) | ||
|
|
31b98f2e62 |
feat(layout): lay out compatibility modes, suppressTopSpacing, useFELayout, booklets and HTML divisions where round 26 shows Word's way, as Word does (#3730)
Word's PDFs of round 26 settled what word-stops-compat3, word-stops-top-spacing3 and -4, word-stops-booklet3, word-stops-divisions2 and word-stops-fe-layout3 probed. In Word 2010's and 2007's modes a table of a share of the width is that share of the text and its margins, a table widened for a long word grows to the room with the margins, floating tables sized to their text shift as CN9's did, text after a tab past the end goes on to 22 inches, and gaps of 1250 twips or less beside a frame are left empty; in Word 2007's mode East Asian text in its language breaks as in none and VML shapes' outlines take no room. suppressTopSpacing leaves 0.8 lines and bordered paragraphs' later lines as they are, reverse-folded booklets are the section's pages, a division's box is drawn once with its later paragraphs taking its margins and side borders, and useFELayout puts half the font's average character width between East Asian text and Latin letters or digits. |
||
|
|
22d15122e5 |
feat(layout): lay out bordered and Word 6 list numbers, hidden marks at sections, controls, headers and notes, and deleted rows and section breaks, as round 26 shows Word does (#3728)
* feat(layout): lay out bordered and Word 6 list numbers, the schema's other alignments, lists of one definition, hidden marks at sections, controls, headers and notes, and deleted rows and section breaks where round 26 shows Word's way, as Word does * fix(layout): keep the section break of the paragraph a hidden mark joins to, as the next one's mark is the joined paragraph's |
||
|
|
a1215475f7 |
feat(layout): lay out Japanese line rules, compressed punctuation, grid indents, right-to-left line ends, endnotes down the page and Arabic's letters side by side where round 26 shows Word's way, as Word does (#3726)
* feat(layout): lay out Japanese line rules, compressed punctuation, grid indents, right-to-left line ends, endnotes down the page and Arabic's letters side by side where round 26 shows Word's way, as Word does
Word's PDFs of round 26 (word-stops-east-asian3.ts and word-stops-arabic2.ts) show that Word's strict rules keep each small kana and the prolonged sound mark from the start of a line of Japanese, in place of the document's own list, and change nothing in Chinese or Korean; that compressed punctuation leaves justified Japanese and left-aligned Chinese as they are; that indents of part of a cell on a grid that snaps to characters are rounded up line by line, before the margin too, with tabs to their stops; that the space after a line's last right-to-left word takes room beside left-to-right text in a right-to-left run and between right-to-left words in any run; that endnotes after text that runs down the page run down it, and end with their section before text that runs another way; and that Word doesn't kern Arabic's letters in Arial and Times New Roman, every pair being as wide as its forms to 8 thousandths of an em. The layout follows each, and keeps a narrowed stop where a case is still open: half-width small katakana and the document's own lists beyond the strict list, distributed Japanese and justified or distributed Chinese and Korean with compression, indents a character or more before the margin, endnotes from a section followed by one that runs as it does before a change of direction, and Calibri's Arabic, which Word kerns by pairs of glyphs.
* docs: say Word doesn't kern Arabic's letters side by side in the fonts of the tables, and spell tatweels
The fonts paragraph of docs/usage/layout.md still said Word kerns them in Arial, Times New Roman and Cambria by pairs not yet known, so only Courier New's Arabic is laid out, which round 26's AR4 PDF showed to be wrong, and the probe README's ignore list lacked tatweels, which failed CSpell.
* fix: fail the Arabic kerning reader on a PDF without its probe, or a paragraph without its 42 words
Otherwise a PDF with no AR4 labels wrote {} and exited 0, and the checker reported nothing.
* fix(layout): measure Arabic's letters in their joined forms as drawn too, with ligatures or kerning on
measureTextWidthAsDrawn measured each Arabic letter in its isolated form where measureTextWidth has the forms the letters beside them join them in, so a word of Arabic in Arial with ligatures on, which no longer stops, was nearly twice as wide as Word draws it. It now takes the joined widths by each glyph's index among the characters, as the plain measurement does.
|
||
|
|
0c0f1f07b9 |
feat(layout): lay out accents sized to their letter, cramped lower limits, spaces beside brackets, sums in a script's script, pre-scripts, phantoms, boxes and centred equation arrays, as Word's round 26 shows (#3725)
Word's PDFs of the round-26 probes (word-stops-equations3, word-stops-equation-small2) settle most of the equation stops #3702 left: roots, brackets and braces narrowed to what the PDFs still leave between two sizes, accents over a letter sized to fit it where the MATH table attaches them, superscripts in lower limits cramped, TeX's spaces beside brackets and bars, more symbols' classes, a sum in a script's script, equation arrays without ampersands centred and alignment marks left as they are, boxes struck through, phantoms without their width, ascent or descent, pre-scripts, and small fractions with displayed equations' defaults on. A scripts box now carries its base's first glyph for kerning and its last script's italic correction, which an accent leaves out. A second ampersand in a row still stops, with the sides of a box and transparent phantoms where Word's way isn't settled; word-stops-equations4.ts probes those for the next batch. |
||
|
|
1f172c6939 | feat(layout): lay out phonetic guides, tabs, soft hyphens, squeezed lines, run borders, fitted text and grids above footnotes where round 26 showed Word's way, as Word does (#3729) | ||
|
|
bc3180cfa6 |
feat(layout): keep a cell's text from the border Word draws before two that meet, and an exact row's space between cells inside its height, as Word does (#3727)
* feat(layout): keep a cell's text from the border Word draws before two that meet, and an exact row's space between cells inside its height, as Word does Word's PDF of word-stops-tables3 (round 26) settled what the lay3-tables probes left open. The text of the cell before two borders of different styles that meet is kept from the border Word draws, by Word's weights for their styles, which are back (BT7a to BT7c); where Word draws the wider, or the next cell's over none, the layout stops, unless the cell's margin settles it. A row of an exact height with space between cells has its own space and its cells' borders inside its height, and only the table's edge outside (TS16a), and a border of 3 points above an exact row is inside it (TS16b). Half of each outer border of 3 and 6 points is inside the room a table sized to its text fills (BT8a, BT8b), and a merged cell's text breaks between its rows as a paragraph's lines do (RW21), as the layout had them. A long word in cells merged across columns still stops: Word's six more cases (LW9a to LW9f) show the word's excess handed to the columns one by one, each taking a share of what is left, but the shares of columns that differ fit no rule yet. word-stops-tables4.ts probes what would settle it, for the next batch. * ci: rerun the checks after GitHub's code scanning upload failed |
||
|
|
28defb1aac |
feat(layout): keep text at least half a point from a floating table, and draw the characters a run's hint moves to its East Asian font in it, as Word does (#3724)
Word's PDFs of round 26 showed the text beside a table that text flows around 0 to 10 twips from it starting where it does with no distance, and 15 twips as given (word-stops-float-distance.docx FD1a to FD1f); curly quotes, dashes, an ellipsis, a degree sign and the like in the East Asian font of a run with the hint for East Asian text, in Chinese, Japanese and English (word-stops-run-fonts.docx HA1a to HA1c); accented letters in the high ANSI font given alone or beside Courier New (HA2a, HA2b); the scripts the run-font rules leave out in the high ANSI font, or in the fonts Word falls back on from either (HA3a); and Hebrew and Arabic in the font for ASCII (HA3b). The layout follows each, and stops in a run with the hint only where the PDFs don't settle the font: an East Asian font that isn't one, Latin Extended letters outside Chinese, a combining mark, a right-to-left run, and a block the rules leave out in a run whose two fonts differ. |
||
|
|
76cde3d6a8 |
feat(layout): lay out VML pictures at their shapes' sizes, and a picture of one pixel at 33 points, as Word draws them (#3723)
Round 26's Word PDF of word-stops-vml-pictures2.docx (VM30a to VM30h) showed Word draws a VML picture (v:imagedata) at its shape's size, and the one-pixel picture of the first batch 33 points square whatever its shape, which VM20 had read as Word's way with every picture. A picture in the line is now a box of its shape's size, with its pixels read from its PNG, JPEG, GIF or BMP file through its part's relationships, 33 points at most across and down for a picture of one pixel. A shape of a VML shape type has the type's attributes where it gives none of its own, so Word's type for pictures gives them no outline, which also takes 0.72 points out of an object's picture's line. The layout still stops at a picture placed on the page that text flows around, one drawn past 33 points a pixel that isn't the one-pixel case or has a resolution of its own, one with no size, and one whose image isn't in the document or isn't read; word-stops-vml-pictures3 probes those for the next batch. |
||
|
|
ee71db8433 |
fix(layout): keep text half a point from a floating table with no distance, and draw characters past ASCII in the run's high ANSI font, as Word does (#3712)
* fix(layout): keep text half a point from a floating table with no distance, and draw characters past ASCII in the run's high ANSI font, as Word does Word's PDFs of round 25 showed the text beside a table that text flows around with no distance from the text starting 10 twips from its room (CN9, CM10), where the layout's model put it at the room's edge, and curly quotes in a run given SimSun for ASCII alone drawn in Calibri, the document's high ANSI font (CN10c, FE2c). Each of a run's fonts is now read on its own, with the high ANSI font for the blocks ECMA-376 17.3.2.26 gives it; the layout stops at characters the run's hint for East Asian text may move to the East Asian font, at scripts the rules leave out in a run whose two fonts differ, and at a distance under half a point. * fix(layout): keep a mark in the font of the character it is on in a list number's one font singleFontOf classified a combining mark on its own, as a character of the high ANSI font, where spansOf keeps it with the character it is on, so a list number such as a digit with an accent stopped as one of characters of both fonts. |
||
|
|
c2816f8d20 |
feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does (#3709)
* feat(layout): lay out footnotes and endnotes, header pictures, cell spacing, header rows and tabs where round 25 shows Word's way, as Word does Word's PDFs of the round-25 probes settle the cases docx/layout still stopped at in notes (word-stops-notes2, word-stops-note-numbers, the word-stops-endnotes-* documents, word-notes-across-pages and word-notes-final-table) and around header pictures, contextual spacing in cells, header rows and tabs (word-stops-edges). Where a case stays open, the stop is narrowed to it. * fix(layout): keep the space a cell's own blocks leave out when its table's edges leave out more A paragraph after a table in a cell is compared with the end of the table's last row, which leaves out its space before. The pass for the table the cell is in replaced what it left out with its own, so the paragraph kept that space. * fix(layout): lay out the endnotes of a section with no blocks of its own after it Where the settings put endnotes at the end of each section, those of a section that suppresses its own go after the next, which can have no blocks of its own, as its paragraphs are hidden. They weren't laid out at all; now they go after the section before's last block, before the next section's first. * docs(layout): put two doc comments back above their functions, and say what leftOut covers * fix(layout): stop at more than 4 columns of footnotes, and don't make them A document's w15:footnoteColumns can ask for any number of columns, and each was made before the layout stopped. Word's Footnote and Endnote dialog offers up to 4, so more stop, as not yet seen in Word, and the section has no columns of footnotes to make. * fix(layout): find where each section's endnotes go in one pass back A section that suppresses its own endnotes puts them at the end of the next that doesn't, and that was followed one section at a time, again for every endnote. A long run of such sections overflowed the stack. Each section's end is now found once, from the last section back, and only where the settings put endnotes at the end of each section. * fix(layout): lay out the endnotes of sections before the first block Endnotes went after each body block, for the sections up to the next block's, so those of sections before the first block's, whose paragraphs are all left out as hidden, were never laid out, nor were any where the body has no blocks at all. They now go before the first block, or alone. * test(layout): cover a header's text box placed against its line or the page The stop kept for a text box that text flows around in a header, placed against its paragraph or line, is now tested for one against its line, and one against the page is read as a drawing, as a picture there is. * fix(layout): stop at endnotes in columns with no separator above them The endnotes' columns start below their separator, so with an empty separator note, which leaves none, a lone endnote at the document's end left no start for the columns it ends in, and evening them out threw. Word has been seen with endnotes in columns only below a separator, so that stops, and guessing, the endnotes are laid out without evening out. * docs(layout): say paragraphs kept before header rows go on only to the next page The table section said the paragraphs kept with the next before a table go on with its header rows to the next page or column. They go on to the next page; in columns, or from the top of a page, the layout stops. * fix(layout): cut a table row in a footnote across many pages in time The search for where a footnote's table row is cut started from the rest of the row and went up a line at a time, filling every earlier part of the row again at each try, so the time grew far faster than the row: a row of 400 lines across 7 pages took 4.7 seconds. Where the rest doesn't fit, no part taller than the page does, so the search goes on from the page's height, and the parts filled on a page are kept for the tries after, filled afresh on each page as their lines may hold its number. The cuts are the same: that row now takes 0.2 seconds, and one of 2,000 lines across 34 pages 3 seconds. * fix(layout): stop at a left tab past the end of a later line only with a hanging indent A tab to a left stop past the end of the line at the start of a later line of a paragraph with a first line indent stopped, though that line starts at the left indent, as TA9a's lines do, which Word put on a line of their own. The stop is kept for the first line there, and for any line of a paragraph with a hanging indent. * fix(layout): find a line's footnote that starts on the next page afresh each time it is tried The footnote of a line at the top of a page that starts on the next page, after the line's others, was kept across the tries of the line, and a try after a drawing was left out, a table placed or a column moved on to could fit the line with all its footnotes, but still put the last on the next page. It is now found again on each try. * fix(layout): fill a footnote row's parts before its last in a loop The parts of a table row in a footnote before its last were filled again by recursion, once for each page the row had gone on to, after the parts kept for a page were let go at its end. A row across thousands of pages would run out of stack. They are now filled in a loop, and kept by the rooms they were cut at one after the other rather than by a key that grew with each page. The cuts and their times are the same. |
||
|
|
88732990f7 |
feat(layout): lay out compatibility modes, suppressTopSpacing, booklets and HTML divisions where Word's round 25 settled them, as Word does (#3704)
* feat(layout): lay out compatibility modes, suppressTopSpacing, booklets and HTML divisions where round 25 settled them, as Word does Word's PDFs of round 25 (word-stops-compat2-15, -14, -12, -top-spacing2, -booklet2, -divisions and -fe-layout2, committed in scripts/layout-probes/stops2 with their documents) settle most of what the earlier batch left open: - Compatibility modes 14 and 12: a page break at the end of a paragraph and distributed lines as in mode 15 or as justified ones, no ligatures without enableOpenTypeFeatures, a tab past the end at its stop with the rest of the paragraph on that line, gaps beside drawings and frames down to 50 and 100 points, indented tables, tables in cells and tables widened for a long word, floating tables with their text at their place; in 12 and 11, East Asian text of no language broken only at its spaces, and a text box's outline taking no room in its line. - suppressTopSpacing: at least a height X leaves out X less 9.6 points, whatever the line's height; a paragraph's later line, the space before a section's first paragraph and a table's cells are followed, multiple spacing and a line below a border left as they are. - Folded booklets laid out as the section's pages; paragraphs in HTML divisions laid out from the web settings. - useFELayout stops only at East Asian text beside other text with automatic spacing on. It keeps stopping, narrowed, where Word hasn't shown its way, and word-stops-compat3.ts writes probes for those. * fix(layout): measure an older mode's narrow gap beside a drawing within the paragraph's indents The stop at gaps beside drawings narrower than Word 2010 was seen putting text in measured the whole gap, so a gap a paragraph's left indent covers, which takes no text anyway, stopped the layout, and one an indent narrows passed by its whole width. It now measures the room the indents leave in each gap. * fix(layout): measure an older mode's gaps of a first line's row with its first line indent When a paragraph's first line indent leaves the first gap beside a drawing no room, its first line may go in a later gap of the row, which the stop at narrow gaps measured without the indent. Those gaps are now measured with it, so the layout stops where the indent would leave less room than Word was seen putting text in. Which gap Word indents then hasn't been seen, so the lines are laid out as before. * fix(layout): measure only the gap that takes a first line with its first line indent The last fix measured every later gap of a first line's row with the first line indent, so a gap that takes the second line, after a first gap the first line fits in, was measured narrower than its room and could stop the layout. Only the first gap the indent leaves room in, which the first line goes in, is measured with it now. * fix(layout): let no hanging indent widen an older mode's gap beside a drawing A first line indent less than none moved the room the stop at narrow gaps measured left of the gap, into the drawing's room, so a gap of 80 points beside a drawing passed as 105. The stop now measures no further left than the gap itself. Where Word starts a first line that hangs past a drawing's edge hasn't been seen, so the lines are laid out as before. * docs(layout): say a tab line's reach is from where the paragraph's lines start, and test both sides of it The comment called the 941.4 points Word was seen keeping text after a tab on its line "past the margin", though a line's positions, as its tab stops, are from where the paragraph's lines start: CN5a's line ran to 18827 twips from there, past the margin's 9026. The test now checks a line just within it as well as one past it. * fix(layout): count only frames beside a line's row in an older mode's narrow gaps A frame anywhere on the page whose edge was where a gap's is made the gap one beside a frame, and its stricter least width, though the frame was lower or higher on the page. Only frames beside the line's row count now. |
||
|
|
c717e7739f |
feat(layout): lay out grid indents, Japanese line rules and endnotes after other grids, and measure Arabic's joined forms, as Word does (#3705)
* feat(layout): lay out grids and East Asian rules round 25 settles * feat(layout): measure Arabic in the forms Word joins it in, and end right-to-left lines as Word does * test(layout): probes for what round 25 left open, and coverage of the round's cases * perf(layout): look past a word for a right-to-left one only after one * test(layout): cover a grid line's own stop * fix(layout): stop at kerned Arabic and unseen right-to-left line ends, as Word's PDFs show * docs(layout): say which fonts' Arabic Word kerns, apart from Courier New's The sentence read as if Courier New's Arabic were the kerned one; it is the one Word doesn't kern. Calibri's Arabic is kerned too, as word-stops-arabic AR1 showed. * refactor(layout): rename the right-to-left lookahead's names beside the tab code's #3707's code for a word after a tab declares following and at in the same loop, which the lookahead's names shadowed. * fix(layout): kern a letter on a grid that snaps to characters with the one before it in another run of its font widthOf measures pieces of the same font together, so a pair across them is kerned; snapped started each piece afresh, so a word split across runs of one font took the cells it needs unkerned there. It now keeps the letter before across such pieces, but not after a soft hyphen's break (apart). * fix(layout): lay out lam and alef alone in Arial, Times New Roman and Cambria, as one glyph Word doesn't kern within unknownArabicKerning took lam and the alef after it as two letters side by side, which Word kerns, but Word joins them into one glyph, the ligature, whose width word-stops-arabic AR1 measured, so a word such as "la" alone stopped the layout for nothing. |
||
|
|
bb6ffa3544 |
feat(layout): lay out table borders, space between cells, text running up cells, merged cells across pages and tables of a share of the width, as Word does (#3708)
* feat(layout): lay out table borders that meet, art borders, rows of their own space and borders, and borders of no width, as Word does * feat(layout): lay out text that runs up or down a cell in tables sized to their text and rows of only it, as Word does * feat(layout): lay out tables of a share of the width that their words don't fit, with rows that give a column different widths or start past it, and leave half their borders outside their columns, as Word does * feat(layout): lay out table styles that keep rows whole, tables indented by a share, cells that don't wrap or fit their text in tables sized to it, and exact row heights with borders, as Word does * feat(layout): lay out the text of cells merged down rows across pages, rows taller than a page with merged cells, footnotes and header rows, and rows taller than a column, as Word does * docs(layout): say how tables' borders, space, rows across pages and text running up lay out, and list the round-25 probes followed * test(layout): probe what the round-25 table probes left open, for Word's next batch * fix(layout): keep the table's top border above a row below a header row taller than a page, which isn't repeated * fix(layout): give a row of only a cell of text running up, without a paragraph, no height A cell may hold only range marks, as a bookmark, with no paragraph, and one whose text runs up or down, in a row of only such cells, failed to measure its last paragraph's mark. It needs no room, as a cell of nothing across the page. * refactor(layout): tell art borders from lines in one place, checked against the schema A run's, a paragraph's and a table cell's borders each told an art border from a line by its style not being one of the lines they know, with three copies of the widest art border. They now share isArtBorder and WIDEST_ART_BORDER, and a test reads ST_Border from wml.xsd to check that its lines, from nil to inset, are those with widths, so the rest of its styles but custom, from apples on, are its art borders and no line is taken for one. A table border's room now comes from the lines a run's and a paragraph's know, which are the same styles. * test(layout): probe the border above a row of an exact height with space between cells and a thick border together TS16a has space between cells with a border of half a point, whose 10 twips inside or outside the row's height Word's PDF shows only just, and TS16b a thick border without the space. TS16c has both, a border of 3 points and space of 40, so Word's next batch shows plainly where the border goes in a table with space between its cells. |
||
|
|
f56f18a336 |
feat(layout): lay out sizes in other units, soft hyphens, tabs, run borders and fitted text at more of their stops, as Word does (#3707)
* feat(layout): read a run's size in any unit at whole half-points, rounded down, as Word does * feat(layout): lay out a hanging indent in twips from a left indent in characters, as Word does * feat(layout): end a box of borders at the empty paragraph that ends a section, as Word does * feat(layout): move a line whose multiple spacing would go into the footnotes to the next page, as Word does * feat(layout): break at a soft hyphen whose hyphen fits, and take a shorter part as it is over a longer one squeezed, as Word does * feat(layout): squeeze a justified line with en spaces by no more than a quarter of its ordinary spaces, as Word does * feat(layout): take a tab on to the next line with a word that doesn't fit after it, and line up text at stops past the end with any indent, as Word does * feat(layout): measure kerned text either side of a soft hyphen apart, as Word does * feat(layout): give a single run border with a shadow or drawn as a frame its room, as Word does * feat(layout): lay out a picture in a border of its run with its border's room, as Word does * feat(layout): lay out text fitted to a width as one box of that width, as Word does * fix(layout): break a word with soft hyphens after a tab at its soft hyphen, as Word does * docs(layout): say what Word showed of phonetic guides, which still stop the layout * test(layout): cover a drawing placed on the page in text with a border, guessing * refactor(layout): name the tab stop's state as lint asks * docs(layout): say what the layout now follows of soft hyphens, tabs, borders, fitted text, sizes and indents * docs(layout): commit Word's PDF of word-stops-text2, and say what it settled * test(layout): spell the kerning probes' letters * feat(layout): stop at text fitted to a width wider than its line after other text, and probe what word-stops-text2 left open * test(layout): cover text fitted to no width * docs(layout): end the sentence on fitted text before two lines in one The sentence added for fitted text ran on into the next one without a full stop. * fix(layout): put SH18e's second soft hyphen between the f and i of efficient The probe is for ligatures across f-f and f-i boundaries, and splitting efficient as ef|fi|cient tested f-f and i-c instead. * fix(layout): end a box of borders at the paragraph that ends a section after a table After a table, the empty paragraph that ends a section takes a line, and sharesBorders still joined its box to the next section's paragraph, whose own box started after it, so its bottom border took no room. * docs(layout): wrap the stops2 README's paragraph on the next batch |
||
|
|
72ebbb1be7 |
feat(layout): stop at text in an embedded font that Office also offers, as Word draws it in Office's own copy (#3710)
* feat(layout): stop at text in a font from a file that Office also offers, as Word draws it in Office's copy Word for Mac drew Pacifico, which a document embedded, in Office's own cloud copy of it rather than the embedded file. docx/layout now stops at text in a font embedded or given as a file when Office offers a font of that name, but for Office's fonts of the width tables, and measures the file when guessing, noting the guess. The names come from Office's catalog of its cloud fonts (version 4.42), cross-checked against Microsoft's published list, generated by scripts/generate-office-cloud-fonts.ts. The layout demos of embedded fonts and fonts from files move from Pacifico to Kaushan Script, which Office doesn't offer. * fix(layout): stop at Latin text in an East Asian font Office offers, given as a file The width tables have the East Asian characters of fonts such as Microsoft YaHei but not their Latin letters, so offeredByOffice now takes the text being measured, and Latin text in such a font from a file stops as Office's copy may draw it differently. * fix(scripts): strip every angle bracket and unescape & last in the cloud fonts generator CodeQL flagged the published list's cell text: one pass of tag stripping could leave part of a tag, and unescaping & before could unescape twice. The generated list is unchanged. * fix(scripts): read the text between a cell's tags in the cloud fonts generator CodeQL still read removing tags with a replace as incomplete sanitization, so the cell's text is now collected from between its tags rather than by removing them. The generated list is unchanged. |
||
|
|
0e7b7f75d4 |
feat(layout): lay out VML text boxes, shapes and objects, and more of floating tables, frames and pictures, as Word does (#3711)
* feat(layout): lay out VML text boxes, shapes and objects, and more of floating tables, frames and pictures, as Word does Word's PDFs of round 25 (word-stops-floats2 and the seven VML probe documents) settle most of the stops of lines 12, 13, 14, 21 and 36 of the stops report. VML text boxes with insets, outlines or heights of their own, shapes with outlines, groups, embedded objects and VML in a header's line are laid out as Word drew them, and so are pictures lined up inside or outside down the page, floating tables and frames with no anchor across the page, two tables that may not overlap with no room on the right, lines whose rooms take none of their words, kept headings with pictures or floating tables, floating tables before a table that moves on, broken with header rows, or with borders between rows only, floats and frames in endnotes, footnotes beside a picture, and frames with borders and a distance. VML pictures still stop, as Word drew every one of 33 points or more 33 points square. Word 16 for Mac won't open a text box in a text box. * fix(layout probes): read curves, turned images, forms and next-line text in the shape reader, and give its command CodeRabbit's review of #3711: the reader's bounds now take in a curve's extrema, not only its end; an image's box is that of all four corners of its unit square, so a turned image's is its turned box; a Form XObject is said to be one rather than called an image; the next-line text operators (TL, TD, T*, ' and ") move the text position; and the README and the script's header give the command to run it with. |
||
|
|
f269792774 |
feat(layout): lay out list numbers, hidden paragraph marks and tracked changes at more of their stops, as Word does (#3703)
* feat(layout): lay out list numbers, hidden paragraph marks and tracked changes at more of their stops, as Word does Round 25's PDFs of word-stops-lists, -list-definitions, -picture-bullets, -hidden, -hidden-edges, -tracked, -tracked-edges and -moves settle most of the stops of the second inventory's lines 16 to 18, and show a level aligned both laid out wrongly without stopping: - Lists: a level Word leaves out (aligned both, or showing a level its list doesn't have), a centred number with its space, a number's emphasis marks and raise, its ascent with multiple spacing, the tab after a right-aligned number, a line of only a number, no automatic spacing between a list's levels, and Thai and Hindi words from 1 to 5. - Hidden marks: paragraphs joined in the first one's indents, tab stops and borders, line by line in their line spacing, across a content control's end, sized as one in a table sized to its text; notes of hidden references laid out and counted; keepNext and boxes past hidden paragraphs; a hidden section break before a section alike on its page. - Tracked changes: deleted pictures, tabs, breaks, note references and marks counted in sized columns as written; deleted endnote and moved note references counted; moved paragraph marks joined; deleted section breaks leaving their section to the next; deleted rows' notes counted, and rows around a deleted one in a spaced table as without it. Commits the probes and Word's PDFs, and word-stops-lists2.ts and word-stops-marks2.ts for what is still unsettled. * docs(layout): say Word opens the page format probes but couldn't save them as PDFs * fix(layout): stop after a left-out list level only at the levels it may have started again A paragraph at a level Word leaves out marked every level below it as uncertain until a level at or above it was counted, so the second of several sub-items after a left-out heading stopped the layout, though it is certainly 2. Only the levels that had numbers when the left-out paragraph came may have been started again by it, and each is known once it is counted, or started again by a level above it. |
||
|
|
2d1d6370dd |
feat(layout): lay out more of the equations Word builds up, and follow its maths settings, as Word does (#3702)
* feat(layout): lay out more of the equations Word builds up, and follow its maths settings, as Word does Word's PDFs of the round-25 probes (word-stops-equations2, word-stops-equation-limits, word-stops-equation-small and word-stops-equation-spacing) settle most of the equation stops they were written for: - scripts' sizes are 73% and 60% of the equation's rounded down to the half point, at any size - a superscript in a cramped part is raised by the MATH table's cramped shift, and a subscript isn't cramped - fractions, sums and functions are spaced as TeX spaces them beside letters, digits, punctuation and each other, and brackets as the brackets they are - roots' signs, brackets, accents (flatter over a tall part) and braces are the sizes Word draws, and matrices' and equation arrays' rows are spaced as Word spaces them - boxes, equation arrays, phantoms, braces of their own sizes, fractions beside other parts and in displayed scripts, sums in scripts, bold and double-struck digits, and more symbols are laid out - an equation displayed beside text, or alone after its list's number, is built up as in a line of text - the maths settings' places for limits, displayed equations' defaults and space between equations are followed Where Word's PDFs leave a size between two, or haven't shown a case, the layout still stops: equations too long for their line, normal text, and the cases around what was settled. * test(layout): probe the equations Word's round-25 PDFs leave between two sizes or haven't shown, for the next batch * refactor(layout): measure an equation array row's part before its ampersand with settled |
||
|
|
6470849dca |
feat(layout): measure the bold Word makes itself, letters a font lacks and more characters in Office's fonts, as Word does (#3706)
* feat(layout): measure the bold Word makes itself, letters a font lacks and more characters in Office's fonts, as Word does Round 25's font probes, saved from Word 16 for Mac, settle what Office's fonts still stopped at: - word-stops-office-fonts MB1 to MB3: the bold Word makes itself for Calibri Light, Franklin Gothic Book and Impact draws each glyph 20 thousandths of an em further on than the regular at 8 to 72 points, the spaces as wide, kerned and joined as the regular, its lines as tall. The width tables now have it, from the generator. - FB1, FB2: the font Word draws a letter a font lacks in doesn't depend on the run's language or East Asian font, and the line takes its ascent and descent. The width tables say which face of the tables Word draws each such letter in, where it is Calibri, Cambria, Arial, Times New Roman or Tahoma, and a line makes room for it. - KL1: text with ligatures isn't kerned in a font kerned by its kern table alone, whichever ligatures it has. - word-stops-more-widths-office and word-stops-more-italic-widths: Hebrew, Thai, box drawing, shapes, symbols and dingbats in Office's other fonts and in the five fonts' italics, as Word draws them. - DS and word-stops-font-heights: font files' lines are as tall as their hhea tables make them, and go their descender below the baseline. Font files whose GPOS table doesn't kern Latin text are kerned by their kern table, and not with ligatures. MB4 showed Word drawing Pacifico, which the document embeds, in Office's own copy of it, so bold text in a font given or embedded without a bold face still stops. * fix(layout): report KL lines the office-fonts reader doesn't find, rather than stopping word-stops-office-fonts.py indexed the kerning of a KL1 line, and the words of KL2's, without checking it found the line whole, so a PDF without one, or with one Word broke, stopped the reader before KL2 and DS. They now print "not found", as MB does. |
||
|
|
90ca7b93ec |
feat(layout): lay out document grids, text down the page, Thai and imported documents, and measure more characters, as Word does (#3700)
* feat(layout): lay out document grids and East Asian settings at more of their stops, as Word does * feat(layout): lay out text that runs down the page at more of its stops, as Word does * feat(layout): measure Hebrew, Thai, box drawing, shapes, symbols and dingbats as Word lays them out, and Thai justified for it * feat(layout): lay out imported documents whose formatting is kept, and whose own styles' defaults give no font or size, as Word does * fix(layout): stop at endnotes that a section of another grid or direction follows, as Word ends them with their own section * feat(layout): measure the Arabic-Indic and Devanagari digits as Word lays them out, as list and page numbers write them * docs(layout): say what document grids, text down the page, Thai, imported documents and more characters lay out as, and list the batch's probes * test(layout): probes of indents on grids, endnotes before another grid or direction, Japanese strict rules and compression, and Arabic's joined forms, for Word's next batch * fix(layout): stop at an imported document whose formatting is kept that ends in a content control Word gives the last paragraph of an imported document whose formatting is kept none of its space after. Where that paragraph is in a content control or custom XML, the layout took off the space after of an earlier paragraph at the top of the imported body, or threw where there was none. Which paragraph Word takes it off there hasn't been seen, so the layout stops rather than guessing. * fix(layout): read an imported document's w:matchSrc as on or off w:matchSrc is an on/off property (CT_OnOff), so a w:val of 0, false or off turns keeping the imported document's formatting off, and its paragraphs take the document's styles of the same names. The layout kept its formatting whenever the element was there. * docs(layout): say that an imported document whose formatting is kept stops the layout where it ends in a content control * docs(layout): say in the imported documents probe what Word's PDF of it showed, and what still stops * docs(layout): say which fonts Hebrew, Thai, bullets and symbols are measured in, and where they stop the layout * test(layout): probe Hebrew, Thai, bullets and symbols in Office's other fonts and in italic, for Word's next batch * fix(layout): stop at East Asian or right-to-left text in an imported document's notes where its styles give no font Where an imported document's own styles give its Latin text Word's own font, the layout stops at East Asian or right-to-left text in it, as which font Word gives that text hasn't been seen. It looked only at the imported body, so text in its footnotes and endnotes, which are merged with the document's, went on without the stop. * docs(layout): leave Cambria's and Times New Roman's Devanagari digits out of the characters measured as Word draws them * docs(layout): give GR12's columns as the probe writes them, 2000 and 6526 twips |
||
|
|
227f9179f9 |
feat(layout): lay out floating tables, text frames and drawings in more of the ways Word does (#3687)
* feat(layout): lay out floating tables, text frames and drawings in more of the ways Word does Follows Word's PDFs of word-stops-floats.docx and word-stops-drawings.docx (lines 12, 13 and 14 of the stops report), and stops more narrowly where they don't settle what Word does. Splits the VML probe into documents Word can open, and adds word-stops-floats2.ts for what is left. * fix(layout): stop, rather than throw, where a drawing's paragraph goes on to the next page outside placing a block, and find the floating tables around a block without copying the blocks * docs(layout): leave out a floating table with nothing after it in its section, which no document has * fix(layout): stop at once where the text before a table moves it on from the text frame anchored at its top A frame placed from the page's top beside the text before its table is pinned to the page, and when that text then went on to the next page, the frame's anchor named the table, which the page laid out again without it didn't move on. The page was laid out again until it gave up as drawings that don't settle. Where Word puts the frame then isn't known, so the layout stops there as it does where the table moves on. * fix(layout): read the empty paragraph Word adds after a floating table at the end of the body on its section's grid It was read without the section's document grid, so its line took the font's height rather than the grid's pitch, as the section's other paragraphs take it. * docs(layout): say which text frames at the end of a section still stop Those before the empty paragraph that ends a section are laid out; those at the end of the document, or whose own paragraph ends the section, still stop. * docs(layout): keep one comment on endsAfterTable, with what Word showed for both cases * fix(layout): take a sliver of room beside a drawing as none, not as a narrow room Edges worked out in different ways can leave a room a fraction of a point wide beside a drawing as wide as the column. Taken as a room narrower than 18 points, the layout stopped there, where before it moved the line below the drawing, as it does with no room. * test(layout): name the probe whose marker is missing in word-stops-floats2's injections A missing CO1b frame made the slices cut the document at the wrong place. Each injection now throws, naming its probe, and they are separate, so ONLY leaves one out without the other. * test(layout): throw where word-stops-vml's VM26b text box is missing, as its other injections do A missing VM26b box made listItems slice document.xml at the wrong place, which ONLY's swallowed errors would have written out. |
||
|
|
a5b5351b54 |
feat(layout): lay out text that runs up or down a table cell where its column's width can't move a line, as Word does (#3680)
* feat(layout): lay out text that runs up or down a table cell where its column's width can't move a line, as Word does Word's PDF of word-stops-vertical-cells.docx (lay-stops2's batch) settles part of the work's line 5: - In a table sized to its text, Word makes the column of text that runs up or down a cell about a line of each paragraph wide, however long its text, and sizes it by the text, not the mark (TV1, TV5). How wide exactly has been seen only of Calibri, so the layout lays it out where the other cells' widths don't depend on it, and still stops where they do: in a table narrowed to the room or fitted to its width, in a table cell, or that text flows around, and in a cell given less than about a line of it. - A long word in it widens nothing (TV2). - A row with it breaks across pages as other rows do, the text on the page of its first part (TV3). - A picture in it leaves its row a line of its mark (TV5c), but a mark larger than its text doesn't make the row that tall (TV5b), which now stops. - Text down with East Asian characters upright (tbRlV, tbLrV) is laid out as text running down, and across with them on their side (lrTbV) as text across (TV6). Guessing past a table in such a cell no longer throws (TV5d). word-stops-vertical-cells2.ts is the probe for the next batch: other fonts, borders and paragraphs, and the row of only such a cell. * fix(layout): size text running up or down a cell by its line size and page fields, and stop at a text box in it A superscript's or subscript's line is its text's (TV4), as the reader already compares it with the mark, and the numbers of PAGE, NUMPAGES and the other page fields are text of their runs' size, so the column of a cell whose text runs up or down is sized by those, and a field smaller than its mark stops as text smaller than its mark does. A text box in such a cell, which pagination lays out as tall as its text, hasn't been seen in Word, so the layout stops there. |
||
|
|
f03253eb22 |
feat(layout): lay out equations Word builds up, as Word does (#3685)
* feat(layout): lay out equations Word builds up, as Word does Lay out the equations Word builds up (fractions, scripts, roots, sums and integrals with their limits, brackets that grow, matrices and cases, accents, bars, functions and limits, and braces) by the rules of Cambria Math's OpenType MATH table, with the font's own widths, ink and constants, as Word's PDFs of word-stops-equations, -equation-settings and -equation-font show. Each probe's width in its line of text is Word's to within 0.03 points and its line's height within Word's own drawing grid, but two roots, which are within 0.1 points. What of Cambria Math the layout needs is generated from Word's own copy of the font by scripts/generate-cambria-math.ts into src/layout/cambria-math.ts, which replaces the widths read from Word's PDFs (equation-widths.ts) and the table of Cambria Math's own widths within 1.5 thousandths of an em, the integrals with their italic correction, and ◇, which Cambria Math hasn't, stops. The layout keeps stopping where Word's PDFs leave the result unsettled: scripts in sizes other than 11 points, superscripts in cramped parts, brackets between two sizes, matrices whose rows are too tall to be single spaced, thin spaces beside fractions, brackets, sums and functions, boxes, normal text, equations too long for their line, maths fonts other than Cambria Math, margins of displayed equations and space between equations side by side in one m:oMathPara. Guessing past a stop, an equation alone in its paragraph is laid out displayed first. word-stops-equations2.ts writes the probes that settle them, each validated against ooxml-schemas/. * fix(layout): stop at a digit in a bold run or another alphabet, which Word hasn't been seen drawing A digit in a bold or bold italic run was laid out as the plain digit, though Word draws a bold run's letters in Unicode's bold alphabet (word-stops-equations.docx EQ19), which has bold digits too, wider than the plain ones. No probe has shown which Word draws, so the layout stops there, as it does for a digit in another alphabet, and word-stops-equations2.ts's EQ45 asks Word. The alphabets' unused first digits are gone. * fix(layout): lay out an equation in a line of text in a numbered paragraph, stopping only at one alone after its list's number * test(layout): probe an equation displayed (m:oMathPara) alone after its list's number too, as EQ38d |
||
|
|
1fb1aa03f9 |
feat(layout): number and place footnotes and endnotes, and write page references in words and pictures, as Word does (#3682)
* test(layout): split the numbers and marks probes into documents Word opens Word 16 for Mac couldn't open word-stops-numbers.docx or word-stops-marks.docx. Write the moves as Word writes them, with range marks and a footnote of its own at each end, start the section past page 32767 from 32767, write the picture bullet as Word does, and split each probe into smaller documents of related cases. * feat(layout): number and place footnotes and endnotes, and write page references in words and pictures, as Word does Word's PDFs of word-stops-notes, word-stops-endnotes and word-stops-fields showed how it numbers footnotes on each page and from a later section's own number, leaves a footnote with a mark of its own uncounted, puts footnotes just below the text, puts the rest of a footnote on a page of its own before a page break, numbers the pages of a rest before a continuous section numbered afresh, ignores a section's own place for its endnotes, leaves out the text of an endnote separator, and writes CardText, DollarText, OrdText, Hex and pictures with spaces, decimals and text. * test(layout): write only the footnotes each of the next batch's notes documents refers to The kit's footnote() keeps every document's notes and write() puts them all into each document a script writes after, so the endnote documents of word-stops-notes2 carried the notes documents' footnotes, unreferenced. Word refused two schema-valid documents this round, so documents for Word shouldn't carry anything stray. kit.ts is left as the other lanes have it. * fix(layout): count only a section's own footnotes in its numbers afresh on each page Where sections numbered afresh on each page share a page, which stops the layout but which a guess lays out, the number of a footnote counted those of the section before on the page too, though its comment says its section's. * test(layout): throw at a missing marker in the marks probes' injections sectionMark, inControl, deletedRows and the TR1a and HD9b injections went on from the start of the document when their marker was missing, as it is when ONLY leaves its probe out, and wrote broken XML where the kit's injections throw, which write skips under ONLY. * test(layout): take out the footnotes nothing refers to from the page 32768 and fields probes The kit writes every footnote the script has made so far into each document, so word-stops-page-32768.docx, which goes to Word in the next batch, carried NF7's two footnotes with no reference to them. The fields document did too, with a third footnote mark on each since the numbers document was split. Every document of the script now keeps only the footnotes it refers to. The committed word-stops-fields.docx stays as Word opened it. * fix(layout): count the pages of a continuous section after a footnote's rest on pages of their own Before a continuous section, the rest of a footnote goes on pages of its own, and the number of pages of both sections was left blank, as Word counted them its own way in word-stops-notes.docx NT2b. Word counts the next section's as its own pages, though: 1 there, and 1 after FN5's rest in word-watertight-notes.docx, which master wrote and this branch had left blank. Only the first section's, which leaves out its pages of the footnote, is still left for Word. * fix(layout): note the guess of a footnote's pages before a continuous section on the first of them Guessing, the stop for a footnote continued across a continuous section break onto pages of its own, whose sections' headers and footers differ, was noted on the page of its reference. What is guessed is which footers the pages of the footnote have, so it is noted on the first of them. |
||
|
|
88aa81b43c |
feat(layout): squeeze lines, break at soft hyphens, and lay out tabs, borders and run formatting at more of their stops, as Word does (#3688)
* feat(layout): squeeze justified lines and break at soft hyphens as Word does Word's squeeze limit is 2.015 rather than 2.04 for justified, distributed, Thai-distributed and kashida lines (word-justify2 K07, K08, K09 and word-stops-tabs JU3). It never squeezes en, em or ideographic spaces (JU1), squeezes a line with bordered text as any other (JU2), squeezes a soft hyphen's part on as it would a word (SH10d), breaks a bordered word at a soft hyphen (SH11) and a first part longer than its line at characters (SH12), and breaks with the hyphen 19.9 twips short of the end (SH13). * fixup: rename shadowed parts * feat(layout): line text up with tab stops past the line's end, at decimal stops and in borders as Word does word-stops-tabs TA3: right, centred and decimal stops past the end at a line's start line the text up with the end. TA4: centred and decimal stops past the right indent line the text up with the stop. TA6: a number lines up its end, commas and all (12%, 12, 34). TA7: a box goes on round a tab in it, and bordered text lines up by its box. * feat(layout): lay out paragraph borders, indents in characters and lines below the page's foot as Word does word-stops-text PB1: paragraphs whose borders differ only by a between border share a box, with the first's between border. PB2: the empty paragraph that ends a section takes no room for its borders or automatic spacing. PB3b: a box ends before a page break. PB5b, PB5c, PB5e: a left indent in characters is in the style's size, a right one in the mark's, and a first line indent in twips goes from it. PB7b: multiple spacing's room below may go below evened-out columns. PB8: a larger mark doesn't count in a line of only a picture. word-stops-notes NT13: borders and automatic spacing take room in a footnote. * feat(layout): lay out emphasis marks, run borders and negative lengths as Word does word-stops-text RF20, RF21, RF22: emphasis marks over and under one line take a quarter of it each side, a quarter of a line with a picture, and line spacing holds them once its room is as much as theirs, with lines below single spacing scaled. RF23: a bordered long word restarts its box on each line. RF25: art border sizes are points, spaces wrap at 32, and sizes 0 and 1 are drawn. RF26, RF28: a minus sign is the whole number's only. * feat(layout): draw two lines in one at half size, and join ligatures beside Latin letters, as Word does word-stops-text RF30: Word draws two lines in one of Latin text on one row at half the size. word-stops-kerning KE3: Word joins a ligature beside a Latin letter outside Windows-1252 as beside any other. * feat(layout): break a kerned word longer than its line where its kerned letters fit, as Word does word-stops-kerning KE6a: Word measures the letters of a long kerned word on each line together, kerned, so more of them fit than measured each on its own. One with ligatures, which Word may break inside, still stops. * docs(layout): what Word's PDFs of word-stops-text, -tabs, -notes and -kerning settled * test(layout): add the probes of word-stops-text, -tabs, -kerning and -notes with Word's PDFs * test(layout): check the squeeze limit against word-justify2's K07 and K08 * test(layout): a probe of what word-stops-text, -tabs and -kerning left open, for Word's next batch * test(layout): cover a bordered footnote in columns, and tabs before a picture * style(layout): spelling and lint * feat(layout): lay out tabular figures as wide as Calibri's and Cambria's own, as Word does word-stops-kerning KE7b, KE7d, KE7f: lining tabular figures in Calibri and Cambria, and old-style tabular ones in Calibri, are as wide as their default figures. Other forms and spacings still stop. * fix(layout): stop the word-stops-text2 probe when its bordered picture's marker or run isn't found borderedPicture used the indices it searched for without checking them, so a missing marker, as when ONLY leaves RF32b out, or a picture run with properties of its own wrote a corrupt document rather than an error that write handles, as replaceMarkerRun and injectIntoParagraph do. * feat(layout): give a left tab stop past the end a line of its own with a first line or hanging indent too, as Word does word-stops-tabs TA1a, TA1b: with a first line indent of 720 and a hanging indent of 720, Word puts the tab after "TA1a text" on a line of its own and "after" at the start of the next, as master now does without those indents (TA8). TA1c, a left stop past the margin in a paragraph indented past it, where "after" doesn't fit: Word put the tab on the next line, at its stop, and broke "after" there, where docx/layout put "after" whole on the next line without stopping, so that stops now. * docs(layout): list this batch's probes in stops2/README.md, and name word-stops-text2's tab probes TA10 and TA11 master's stops2/README.md lists the batch's documents a change has followed, so word-stops-kerning and word-stops-notes go there, with what the text and tabs probes settled here, rather than in rows of their own in scripts/layout-probes/README.md. word-stops-edges.ts already has TA9a and TA9b, so word-stops-text2's tab probes are TA10a to TA10i, and TA11a and TA11b ask whether Word breaks the word after a left stop it doesn't fit after, as in TA1c, without a right indent past the margin too. * fix(layout): lay out two lines in one in a run with attributes, such as Word's revision ids The check for what else is in a run of two lines in one counted the run's attributes, which the reader gives as an _attr child, as content other than text, so a run Word wrote with w:rsidR stopped the layout. * docs(layout): give word-stops-text2's SH16j and JU4 probes the spaces they have SH16j to SH16l have 15 spaces before the soft hyphen, and JU4's first lines 6 en spaces, not 13 and 5. What each asks doesn't depend on the counts, so the header says what the probes write rather than the probes changing. * fix(layout): stop at a bordered or automatically spaced footnote that starts on the next page and goes on across pages A footnote whose least part is taller than a page starts on the page after its reference's, and startPage splits it through fillNote without splitLast, so its borders or automatic spacing went across pages without the stop splitLast makes for them. * fix(layout): line a picture after bordered text up with a right or centred stop, and keep a box open across its tab in content widths shiftAt added the box's closing room after the last word even when a picture after it had closed the box, which widthAfterTab counts already, so the text after a right stop ended a border's room before it. measureContentWidths closed a box at a tab with its border and opened it again after, where the layout keeps it open (word-stops-tabs TA7a), so a table sized to its text was a border's room wider than its line. * docs(layout): say what tabular figures in Calibri and Cambria are as wide as * fix(layout): stop at the empty paragraph that ends a section with the same borders as a paragraph beside it Word's PDF of word-stops-text PB3a shows bordered paragraphs either side of the empty paragraph that ends a section, which has none, as boxes of their own, and PB2a shows that paragraph's borders taking no room beside paragraphs without them. Whether a box of its borders before or after it goes on through it hasn't been seen, and master stopped at any borders on it, so stop there again rather than guess the box ends. word-stops-text2.ts PB3c to PB3e probe it for Word's next batch. * refactor(layout): read run borders of thin and thick lines with a medium or large gap as master's table cells do #3677 gave thin and thick lines with a medium or large gap the widths Word draws beside a table's cells, from 4 to 24 eighths of a point, which word-stops-text RF25a, a thin, thick and thin line with a medium gap of 3 points 9 points wide in a run, is one of. Only RF25b, a thick and thin line with a large gap of 4.5 points, is past those, so it alone stays a width seen at one size, and the docs no longer list RF25a's as other than a paragraph's. The read-document test of a run border not yet followed takes "custom", as apples of 4 points, which #3677 used, are an art border followed now. |