summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
Commit message (Collapse)AuthorAgeFilesLines
* 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. :(
* layout: Allocate a bit lessMatthias Clasen2021-08-281-7/+11
| | | | | Instead of throwing away the log_widths array for every run, keep it around and grow it as needed.
* layout: Use char_offset in a few placesitem-offsetMatthias Clasen2021-08-281-23/+9
| | | | There is more we can do here, but this is a start.
* carets: Fix rect for negative slopesMatthias Clasen2021-08-271-0/+4
| | | | | | The intention was to flip the rectangle horizontally. We do return a negative width, but we forgot to flip the origin.
* docs: Add another illustrationMatthias Clasen2021-08-261-1/+6
| | | | Show cursor positions.
* hyphen: Try harder to insert needed hyphensMatthias Clasen2021-08-251-4/+43
| | | | | | | We were forgetting to reshape runs in some situations, leading to them not having hyphens appended. This was happening when runs fit fully onto the end of a line that is wrapped anyway.
* Add segmentation attributesbreak-tailoringMatthias Clasen2021-08-251-0/+2
| | | | | | | Add attributes that let us override word and sentence boundaries (and, indirectly, line breaks). Tests included.
* Merge branch 'hyphen-log-attr' into 'main'Matthias Clasen2021-08-251-137/+42
|\ | | | | | | | | | | | | Add hyphens to log attrs Closes #603 See merge request GNOME/pango!436
| * Refine hyphenationMatthias Clasen2021-08-251-8/+42
| | | | | | | | | | | | | | | | Replace ‧ and | with a - when we break there. Update affected test output. Fixes: #603
| * layout: Use need_hyphen from log attrsMatthias Clasen2021-08-241-130/+1
| |
* | Add an illustration for caret metricscaret-slopeMatthias Clasen2021-08-241-1/+4
| |
* | Add pango_layout_get_caret_posMatthias Clasen2021-08-241-5/+95
|/ | | | | This is like pango_layout_get_cursor_pos, but returns a rectangle that has caret font metrics applied to it.
* break: Add pango_attr_break apiMatthias Clasen2021-08-231-7/+15
| | | | | | | | | | | | So far, we've been applying attribute-based customization while doing per-item tailoring. But this is suboptimal, since it means we don't have a full view of the log attrs, and can't do invariant fixes that cross item boundaries. Therefore, add a separate pango_attr_break api that applies attributes to to the whole paragraph, and make PangoLayout use it.
* layout: Only recompute log_attrs when neededMatthias Clasen2021-08-231-15/+21
| | | | | | There is no need to throw away the log_attrs when we just change the width, or other layout properties that do not affect segmentation.
* Fix an oversight with text-transformMatthias Clasen2021-08-221-1/+1
| | | | | With the current implementation of text-transform, we need the attribute to be constant across runs.
* layout: Silence compiler warningsMatthias Clasen2021-08-221-26/+27
|
* layout: Use pango_shape_itemMatthias Clasen2021-08-201-4/+5
| | | | Use the new API, and pass our log attrs along.
* layout: Text transform affects shapeMatthias Clasen2021-08-201-0/+1
| | | | | Classify text transform as an attribute that affects shaping. It will, in the future.
* layout: Fix some wrapped line start positionsblock-cursor-fixesMatthias Clasen2021-08-201-1/+2
| | | | | Make pango_layout_index_to_pos report non-empty pos for the first position in a wrapped line.
* layout: Fix some end-of-line positionMatthias Clasen2021-08-201-7/+8
| | | | | Make pango_layout_index_to_pos report non-empty rectangles at the end of a line.
* Fix pango_layout_index_to_pos resultsMatthias Clasen2021-08-201-6/+9
| | | | | We were returning wildly incorrect results for anything but the first run in a line.
* Document incompatibility of tabs and justificationdocument-tabsMatthias Clasen2021-08-191-1/+12
| | | | | | Not great, but these *are* conflicting features. Fixes: #595
* Add pango_justify_last_lineMatthias Clasen2021-08-101-2/+55
| | | | | | | Add a way to justify the last line in a justified paragraph. Fixes: #74
* Fix more corner cases around line endsMatthias Clasen2021-08-091-4/+18
| | | | | | We were miscounting the cursor positions in a line, causing us to jump down to the next line when moving backwards towards the start of the line.
* Fix corner cases around line endsMatthias Clasen2021-08-091-12/+16
| | | | | | | | | | pango_layout_index_to_line_and_extents needs to return a run rect even if the line has no non-empty runs. Failing to do so was causing cursors at the end of lines to have a height of 0 or 1, which is not what we want. Add a testcase.
* docs: Add an example for split cursorsMatthias Clasen2021-08-091-1/+15
| | | | | | | Show how weak and strong cursors look in practice. Fixes: #77
* docs: CosmeticsMatthias Clasen2021-08-081-3/+2
| | | | No need to link a function to itself.
* docs: Add one more dark mode imageMatthias Clasen2021-08-081-1/+4
|
* Fix up logical rectangle reportingMatthias Clasen2021-08-081-24/+76
| | | | | | | | | | | | | Fix up the various apis that are reporting logical rects to follow these rules: Logical rectangles of lines are affected by the line-height attribute, logical rectangles of smaller units (runs, clusters, chars, cursors, etc) are not. This fixes the text cursors and block cursors in GTK to be 'normal' height, even when applying line-height for double-spacing.
* layout: Handle line-height attributesMatthias Clasen2021-08-081-1/+30
| | | | | | | | | Modify the height and vertical origin of logical extents according to the line height attributes. We currently apply half the leading above and half below the content (i.e., lines are vertically centered in their modified height).
* Add line-height attributesMatthias Clasen2021-08-081-0/+3
| | | | | | | | | | | | Add attributes for line-height, in a relative and absolute variant. This will be used to grow the logical extents of runs in a way that is compatible with CSS semantics. In markup, we support a new line_height attribute that will be interpreted as absolute if it is an integer > 1024, and as a relative factor otherwise.
* docs: Add more detailsMatthias Clasen2021-08-081-0/+10
| | | | | Add some visualization of alignment and justification to the PangoLayout docs.
* docs: Some clarificationsMatthias Clasen2021-08-081-2/+7
| | | | | Add some more detail around baseline-to-baseline distances.
* Tweak the docsbidi-revengeMatthias Clasen2021-08-081-7/+6
| | | | | Make the docs for pango_layout_move_cursor_visually a bit more clear.
* Reimplement pango_layout_move_cursor_visuallyMatthias Clasen2021-08-081-171/+107
| | | | | | | | Reimplement this function based on pango_layout_get_cursor_pos. This is a bit less efficient, but it fixes cases where the old implementation would get stuck. Fixes: #587, #585, #157
* Try to improve pango_layout_get_cursor_posMatthias Clasen2021-08-081-9/+27
| | | | | Try to disambiguate run boundaries better. Not sure this works as intended, yet.
* Revert a non-longer needed changeMatthias Clasen2021-08-041-8/+0
| | | | | | | | | | | This reverts 681f92d78c2623, after adding the crash that it alludes to as a test case and verifying that it no longer crashes. This commit was causing split cursors to not work as intended at the end of a mixed-direction string. Broken since 2008...
* layout: Add some api for introspectionMatthias Clasen2021-08-011-0/+65
| | | | | | Add accessors for PangoLayoutLine fields. Fixes: #553
* CosmeticsMatthias Clasen2021-07-091-3/+3
|
* Merge branch 'fix-empty-line-spacing-2' into 'master'Matthias Clasen2021-07-091-13/+17
|\ | | | | | | | | | | | | layout: make the height of an empty line match a regular line Closes #577 See merge request GNOME/pango!363
| * layout: make the height of an empty line match a regular lineArtem Rebrov2021-07-081-13/+17
| | | | | | | | | | When using line-spacing, the height of an empty line is the same as when line-spacing has zero value. Take the value from font metrics.
* | docs: Small layout docs improvementsMatthias Clasen2021-07-091-6/+11
|/ | | | | Add some more default values, and correct the docs for pango_layout_set_spacing wrt to the default value.
* layout: Zero out log attrsMatthias Clasen2021-07-061-1/+1
| | | | This makes tests more reproducible.