-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Text] Glyph Outline Part 5/13 - Shaped buffer glyph indices #21501
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
Open
Gillibald
wants to merge
10
commits into
AvaloniaUI:main
from
Gillibald:pr2d/shaped-buffer-glyph-indices
+903
−44
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7d8fa81
Fix glyph metrics; expose glyph bounding box
Gillibald f7d0c9c
Add glyph-bounds benchmark
Gillibald 96c282b
Add allocation-free batch glyph-bounds path
Gillibald f9026d6
Restore System.Buffers.Binary using in GlyfTable
Gillibald b56c81b
Clamp glyph bounding-box extents to non-negative
Gillibald 76af266
Allocate batch glyph-metric buffers only when their source is present
Gillibald 84ed811
Note the halved loca offsets in the batch bounds reader
Gillibald 3e19d6a
Split the batch metrics loop on the glyf branch instead of per glyph
Gillibald 87226fb
Add vertical glyph advance API to GlyphTypeface
Gillibald 129a672
Expose contiguous glyph indices span on ShapedBuffer
Gillibald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using System; | ||
|
|
||
| namespace Avalonia.Media | ||
| { | ||
| /// <summary> | ||
| /// A glyph's control-point bounding box in font design units, as stored in the | ||
| /// <c>glyf</c> header. Used by the batch bounds path | ||
| /// (<see cref="GlyphTypeface.TryGetGlyphBounds"/>) where only the ink extent is | ||
| /// needed and advances are already known by the caller. | ||
| /// </summary> | ||
| internal readonly record struct GlyphBounds(short XMin, short YMin, short XMax, short YMax) | ||
| { | ||
| /// <summary> | ||
| /// Width of the bounding box (<see cref="XMax"/> − <see cref="XMin"/>), clamped to a | ||
| /// non-negative value. A malformed header with <see cref="XMax"/> < <see cref="XMin"/> | ||
| /// yields <c>0</c> rather than wrapping when narrowed to an unsigned extent. The maximum | ||
| /// possible extent for <see cref="short"/> coordinates is 65535, so the result always | ||
| /// fits in a <see cref="ushort"/>. | ||
| /// </summary> | ||
| public int Width => Math.Max(0, XMax - XMin); | ||
|
|
||
| /// <summary> | ||
| /// Height of the bounding box (<see cref="YMax"/> − <see cref="YMin"/>), clamped to a | ||
| /// non-negative value. A malformed header with <see cref="YMax"/> < <see cref="YMin"/> | ||
| /// yields <c>0</c> rather than wrapping when narrowed to an unsigned extent. | ||
| /// </summary> | ||
| public int Height => Math.Max(0, YMax - YMin); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,54 @@ | ||
| namespace Avalonia.Media; | ||
| namespace Avalonia.Media; | ||
|
|
||
| public readonly record struct GlyphMetrics | ||
| { | ||
| /// <summary> | ||
| /// Distance from the x-origin to the left extremum of the glyph. | ||
| /// Distance from the x-origin to the leftmost outline point. | ||
| /// </summary> | ||
| public int XBearing { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Distance from the top extremum of the glyph to the y-origin. | ||
| /// Distance from the topmost outline point to the y-origin. | ||
| /// </summary> | ||
| public int YBearing { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Distance from the left extremum of the glyph to the right extremum. | ||
| /// Width of the glyph's outline bounding box. | ||
| /// </summary> | ||
| public ushort Width { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Distance from the top extremum of the glyph to the bottom extremum. | ||
| /// Height of the glyph's outline bounding box. | ||
| /// </summary> | ||
| public ushort Height { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Horizontal advance width (distance to the next glyph's origin). | ||
| /// </summary> | ||
| public ushort AdvanceWidth { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Vertical advance height (distance to the next glyph's origin in vertical layout). | ||
| /// </summary> | ||
| public ushort AdvanceHeight { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Horizontal offset from the glyph's origin to the leftmost outline point (used for bitmap glyphs). | ||
| /// </summary> | ||
| public ushort XOffset { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Vertical offset from the glyph's origin to the topmost outline point (used for bitmap glyphs). | ||
| /// </summary> | ||
| public ushort YOffset { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// X coordinate of the vertical origin (used for vertical layout). | ||
| /// </summary> | ||
| public ushort VerticalOriginX { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Y coordinate of the vertical origin (used for vertical layout). | ||
| /// </summary> | ||
| public ushort VerticalOriginY { get; init; } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.