I understand from helpful discussions with developers of Writer in the past that the page layout for text should ideally produce an integer number of lines of text to prevent some odd variations in placement of the last line on a page (sometimes losing a line). To set up a good page style that produces consistent results across a book it's important to know how many lines will fit on a page, to ensure you've chosen top and bottom margins, and height and spacing for header and footer, that will allow Writer to fit a whole number of lines to the page size you've chosen. But to do this you need to know the leading, so you can calculate the line height. Obviously this varies depending on the spacing style and values chosen, but it would be very helpful to know what the starting values are. E.g. if I choose Single Spacing and a font height of 10.5pt, what is the line height? My guess is that the leading would be 1.5pt to give a line height of 12pt, but this is only a guess on my part. I couldn't find any documentation on this topic. It would be great if you could provide some, so authors can do good book layout in Writer and take some of the guesswork out of it. We need to understand how the font size and line spacing values determine the line height, so we can tell whether we've chosen margins and header and footers that produces an integer number of lines. Thanks!
It is not such easy because leading depends on the font too, especially whether it is a modern font, that includes some information about line spacing. Have you considered to use "Page line-spacing" (in the past named 'Register-true')?
Yes, but I haven't found clear documentation on 'register true' either, and I don't think it helps in making the calculation. I'm guessing I'd still need to just try it out on a reasonably long (ipsem lorum) document to see whether or not there was a spill on page 50 or 100 or 200, and would have to visually inspect every page to spot an occurrence. Based on your response and thinking about it some more, I appreciate that it would of course depend on the font, and potentially the font size within that font too. But Writer must know the values (since it does the typesetting/layout), then providing some way for the user to actually discover the numbers would be enough - that way at least they could perform the calculations. I guess the info would also have to include how subscripts and superscripts might change the numbers if the user happened to use them, too. The trouble is that at the moment it's a total black box and the user has no information other than how the text is laid out on the page in the end. From what you've said though Regina, I should change this from a request for more documentation (which can't really provide it), into an enhancement request for Writer to provide this info somehow?
@Regina, can this information be found anywhere using a macro? Which property of a Paragraph or TextPortion would store this information? I did my best trying to find it, but was not successful. I was trying to instantiate the Canvas service [1] to get a "XCanvasFont" object [2] and call its getFontMetrics() object. Maybe this would reveal the desired information. This would return a FontMetrics struct [3] which contains information about leading. However, I was not successful instantiating the Canvas service through a macro, so the method was unreachable. [1] https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1rendering_1_1Canvas.html [2] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1rendering_1_1XCanvasFont.html [3] https://api.libreoffice.org/docs/idl/ref/structcom_1_1sun_1_1star_1_1rendering_1_1FontMetrics.html
Created attachment 175444 [details] Macro that Loads all font metrics @Luke... I created a Calc sheet with a macro (just click the button on it) that loads the Font Metrics of all fonts available in your system. This include metrics as Leading, Ascent and Descent. Beware that if you have a lot of fonts, it will take a few minutes to finish loading. On my PC with 8 thousand fonts, it took 5 minutes. Could you please verify if this information would help you determine line height? If so, let me know because I'll create the corresponding documentation. And maybe add this macro to one of the built-in LO macros.
It was a real battle to get Calc to let me run the macro. Initially, the file opened with a warning that untrusted macros wouldn't be run. I then navigated via Tools->Macros->Run Macro to navigate to the AllFontMetrics macro and select Run. Nothing at all happened - no warning that it couldn't run, but no indication that it was running, either. [1] Next I tried clicking on the button, with the same result. Then I opened Tools->Macros->Edit Macro and navigated again to the LoadFontInfo macro and selected Run. This time it immediately failed with a message on an error panel [containing text that can't be copied and pasted, which is annoying][2]: For security reasons, you cannot run this macro. For more information, check the security settings. I did that, and changed my security settings for macros from high to Low, and hit OK. I tried again, and got the same security error. I closed the file and reopened it, and checked that the macros security option was still set to Low, and tried again, and got the same security denial. In desperation, I exited from LibreOffice entirely and restarted. At that point it worked. So neither (1) the message about the security setting, nor (2) changing the security settings and applying/okaying the change prompted the user that the changes would not take effect until exiting and restarting LibreOffice entirely. [3] I don't have time to report items [1], [2], and [3] as bugs. Anyway, checking into my specific case to try to give Rafael some useful information, it's not at obvious how to use the information I see. Since I know a bit about font design and typesetting, I'll see if I can puzzled it out here... I typically set my 5"x8" format books using 10.5pt Georgia. It seems possible that it uses a line height of 12pt (so I suppose you could say a leading of 1.5pt), if my guess is right. Now, the info provided doesn't include the typeface 'style', so I simply get the name Georgia repeated four times (no indication of Regular, Italic, Bold, Bold Italic), although in this case it doesn't matter because all the metrics are the same for each of the four. To be concrete, I get: Name Height Ascent Descent Leading Slant ... Georgia 17 16 4 3 0 Georgia 17 16 4 3 0 Georgia 17 16 4 3 0 Georgia 17 16 4 3 0 Hmm: assuming the calculation would be: Inter Line Gap factor = Leading / (Height + Descent) Inter Line Gap factor = Inter Line Gap factor * Font size yields 3 / (17+4) = 1/7 for the Inter Line Gap factor and 10.5pt/7 -> 1.5000pt Which does indeed give me the answer I would expect in this example at least, so I think you may have solved the problem Rafael - thank you! So, Writer could look up those metrics for the font style and height selected for a paragraph style, and report that information as a read-only figure on the Indents & Spacing tab for the Paragraph Style panel. I assume the Line Height number reported would have to be modified by a multiplying factor if one was included in the paragraph style (like 1.15, 1.5, Double spacing) was selected, or by an addition if some additive factor was chosen as the Line Spacing in the Indents & Spacing tab; or copied from the user selected figure if Fixed was selected, or just use the Leading factor if the user selected that? Doing a quick comparison with Times New Roman, which my 'rule of thumb' learnings have said is usually set as if Line Height is 1pt larger than the font size (so, 10/11, 11/12, 12/13) is roughly right: The metrics give 2/21 as the inter line gap factor, so would give 10/10.95, 11/12.05, 12/13.14. (I remember that this changes to Size/Size+2 at some point around 15pt - and so on as the font size increases further - but can't remember exactly where.) I don't know whether Writer rounds the line heights to integer values or works with fractional line heights as it lays out lines of text on the page. That's an important fact important to know, too, but is easily handled by reporting the figure with two or four decimal digits of precision if it uses fractions, otherwise as whole number if it rounds. Note: I understand that when the writer uses superscripts, inserts larger text, or images etc. in a line, it must increase the leading for such lines - but the user should also understand the such text layout changes may alter the number of lines that will fit on such a page. Therefore I think that issue isn't something Writer could be reasonably expected to do much about. I.e. the normal-case Line Height figure is enough. --- Just a final note on the font naming thing: it would be important for the Regular/Italic/Bold/... font style used in the paragraph style to be looked up as the basis for the calculations, if the feature is added to Writer. If it's not added, it would be good if the font style could be appended (in some way) to the font name in the spreadsheet. Here's a few names from the typefaces around Georgia in my list: Gesture Slant BRK Gesture BRK Georgia Georgia Georgia Georgia Gentium Book Basic Gentium Book Basic Gentium Book Basic Gentium Book Basic Gather BRK Gardiner Noto Sans Telugu UI ExtraCondensed Thin Gaposis Solid BRK Gaposis Outline BRK Gamaliel Galvanize BRK Galapogos BRK Noto Serif Tamil ExtCond ExtBd GFS Porson GFS Baskerville Furat Fully Completely BRK Quacksalver BRK Comic Neue Angular Light Comic Neue Angular Light Noto Serif Kannada SemiBold Comic Neue Angular Comic Neue Angular Comic Neue Angular Comic Neue Angular Comic Neue Light Comic Neue Light Combustion Wide BRK Combustion Tall BRK Combustion Plain BRK Combustion II BRK Combustion I BRK Noto Sans Thai SemCond Blk and a few around Times New Roman: Noto Serif Kannada ExtraBold Noto Serif Kannada Noto Serif Kannada Noto Serif Hebrew Thin Noto Serif Hebrew SemCond Light Noto Serif Hebrew SemCond ExtLt Noto Serif Hebrew SemCond Blk Noto Serif Hebrew SemBd Noto Serif Hebrew Light Noto Serif Hebrew ExtLt Noto Serif Hebrew ExtCond Thin Times New Roman Times New Roman Times New Roman Times New Roman Noto Serif Hebrew ExtCond SemBd Noto Serif Hebrew ExtCond Light Noto Serif Hebrew ExtCond ExtLt Noto Serif Hebrew ExtCond ExtBd Noto Serif Tamil ExtCond Light Noto Serif Hebrew ExtCond Blk Noto Serif Hebrew ExtCond Noto Serif Hebrew ExtCond Noto Serif Hebrew ExtBd Noto Serif Hebrew Cond Med Noto Serif Hebrew Cond ExtLt Noto Serif Hebrew Cond Blk Noto Serif Hebrew Noto Serif Hebrew Noto Serif Hebrew Blk Thanks again, Rafael. I'll be interested to hear if my single example calculations (Georgia, 10.5 pt) are correct. Nor do I know what
Sorry, where I wrote: "Hmm: assuming the calculation would be: Inter Line Gap factor = Leading / (Height + Descent) Inter Line Gap factor = Inter Line Gap factor * Font size" I meant to write: "Hmm: assuming the calculation would be: Inter Line Gap factor = Leading / (Height + Descent) Inter Line Gap = Inter Line Gap factor * Font size" ^_____
Created attachment 175459 [details] Macro that Loads all font metrics V2 Luke, I uploaded a new version of that Calc file with the macro. Now it returns the style and calculates the ILG factor using the formula you provided. Beware that to run it, you should use LO 7.1 or higher. The name of the macro is "LoadFontInfo". I believe LibreOffice does some rounding after applying the factor, but I am not an expert in font rendering. Maybe we'll need feedback by someone else to confirm if (and how) rounding is applied.
It looks good Rafael. I see I have over 3,000 fonts on my system. It gave plausible results for them. I did some experiments with some fonts with weird Leading value (negative, zero, some relatively large positive values), and all gave reasonable results. There are some very strange fonts out there, incidentally!