-
Notifications
You must be signed in to change notification settings - Fork 11
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
Better support for vertical text #124
Merged
+1,131
−249
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
22adb71
[unicodedata] add vertical orientation
benoitkugler e439bd9
Merge branch 'main' into vertical-scripts
benoitkugler 78a27fe
expose vertical script data for more efficient query
benoitkugler d06c8e8
Merge branch 'vertical-bounds' into vertical-scripts
benoitkugler 2f88fba
[shaping] initial support for vertical glyph rotation
benoitkugler 93d0246
[shaping] rename file for consistency with wrapping.go
benoitkugler 12a97d9
[shaping] fix vertical bounds, properly taking into account negative …
benoitkugler cdf3a0c
add sideways helper for outlines
benoitkugler 0361ff7
[shaping] add sideways mode to the shaper
benoitkugler a8f0dee
[shaping] add sample for RTL vertical text
benoitkugler cb04a76
[shaping] add vertical orientation to the input segmenter
benoitkugler 8b5e415
Merge branch 'main' into vertical-scripts
benoitkugler 9796152
[shaping] organize test rasterizer and add vertical script examples
benoitkugler ebfecdf
[shaping] more idiomatic samples in test
benoitkugler fea6bbb
[harfbuzz] properly scale glyph X and Y offsets
benoitkugler 570b07b
Merge branch 'fix-offset-scaling' into vertical-scripts
benoitkugler b81c4ad
properly apply YOffset
benoitkugler 0e869e6
fix rotation; add converter helpers
benoitkugler 291c26f
fix dot position
benoitkugler 582c627
[shaping] adjust baseline for vertical sideways text
benoitkugler d4aaea9
fix doc typo
benoitkugler 03cc2f6
[shaping] fix image dims computation in visual tests
benoitkugler efc3936
Cleanup names and documentation
benoitkugler 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 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 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,65 @@ | ||
package di | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/go-text/typesetting/harfbuzz" | ||
tu "github.com/go-text/typesetting/opentype/testutils" | ||
) | ||
|
||
func TestDirection(t *testing.T) { | ||
tu.Assert(t, DirectionLTR.Axis() == Horizontal) | ||
tu.Assert(t, DirectionRTL.Axis() == Horizontal) | ||
tu.Assert(t, DirectionTTB.Axis() == Vertical) | ||
tu.Assert(t, DirectionBTT.Axis() == Vertical) | ||
tu.Assert(t, !DirectionLTR.IsVertical()) | ||
tu.Assert(t, !DirectionRTL.IsVertical()) | ||
tu.Assert(t, DirectionTTB.IsVertical()) | ||
tu.Assert(t, DirectionBTT.IsVertical()) | ||
|
||
tu.Assert(t, DirectionLTR.Progression() == FromTopLeft) | ||
tu.Assert(t, DirectionRTL.Progression() == TowardTopLeft) | ||
tu.Assert(t, DirectionTTB.Progression() == FromTopLeft) | ||
tu.Assert(t, DirectionBTT.Progression() == TowardTopLeft) | ||
|
||
tu.Assert(t, !DirectionTTB.IsSideways()) | ||
tu.Assert(t, !DirectionBTT.IsSideways()) | ||
|
||
tu.Assert(t, DirectionLTR.SwitchAxis() == DirectionTTB) | ||
tu.Assert(t, DirectionRTL.SwitchAxis() == DirectionBTT) | ||
tu.Assert(t, DirectionTTB.SwitchAxis() == DirectionLTR) | ||
tu.Assert(t, DirectionBTT.SwitchAxis() == DirectionRTL) | ||
|
||
tu.Assert(t, DirectionLTR.Harfbuzz() == harfbuzz.LeftToRight) | ||
tu.Assert(t, DirectionRTL.Harfbuzz() == harfbuzz.RightToLeft) | ||
tu.Assert(t, DirectionTTB.Harfbuzz() == harfbuzz.TopToBottom) | ||
tu.Assert(t, DirectionBTT.Harfbuzz() == harfbuzz.BottomToTop) | ||
|
||
tu.Assert(t, !DirectionLTR.HasVerticalOrientation()) | ||
tu.Assert(t, !DirectionRTL.HasVerticalOrientation()) | ||
tu.Assert(t, !DirectionTTB.HasVerticalOrientation()) | ||
tu.Assert(t, !DirectionBTT.HasVerticalOrientation()) | ||
|
||
for _, test := range []struct { | ||
sideways bool | ||
progression Progression | ||
hb harfbuzz.Direction | ||
}{ | ||
{true, FromTopLeft, harfbuzz.TopToBottom}, | ||
{true, TowardTopLeft, harfbuzz.BottomToTop}, | ||
{false, FromTopLeft, harfbuzz.TopToBottom}, | ||
{false, TowardTopLeft, harfbuzz.BottomToTop}, | ||
} { | ||
d := axisVertical | ||
d.SetProgression(test.progression) | ||
|
||
tu.Assert(t, !d.HasVerticalOrientation()) | ||
d.SetSideways(test.sideways) | ||
|
||
tu.Assert(t, d.HasVerticalOrientation()) | ||
tu.Assert(t, d.IsSideways() == test.sideways) | ||
tu.Assert(t, d.Axis() == Vertical) | ||
tu.Assert(t, d.Progression() == test.progression) | ||
tu.Assert(t, d.Harfbuzz() == test.hb) | ||
} | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwitchAxis probably ;) The linter should have caught this, perhaps our CI needs a few improvements.
Possibly "switches" not "switch" as well if this line is being updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thank you.