summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
Commit message (Collapse)AuthorAgeFilesLines
* layout: Fix line height computationslayout-font-scaleMatthias Clasen2022-09-061-2/+7
| | | | | | | | We were using the font metrics height, which is scaled by the ctm, so we need to take the font scale factors into account here. Fixes: #691
* layout: Apply show flags to line separatorsMatthias Clasen2022-07-031-2/+26
| | | | | | | We only want line separators at the line end to be visible when the show flags say so. This was not working before, because the shaping always marks LS as unknown glyph.
* Avoid overflow when calculating caret slopeMatthias Clasen2022-06-211-1/+1
| | | | This showed up as wrong slopes with font size > 60.
* Apply 1 suggestion(s) to 1 file(s)survive-without-fontsMiloš Komarčević2022-04-111-1/+1
|
* layout: Try harder to survive without fontsMatthias Clasen2022-04-081-1/+6
| | | | | | | | No great typography can be expected without fonts, but we should try not to crash, since this situation can apparently happen on Windows. Fixes: #680
* Fix move pango_layout_move_cursor_visuallyfix-rtl-cursor-moveMatthias Clasen2022-03-311-2/+2
| | | | | | | | | | When moving the cursor off the paragraph end to the left in RTL text, we were moving to the previous line, and not to the next line, as expected. Test included. Fixes: #679
* Drop the hb-glib dependency againMatthias Clasen2022-03-091-2/+1
| | | | | | It is not really needed. Fixes: #674
* layout: Handle baselinesbaseline-handlingMatthias Clasen2022-02-171-2/+64
| | | | | | | During post-processing for lines, take into account the baselines for each run, and shift them vertically to align them on the dominant baseline.
* Avoid an uninitialized variable warningMatthias Clasen2022-01-061-1/+4
| | | | Fixes: #650
* layout: Make sloped carets work betterMatthias Clasen2022-01-031-1/+4
| | | | | | | | When the font matrix has uneven scales, we need to factor that into the slope that we get from the font metrics. Tested with a condensed italic Cantarell.
* Fix line height with emulated small capsfix-small-caps-line-heightMatthias Clasen2021-12-191-8/+19
| | | | | | | | When we change font scale for emulating small caps, keep the original font around in the analysis, and use it for calculating the run height. Fixes: #622
* Improve line width accountingMatthias Clasen2021-12-181-1/+1
| | | | | | | We want to avoid trading chars for hyphens in the margin beyond the set width. Fixes: #646
* layout: Fix a cornercase of line width accountingMatthias Clasen2021-12-181-8/+12
| | | | | We don't collapse space at the very end, so we should count such spaces towards the line width.
* 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.