// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Runtime.CompilerServices; namespace SixLabors.Fonts.Unicode { /// /// Represents the Unicode Bidi value of a given . /// /// public readonly struct BidiClass { private readonly uint bidiValue; /// /// Initializes a new instance of the struct. /// /// The codepoint. public BidiClass(CodePoint codePoint) => this.bidiValue = UnicodeData.GetBidiData((uint)codePoint.Value); /// /// Gets the Unicode Bidirectional character type. /// public BidiCharacterType CharacterType => (BidiCharacterType)(this.bidiValue >> 24); /// /// Gets the Unicode Bidirectional paired bracket type. /// public BidiPairedBracketType PairedBracketType => (BidiPairedBracketType)((this.bidiValue >> 16) & 0xFF); /// /// Gets the codepoint representing the bracket pairing for this instance. /// /// /// When this method returns, contains the codepoint representing the bracket pairing for this instance; /// otherwise, the default value for the type of the parameter. /// This parameter is passed uninitialized. /// . /// if this instance has a bracket pairing; otherwise, [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryGetPairedBracket(out CodePoint codePoint) { if (this.PairedBracketType == BidiPairedBracketType.None) { codePoint = default; return false; } codePoint = new CodePoint(this.bidiValue & 0xFFFF); return true; } } }