Monday, September 30, 2013

GSoC 2013 - Character border

Character border (fdo#35155)

In this summer I participated in Google Summer of Code and implemented border on the character level. So in the next 4.2 version of LibreOffice users will be able to set border around a run of characters.

Two example of character border. Above there is a drop cap letter with double border and blue background. Under there are two words with a blue border around it plus a box-shadow on the top-right side of the border.

The character border can be specified as a direct formatting via Format -> Character -> Borders tab and it also can be the part of a character style (e.g. Format -> Styles and Formatting -> Character Style). One special case of the latter is drop caps character style.

Drop Caps

While I was working with character border and I was testing whether it works in all cases I realized that Drop Caps has some bugs which keep me from adding my new feature. So I have to solve them before I able to keep on my original project:

1. User defined background was shifted upward
Two parts of the picture shows the background painting before the bug fix and after that. Before the default gray background was hanging out from behind the user defined yellow background. The after part shows that after fixing the bug only the user defined yellow background is painted.
Since border is drawn at the edges of the background, it was also drawn at the wrong place.

2. Changing line height
A drop caps with the deafult gray background and a red arrow showing that the first line of the paragraph next to the drop cap has bigger height as it is expected.
Height of the first line was changing unexpectedly when the drop cap letter's original height was bigger than the height of the following characters. Original means the height which it would have if it wasn't a drop cap. By now this original height is ignored during height calculation of the first line.
Since border rendering increase this height with the border width, line height also increased with this width.

3. ODF import loses drop caps character style (fdo#43807)
It also loses the border including by this character style.

Border merge

The implementation of character attributes and the specification of ODF file format make it necessary to add automatic border merge functionality. Border merge means that if two text ranges have equal border (same line, padding and shadow) they will be rendered inside the same border.

Above there is a text with two bordered text range with one Q letter between them. After this Q letter is removed the two border text range are merged and so are rendered within the same border.

Border merge also means background merge, since this is a general concept to draw border at the edges of the background.
When there are letters with different sizes and they have background then this background's height will depend from the height of the text. So letters with different size will have different hight background. But if this letters are merged to one border group then they will have a coherent background.

File formats

List of file formats to which/from which Writer exports/imports character border:


  1. That will be great if you publish this enhancement under Apache licence.
    Then we would have it with LibO and AOO.

    1. I've already published it by committing to LibreOffice central repository and it means MPL / LGPLv3+ licence.

    2. Copyleft licence is not compatible with ALv2. So maybe, you can change it? To benefit the users of your code in both suites.

    3. As I know copyleft means that if I modify the code I will have to use the same license.

    4. ... and LibreOffice use MPL/LGPL copyleft license.

  2. Congratulations and thank you very much for this improvement!

  3. Have you ever considered about adding a little bit more than
    just your articles? I mean, what you say is fundamental and everything.
    Nevertheless think about if you added some great photos or video clips to give
    your posts more, "pop"! Your content is excellent but with pics and video clips, this blog could undeniably be one of the greatest in its niche.
    Awesome blog!

    my blog ... Dish latino, ,

    1. Yes, you're absolutely right. The truth is that it's not a real blog, rather an information table. Maybe I should write Wiki pages instead. :D