ImageSharp/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LigatureAttachTable.cs
2026-08-03 22:31:27 +02:00

45 lines
2.8 KiB
C#

// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.IO;
namespace SixLabors.Fonts.Tables.AdvancedTypographic.GPos {
/// <summary>
/// Each LigatureAttach table consists of an array (componentRecords) and count (componentCount) of the component glyphs in a ligature.
/// The array stores the ComponentRecords in the same order as the components in the ligature.
/// The order of the records also corresponds to the writing direction — that is, the logical direction — of the text.
/// For text written left to right, the first component is on the left; for text written right to left, the first component is on the right.
/// </summary>
internal class LigatureAttachTable
{
/// <summary>
/// Initializes a new instance of the <see cref="LigatureAttachTable"/> class.
/// </summary>
/// <param name="reader">The big endian binary reader.</param>
/// <param name="markClassCount">Number of defined mark classes.</param>
/// <param name="offset">Offset from beginning of LigatureAttach table.</param>
public LigatureAttachTable(BigEndianBinaryReader reader, ushort markClassCount, long offset)
{
// +-------------------+---------------------------------+--------------------------------------------------------------------------------------+
// | Type | Name | Description |
// +===================+=================================+======================================================================================+
// | uint16 | componentCount | Number of ComponentRecords in this ligature. |
// +-------------------+---------------------------------+--------------------------------------------------------------------------------------+
// | ComponentRecords | componentRecords[componentCount]| Array of Component records, ordered in writing direction. |
// +-------------------+---------------------------------+--------------------------------------------------------------------------------------+
reader.Seek(offset, SeekOrigin.Begin);
ushort componentCount = reader.ReadUInt16();
this.ComponentRecords = new ComponentRecord[componentCount];
for (int i = 0; i < componentCount; i++)
{
this.ComponentRecords[i] = new ComponentRecord(reader, markClassCount, offset);
}
}
/// <summary>
/// Gets the array of component records for this ligature, ordered in writing direction.
/// </summary>
public ComponentRecord[] ComponentRecords { get; }
}
}