Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for vertical text bounds and alignment #9133

Merged
merged 12 commits into from Jul 13, 2023

Commits on Jul 12, 2023

  1. Update GlobalTransform on insertion (bevyengine#9081)

    # Objective
    
    `GlobalTransform` after insertion will be updated only on `Transform` or
    hierarchy change.
    
    Fixes bevyengine#9075
    
    ## Solution
    
    Update `GlobalTransform` after insertion too.
    
    ---
    
    ## Changelog
    
    - `GlobalTransform` is now updated not only on `Transform` or hierarchy
    change, but also on insertion.
    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    b2492d6 View commit details
    Browse the repository at this point in the history
  2. TextPipeline::queue_text, `TextMeasureInfo::compute_size_from_secti…

    …on_texts`
    
    and `GlyphBrush::process_glyphs` each have a section of code that calculates the minimum bounds around a list of text sections.
    
    The first two functions don't apply any rounding, but  `process_glyphs` also floors all the values. It seems like this can cause conflicts where the text gets incorrectly shaped.
    
    Also when Bevy computes the text bounds it chooses the smallest possible rect that fits all the glyphs, ignoring white space. The glyphs are then realigned vertically so the first glyph is on the top line. Leading empty lines are missed off.
    
    This PR adds a function `compute_text_bounds` that replaces the duplicate code, so the text bounds are rounded the same way by each function. Also, since Bevy doen't use ab_glyph to control vertical alignment, the min y bound is just always set to 0 which ensures no leading empty lines will be will missed.
    
    There is another problem in that trailing empty lines are also ignored, but that's more difficult to deal with and much less important than the other issues.
    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    e40349d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b1ecd0e View commit details
    Browse the repository at this point in the history
  4. TextPipeline::queue_text, `TextMeasureInfo::compute_size_from_secti…

    …on_texts`
    
    and `GlyphBrush::process_glyphs` each have a section of code that calculates the minimum bounds around a list of text sections.
    
    The first two functions don't apply any rounding, but  `process_glyphs` also floors all the values. It seems like this can cause conflicts where the text gets incorrectly shaped.
    
    Also when Bevy computes the text bounds it chooses the smallest possible rect that fits all the glyphs, ignoring white space. The glyphs are then realigned vertically so the first glyph is on the top line. Leading empty lines are missed off.
    
    This PR adds a function `compute_text_bounds` that replaces the duplicate code, so the text bounds are rounded the same way by each function. Also, since Bevy doen't use ab_glyph to control vertical alignment, the min y bound is just always set to 0 which ensures no leading empty lines will be will missed.
    
    There is another problem in that trailing empty lines are also ignored, but that's more difficult to deal with and much less important than the other issues.
    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    bb4229e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6838c7d View commit details
    Browse the repository at this point in the history
  6. fmt

    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    f7cca69 View commit details
    Browse the repository at this point in the history
  7. Removed an unused import

    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    2b33ecb View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b7db366 View commit details
    Browse the repository at this point in the history
  9. removed unneeded rounding

    ickshonpe committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    dcaf0c9 View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2023

  1. Changed the visibility of bevy_ui::glyph_brush::compute_text_bounds

    … to `pub (crate)` and added some doc comments.
    ickshonpe committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    0ed18d8 View commit details
    Browse the repository at this point in the history
  2. cargo fmt

    ickshonpe committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    01f6788 View commit details
    Browse the repository at this point in the history
  3. improved comment

    ickshonpe committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    93011f5 View commit details
    Browse the repository at this point in the history