summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
Commit message (Collapse)AuthorAgeFilesLines
* layout: Handle a corner caseMatthias Clasen2021-12-091-1/+3
| | | | | | | | | We can't break in a tab run. This fixes an assertion found by afl. Testcase included. Fixes: #638
* Fix line width computationMatthias Clasen2021-12-061-1/+26
| | | | | | | | | | We an only use the line_width - remaining_width shortcut if we are actually maintaining remaining_width, i.e. not if we don't wrap lines. Testcase included. Fixes: #635
* Fix a crash in tab handlingtab-crash-fixMatthias Clasen2021-12-051-3/+19
| | | | | | | | | | When we uninsert the current tab run, we need to reset our tab state to prevent last_tab->glyphs to become a dangling pointer. Test included. Fixes: #634
* Fix up tab sizingtab-speedupMatthias Clasen2021-12-021-23/+18
|
* layout: Small optimizationMatthias Clasen2021-12-021-25/+3
| | | | | Don't calculate line width the hard way when we can do it much easier.
* layout: Optimize tab handlingMatthias Clasen2021-12-011-1/+1
| | | | | | We don't need to iterate the entire tab array every time, we just continue from the previous tab stop position.
* layout: Call pango_tab_array_sortMatthias Clasen2021-12-011-3/+6
| | | | | We want to optimize access to tab stops, and will assume they are ordered.
* layout: Some restructuring of tab handlingMatthias Clasen2021-12-011-54/+43
| | | | Introduce a LastTab struct, and use it.
* tabs: Add a decimal pointMatthias Clasen2021-11-291-9/+39
| | | | | | | This is useful for PANGO_TAB_DECIMAL. Implement this in PangoLayout, in the serializer, and update tests.
* layout: Implement tab alignmentsMatthias Clasen2021-11-291-57/+201
| | | | | | | | | | | | | Implement the other tab alignments by adjusting the tab width as we go. Based on an old patch by Itai Bar-Haim. This also includes a fix for the previously supported left tab alignment in the presence of indent. Fixes: #34
* docs: Add a note on tabsMatthias Clasen2021-11-291-1/+2
| | | | | Explain that tabs really only work with PANGO_ALIGN_LEFT.
* Fix line heights in improper gravitiesgravity-fixesMatthias Clasen2021-11-271-1/+1
| | | | | | | | | | | Without this, we end up with line height being zero in gravity north or west. The visible symptom is that wrapped lines are drawn on top of each other with line-height != 0. Affected tests have been updated. Fixes: #631
* Avoid an out-of-bound accessMatthias Clasen2021-11-271-1/+1
| | | | | We can only use the width of the previous char if we are not at the first char. Found by asan.
* Make sure glyphinfo is fully initializedMatthias Clasen2021-11-261-0/+1
| | | | | The alternative is random test failures, now that we check all these fields in test-layout.
* Fix handling of extra widthline-breaking-fixes4Matthias Clasen2021-11-221-5/+23
| | | | | | | When handling items that fix completely, we were not consistently taking extra width into account, leading to hyphens sticking out in some cases.
* Fix a case of unintended hyphenationMatthias Clasen2021-11-221-1/+2
| | | | | | | | | | | | | When we take a complete item because there are no breakpoints, we were inserting a hyphen at the end even though there may not be a breakpoint there, and ending up with a hyphen in the middle of an (overlong) line: Brat-wurst. Test included. This but was discovered with the help of http://gitlab.gnome.org/matthiasc/layout-editor
* Neuter g_debug in line-breakingtake-out-gdebugMatthias Clasen2021-11-181-35/+37
| | | | | | This code gets run for gtks size-allocation, and we don't want it to be any slower than it has to be, when not debugging it.
* Fix a thinko in zero_line_final_spaceMatthias Clasen2021-11-161-1/+0
| | | | | | | | | | | We must not add the width of the space back to remaining_width, since we're just correcting the glyphs to match the accounting that process_item has already done. This was showing up as justification operating on wrong numbers when justifying lines with a final space, leading to uneven margins.
* Correct the extra_width accountingMatthias Clasen2021-11-161-2/+5
|
* Rewrite process_itemMatthias Clasen2021-11-161-214/+309
| | | | | | | | | | | | | | | This is not an entire rewrite, the basic approach to fitting items is still the same. The main difference here is that we shape and measure a possible breakpoint before accepting it as candidate for breaking. This is necessary to ensure that we have accurate width information when making decisions about this breakpoint - the width we are calculating based on log widths is only an approximation (due to things like clusters, hyphens, final spaces, etc). To avoid excessive shaping, we only do this extra work when we are close to the end of the line.
* More tweaks, and commentsMatthias Clasen2021-11-151-15/+22
|
* Go back to an array for disabled breakpointsMatthias Clasen2021-11-151-10/+24
| | | | | It turns out that we do need to look for longer breakpoints after all if we want to find optimal solutions.
* Fix line-break accounting moreMatthias Clasen2021-11-151-5/+11
| | | | | | | | | | | | | | | When looking for breakpoints, we were assuming that there is no point to keep looking forward once we hit a spot where the broken off part is too long. But with hyphen insertion, that is no longer true, necessarily. Consider 'bli '. Breaking after 'bl' will insert 'bl-', which might be longer than 'bli', which is what will be inserted when we break after the i. To fix this, keep looking for breakpoints as long as there is still a chance to find one.
* Improve the BREAK_ALL_FIT caseMatthias Clasen2021-11-151-9/+30
| | | | | We always need to check if we still fit, after shaping. The width we use before is just an estimate.
* layout: Simplify things one more timeMatthias Clasen2021-11-141-16/+9
| | | | | | | | | | | | | The key insight here is that if we find a broken item does not fit, we are only interested in finding an *earlier* breakpoint - the later ones aren't going to produce a shorter run. So we can just keep track of the last char we want to allow breaking at. This fixes the case of finding the minimum width with wrap mode PANGO_WRAP_WORD.
* CosmeticsMatthias Clasen2021-11-141-1/+0
|
* Fix a thinkoltr-line-breaking-fixesMatthias Clasen2021-11-121-1/+1
|
* Fix another corner case of space-handlingMatthias Clasen2021-11-121-5/+17
| | | | This keeps spiraling :(
* Fix up one more case of break-after-spaceMatthias Clasen2021-11-121-11/+11
| | | | | | If the break is at the end of the item, we were forgetting to check for the space before the break.
* Handle break-after-space correctlyMatthias Clasen2021-11-121-1/+15
| | | | | | | | | | | | | | When we are breaking after a space, we must not count the width of the space towards the line, since we are zeroing it later. It is a bit annoying that there are multiple places where this has to be taken into account. Another missing bit in this code is that we are only looking at a single whitespace character before the break, when we should really look for a sequence of spaces.
* Correctly reinstate remaining_widthMatthias Clasen2021-11-121-1/+3
| | | | | When unsplitting an item, we were sometimes calculating the remaining_width incorrectly.
* Simplify find_break_extra_widthMatthias Clasen2021-11-121-25/+1
| | | | We can use the log_widths that we already have.
* Simplify breakpoint disablingMatthias Clasen2021-11-121-30/+9
| | | | | | We only want this inside process_item, so we can make this a purely local thing, without modifying log_attrs.
* CosmeticsMatthias Clasen2021-11-121-1/+2
|
* Try harder to not produce overlong linesavoid-overlong-linesMatthias Clasen2021-11-111-0/+48
| | | | | | | | | | | Our accounting for run lengths is imperfect (mainly due to log widths for clusters being evenly distributed), so it can happen that after reshaping the split item, we find that it does not actually fit in the remaining width. Previously, we would just use the split run at that point and produce an overlong line. Instead, undo the split, disable the breakpoint we used, and try again.
* CosmeticsMatthias Clasen2021-11-111-2/+2
|
* layout: Fix a poblem with hyphen widthMatthias Clasen2021-11-101-8/+5
| | | | | In some cases, we were forgetting to account for the width of a hyphen.
* Reshuffle itemize APIMatthias Clasen2021-11-081-7/+13
| | | | | | | | | | | Split the post-processing off into a separate function that can take log attrs in addition. This will allow us to handle word starts when dealing with text transforms for emulated Small Caps. So far, this is all private API that is used from PangoLayout. Please file an issue if you want to access Small Caps emulation without PangoLayout.
* Flesh out some doc commentsMatthias Clasen2021-10-291-1/+9
| | | | | Add some missing details about new enumerations and run baselines.
* add missing since 1.50 annotationsBilal Elmoussaoui2021-10-291-0/+6
|
* Fix cursor pos height in some casesMatthias Clasen2021-10-191-18/+28
| | | | | | | For empty runs, we were sometimes using line height, which may be scaled up by the line-height attribute. Fix that.
* Fix empty line heightsMatthias Clasen2021-10-191-0/+24
| | | | | | Fix the calculation of line height for empty lines to take the line-height attributes into account like we do for non-empty lines.
* layout: Fix static analysis warningsMatthias Clasen2021-09-171-4/+4
| | | | | These were showing up as warnings about garbage values in the gtk static-scan build.
* Be more forgiving about attribute orderingMatthias Clasen2021-09-011-10/+16
| | | | | | | | | | | | We don't really have firm control over the way attributes are ordered in the list, so the assumtion that we see proper nesting for baseline shifts was a bit optimistic. Just look through all open stack items for a match, and remove that. Test included.
* Add horizontal displacementMatthias Clasen2021-08-311-34/+60
| | | | | | | | | | | Apply horizontal displacements for superscripts and subscripts that are provided in font metrics. This noticably improves the placement of superscripts in italics. Currently, we only apply these displacements in post-processing, and ignore the width changes during line-breaking. This could be improved by moving the baseline handling into the line-breaking proper.
* Implement font-dependent scalingMatthias Clasen2021-08-311-0/+1
| | | | | | | Add a new font-scale attribute to indicate font size changes due to super- and subscript shifts, and handle it during item post-processing to find the right font sizes.
* Implement baseline shiftsMatthias Clasen2021-08-311-26/+142
| | | | | | | | | | | Add a new baseline-shift attribute, which is similar to rise, but accumulates. In addition, it supports font- relative values such as superscript and subscript. We implement support for this by computing baseline shifts for run during line post-processing, and storing them in the runs. The renderer now takes these shifts into account when rendering layout lines.
* layout: Use pango_glyph_string_index_to_x_fullMatthias Clasen2021-08-291-18/+35
|
* Add pango_layout_iter_get_run_baselineMatthias Clasen2021-08-291-0/+16
| | | | This is useful information.
* layout: Apply rise to cluster extentsMatthias Clasen2021-08-291-0/+6
| | | | This has been broken all along. :(