mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 12:23:39 +01:00
merge net5
This commit is contained in:
commit
c1dac8d27a
34 changed files with 420 additions and 386 deletions
|
|
@ -161,6 +161,7 @@ namespace Dalamud.Interface
|
|||
return;
|
||||
|
||||
var scale = target.Value!.FontSize / source.Value!.FontSize;
|
||||
var addedCodepoints = new HashSet<int>();
|
||||
unsafe
|
||||
{
|
||||
var glyphs = (ImFontGlyphReal*)source.Value!.Glyphs.Data;
|
||||
|
|
@ -175,9 +176,11 @@ namespace Dalamud.Interface
|
|||
var prevGlyphPtr = (ImFontGlyphReal*)target.Value!.FindGlyphNoFallback((ushort)glyph->Codepoint).NativePtr;
|
||||
if ((IntPtr)prevGlyphPtr == IntPtr.Zero)
|
||||
{
|
||||
addedCodepoints.Add(glyph->Codepoint);
|
||||
target.Value!.AddGlyph(
|
||||
target.Value!.ConfigData,
|
||||
(ushort)glyph->Codepoint,
|
||||
glyph->TextureIndex,
|
||||
glyph->X0 * scale,
|
||||
((glyph->Y0 - source.Value!.Ascent) * scale) + target.Value!.Ascent,
|
||||
glyph->X1 * scale,
|
||||
|
|
@ -190,6 +193,8 @@ namespace Dalamud.Interface
|
|||
}
|
||||
else if (!missingOnly)
|
||||
{
|
||||
addedCodepoints.Add(glyph->Codepoint);
|
||||
prevGlyphPtr->TextureIndex = glyph->TextureIndex;
|
||||
prevGlyphPtr->X0 = glyph->X0 * scale;
|
||||
prevGlyphPtr->Y0 = ((glyph->Y0 - source.Value!.Ascent) * scale) + target.Value!.Ascent;
|
||||
prevGlyphPtr->X1 = glyph->X1 * scale;
|
||||
|
|
@ -201,6 +206,16 @@ namespace Dalamud.Interface
|
|||
prevGlyphPtr->AdvanceX = glyph->AdvanceX * scale;
|
||||
}
|
||||
}
|
||||
|
||||
var kernPairs = source.Value!.KerningPairs;
|
||||
for (int j = 0, k = kernPairs.Size; j < k; j++)
|
||||
{
|
||||
if (!addedCodepoints.Contains(kernPairs[j].Left))
|
||||
continue;
|
||||
if (!addedCodepoints.Contains(kernPairs[j].Right))
|
||||
continue;
|
||||
target.Value.AddKerningPair(kernPairs[j].Left, kernPairs[j].Right, kernPairs[j].AdvanceXAdjustment);
|
||||
}
|
||||
}
|
||||
|
||||
if (rebuildLookupTable)
|
||||
|
|
@ -221,7 +236,7 @@ namespace Dalamud.Interface
|
|||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "ImGui internals")]
|
||||
public struct ImFontGlyphReal
|
||||
{
|
||||
public uint ColoredVisibleCodepoint;
|
||||
public uint ColoredVisibleTextureIndexCodepoint;
|
||||
public float AdvanceX;
|
||||
public float X0;
|
||||
public float Y0;
|
||||
|
|
@ -232,23 +247,110 @@ namespace Dalamud.Interface
|
|||
public float U1;
|
||||
public float V1;
|
||||
|
||||
private const uint ColoredMask /*****/ = 0b_00000000_00000000_00000000_00000001u;
|
||||
private const uint VisibleMask /*****/ = 0b_00000000_00000000_00000000_00000010u;
|
||||
private const uint TextureMask /*****/ = 0b_00000000_00000000_00000111_11111100u;
|
||||
private const uint CodepointMask /***/ = 0b_11111111_11111111_11111000_00000000u;
|
||||
|
||||
private const int ColoredShift = 0;
|
||||
private const int VisibleShift = 1;
|
||||
private const int TextureShift = 2;
|
||||
private const int CodepointShift = 11;
|
||||
|
||||
public bool Colored
|
||||
{
|
||||
get => ((this.ColoredVisibleCodepoint >> 0) & 1) != 0;
|
||||
set => this.ColoredVisibleCodepoint = (this.ColoredVisibleCodepoint & 0xFFFFFFFEu) | (value ? 1u : 0u);
|
||||
get => (int)((this.ColoredVisibleTextureIndexCodepoint & ColoredMask) >> ColoredShift) != 0;
|
||||
set => this.ColoredVisibleTextureIndexCodepoint = (this.ColoredVisibleTextureIndexCodepoint & ~ColoredMask) | (value ? 1u << ColoredShift : 0u);
|
||||
}
|
||||
|
||||
public bool Visible
|
||||
{
|
||||
get => ((this.ColoredVisibleCodepoint >> 1) & 1) != 0;
|
||||
set => this.ColoredVisibleCodepoint = (this.ColoredVisibleCodepoint & 0xFFFFFFFDu) | (value ? 2u : 0u);
|
||||
get => (int)((this.ColoredVisibleTextureIndexCodepoint & VisibleMask) >> VisibleShift) != 0;
|
||||
set => this.ColoredVisibleTextureIndexCodepoint = (this.ColoredVisibleTextureIndexCodepoint & ~VisibleMask) | (value ? 1u << VisibleShift : 0u);
|
||||
}
|
||||
|
||||
public int TextureIndex
|
||||
{
|
||||
get => (int)(this.ColoredVisibleTextureIndexCodepoint & TextureMask) >> TextureShift;
|
||||
set => this.ColoredVisibleTextureIndexCodepoint = (this.ColoredVisibleTextureIndexCodepoint & ~TextureMask) | ((uint)value << TextureShift);
|
||||
}
|
||||
|
||||
public int Codepoint
|
||||
{
|
||||
get => (int)(this.ColoredVisibleCodepoint >> 2);
|
||||
set => this.ColoredVisibleCodepoint = (this.ColoredVisibleCodepoint & 3u) | ((uint)value << 2);
|
||||
get => (int)(this.ColoredVisibleTextureIndexCodepoint & CodepointMask) >> CodepointShift;
|
||||
set => this.ColoredVisibleTextureIndexCodepoint = (this.ColoredVisibleTextureIndexCodepoint & ~CodepointMask) | ((uint)value << CodepointShift);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ImFontGlyphHotData the correct version.
|
||||
/// </summary>
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "ImGui internals")]
|
||||
public struct ImFontGlyphHotDataReal
|
||||
{
|
||||
public float AdvanceX;
|
||||
public float OccupiedWidth;
|
||||
public uint KerningPairInfo;
|
||||
|
||||
private const uint UseBisectMask /***/ = 0b_00000000_00000000_00000000_00000001u;
|
||||
private const uint OffsetMask /******/ = 0b_00000000_00001111_11111111_11111110u;
|
||||
private const uint CountMask /*******/ = 0b_11111111_11110000_00000111_11111100u;
|
||||
|
||||
private const int UseBisectShift = 0;
|
||||
private const int OffsetShift = 1;
|
||||
private const int CountShift = 20;
|
||||
|
||||
public bool UseBisect
|
||||
{
|
||||
get => (int)((this.KerningPairInfo & UseBisectMask) >> UseBisectShift) != 0;
|
||||
set => this.KerningPairInfo = (this.KerningPairInfo & ~UseBisectMask) | (value ? 1u << UseBisectShift : 0u);
|
||||
}
|
||||
|
||||
public bool Offset
|
||||
{
|
||||
get => (int)((this.KerningPairInfo & OffsetMask) >> OffsetShift) != 0;
|
||||
set => this.KerningPairInfo = (this.KerningPairInfo & ~OffsetMask) | (value ? 1u << OffsetShift : 0u);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get => (int)(this.KerningPairInfo & CountMask) >> CountShift;
|
||||
set => this.KerningPairInfo = (this.KerningPairInfo & ~CountMask) | ((uint)value << CountShift);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ImFontAtlasCustomRect the correct version.
|
||||
/// </summary>
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "ImGui internals")]
|
||||
public unsafe struct ImFontAtlasCustomRectReal
|
||||
{
|
||||
public ushort Width;
|
||||
public ushort Height;
|
||||
public ushort X;
|
||||
public ushort Y;
|
||||
public uint TextureIndexAndGlyphID;
|
||||
public float GlyphAdvanceX;
|
||||
public Vector2 GlyphOffset;
|
||||
public ImFont* Font;
|
||||
|
||||
private const uint TextureIndexMask /***/ = 0b_00000000_00000000_00000111_11111100u;
|
||||
private const uint GlyphIDMask /********/ = 0b_11111111_11111111_11111000_00000000u;
|
||||
|
||||
private const int TextureIndexShift = 2;
|
||||
private const int GlyphIDShift = 11;
|
||||
|
||||
public int TextureIndex
|
||||
{
|
||||
get => (int)(this.TextureIndexAndGlyphID & TextureIndexMask) >> TextureIndexShift;
|
||||
set => this.TextureIndexAndGlyphID = (this.TextureIndexAndGlyphID & ~TextureIndexMask) | ((uint)value << TextureIndexShift);
|
||||
}
|
||||
|
||||
public int GlyphID
|
||||
{
|
||||
get => (int)(this.TextureIndexAndGlyphID & GlyphIDMask) >> GlyphIDShift;
|
||||
set => this.TextureIndexAndGlyphID = (this.TextureIndexAndGlyphID & ~GlyphIDMask) | ((uint)value << GlyphIDShift);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue