(mode WritingMode, orient TextOrientation, script text.Script, level int, direction text.Direction)
| 242 | } |
| 243 | |
| 244 | func scriptDirection(mode WritingMode, orient TextOrientation, script text.Script, level int, direction text.Direction) (text.Direction, text.Rotation) { |
| 245 | // override text direction for given writing mode |
| 246 | // script and level come from ScriptItemizer |
| 247 | // direction is the explicit direction set on the face |
| 248 | vertical := false |
| 249 | rotation := text.NoRotation |
| 250 | if mode == VerticalLR || mode == VerticalRL { |
| 251 | if !text.IsVerticalScript(script) && orient == Natural { |
| 252 | // horizontal script with natural orientation |
| 253 | rotation = text.CW |
| 254 | } else if rot := text.ScriptRotation(script); rot != text.NoRotation { |
| 255 | // rotated horizontal script for vertical mode (such as Mongolian) |
| 256 | rotation = rot |
| 257 | } else { |
| 258 | // horizontal script with upright orientation or vertical script |
| 259 | vertical = true |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | if !vertical { |
| 264 | if direction != text.LeftToRight && direction != text.RightToLeft { |
| 265 | if (level % 2) == 1 { |
| 266 | direction = text.RightToLeft |
| 267 | } else { |
| 268 | direction = text.LeftToRight |
| 269 | } |
| 270 | } |
| 271 | } else { |
| 272 | if direction != text.TopToBottom && direction != text.BottomToTop { |
| 273 | if (level % 2) == 1 { |
| 274 | direction = text.BottomToTop |
| 275 | } else { |
| 276 | direction = text.TopToBottom |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | return direction, rotation |
| 281 | } |
| 282 | |
| 283 | func reorderSpans(spans []TextSpan) { |
| 284 | // find runs of a certain level and deeper (including nested) |
no test coverage detected