This week’s post comes from Theresa Estrada, the program manager responsible for layout in Word.
Since the Office Customer Preview was announced a few weeks ago, we’ve talked quite bit about the vision for the product and the new features that you’ll be able to take advantage of when you try it out. One area that we invested heavily in this release, but has remained under the radar, is our work on the layout engine that Word uses. When I say “layout” I’m referring to the way that Word places everything onto the page. The position of everything from a single character of text to a complex table is calculated during layout and then the results are displayed on the screen. This technology really forms the core of our product.
We know from talking to you that layout is absolutely critical. So critical, in fact, that the tiniest change to the layout of a document between versions can be a big issue. With this in mind, we have always been incredibly focused on trying to maintain compatibility between versions of Word. Unfortunately, this has constrained our ability to both tweak layout in complex cases and to offer new, more sophisticated document layout features – two things that folks regularly request.
In past releases, we introduced Compatibility Mode to help ensure layout fidelity between versions. With this release, we went a step further. While we still have Compatibility Mode, files upgraded to Word 2013 mode use a new and much improved layout engine.
A little background
There are two components that make up the new layout engine in Word: Line Services and Page & Table Services.
Line Services, or LS, is a component that is used in products across Microsoft to control line layout. This was originally included in Word 2000. Since that time, LS has handled everything from individual characters, like basic Latin characters, to math equations and special East Asian phonetic objects. It also includes how text is broken at the end of a line.
Page and Table Services, or PTS, was first introduced in Word 2007. This component is used to handle the layout of everything outside the control of Line Services. For example, it handles the layout of objects like tables and figures (pictures, charts, SmartArt, etc), as well as their interactions with the paragraphs of text on the page.
You might be thinking “Wait, she said this was a new layout engine but these were already included in Word. What gives?” Yes, LS and PTS have both shipped in Word before, but they were never fully integrated into Word – we were able to use just a fraction of their goodness because we were working hard to maintain compatibility with the prior version.
With the new layout engine we had three goals:
- More accurate, predictable layouts
- Start introducing new, more sophisticated layouts
- Improved performance
More accurate, predictable layouts
The existing layout engine in Word evolved over many releases. As such, the original design didn’t account for many of the features that were later added to Word. This meant that we didn’t always handle layout efficiently or in an intuitive way – which could leave you scratching your head and wondering why Word was behaving so strangely. Even though we used LS and PTS, we had to carry forward existing behaviors (even the strange ones) to help ensure compatibility.
The first order of business in fully integrating LS and PTS into Word was to break the pattern of carrying forward undesirable behavior. The newer, cleaner code of LS and PTS didn’t include many of these issues and by fully integrating with the components, we were able to address many of these behaviors. The end results are often subtle: text can be more evenly balanced across multiple columns, table cells can be more accurately auto-fit to their contents and figures’ positioning properties are applied more faithfully.
Sophisticated new layouts
We often hear from customers about layouts you wish you could achieve in Word. In many cases, customers are using tools such as LaTEX to produce perfectly typeset documents and wish they could do the same in Word. While we don’t claim to have reached that level of professional typesetting, LS and PTS have opened the door to start introducing new layout features.
For starters, we’ve taken further strides forward with LS, by introducing a new algorithm to handle line breaking. This algorithm considers several aspects of the line, such as word length, spacing between words and possible hyphenation points, to break each individual line at a point which provides the best fit for the line. This allows us to be smarter about line breaks and produce text that is easier for readers to consume.
Going beyond this, in Word 2013, you will be able to:
- Create footnotes using a different number of columns than what is used in the main document
- Insert pictures that are taller than 22” in web layout, which is now a truly “bottomless” page
- Wrap text around a figure in a header
There are two areas where the move to the new layout engine has helped us to improve performance. First, because the code is cleaner and more efficient, we can simply calculate layout faster than we could before. In many cases, this has allowed us to make other improvements in the product, such as the new Live Layout feature which continually updates layout as figures are moved around the page. While this feature will still work in compatibility mode, for complex documents it will be faster in Word 2013 mode. In addition, the speedier layout calculations allow us to be more accurate when determining layouts that require some recursive calculations. For example, in a document with two columns, we may need to do multiple passes of layout to account for complex situations like figures that overlap both columns. In this case, we can quickly repeat the layout calculations to get to the best result.
The second area where performance was improved was in the web layout view. For those who aren’t familiar with this view, it was introduced to help author digital content. Its big advantage for this type of content is that it isn’t constrained by pages. Instead, it is a single “bottomless” page. In order to make this work in prior versions of Word, a behind the scenes limit of around 22” was actually enforced, which made working with very large figures and tables difficult.
In Word 2013, this limit of 22” was removed. What made this possible was the ability to incrementally layout and redraw only the portion of the page that is being changed. By not having to update the entire document on every change, we were able dramatically improve performance in this situation.
When you launch Word 2013, you won’t notice any big changes related to this layout investment right away. If you start a new document, you will automatically be using the new layout engine and able to take advantage of all its goodness. Documents created this way will use the same file format, so they will open in prior versions of Word as expected. Because the layout engine has changed, however, documents created in Word 2013 mode may lay out differently when opened in the prior version. If you work in an enterprise where sharing documents across versions of Word is common, a group policy exists to force all new documents to be created in compatibility mode.
For existing documents, we recognize the need to maintain layout fidelity across versions. These documents will always open in compatibility mode, which is indicated in the title bar of the Word window.
You have the option of converting these to the Word 2013 mode to take advantage of the new features. To do this, click the File button, then click the Convert button on the Info tab.
If maintaining layout compatibility is critical to you, we don’t recommend converting. For many simple documents however, converting will not result in any noticeable changes.
Setting the stage for the future
We are definitely excited about the changes we’ve enabled in Word 2013 by embracing the new layout engine. What we’re even more excited about is what this enables us to do in the future. Line Services and Page & Table Services open the door to a world of new features that would not have been possible in the past.
The layout changes in Word were brought to you by the PTLS feature crew, most of whom are shown here. If you want to learn even more about the history of the team and the components, check out Murray Sargent’s MSDN blog about Line Services.