-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Text Rendering: Add DirectWrite color glyph (COLR v0) rendering support #11684
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
Open
etvorun
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
etvorun:port/color-emoji-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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
224 changes: 193 additions & 31 deletions
224
src/Microsoft.DotNet.Wpf/src/PresentationCore/Fonts/GlobalUserInterface.CompositeFont
Large diffs are not rendered by default.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
...oft.DotNet.Wpf/src/PresentationCore/MS/internal/Interop/DWrite/DWriteColorGlyphStructs.cs
This file contains hidden or 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,47 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace MS.Internal.Interop.DWrite | ||
| { | ||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal struct DWRITE_GLYPH_OFFSET | ||
| { | ||
| public float advanceOffset; | ||
| public float ascenderOffset; | ||
| } | ||
|
|
||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal unsafe struct DWRITE_GLYPH_RUN | ||
| { | ||
| public void* fontFace; // IDWriteFontFace* | ||
| public float fontEmSize; | ||
| public uint glyphCount; | ||
| public ushort* glyphIndices; | ||
| public float* glyphAdvances; | ||
| public DWRITE_GLYPH_OFFSET* glyphOffsets; | ||
| public int isSideways; // BOOL (4 bytes) | ||
| public uint bidiLevel; | ||
| } | ||
|
|
||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal struct DWRITE_COLOR_F | ||
| { | ||
| public float r; | ||
| public float g; | ||
| public float b; | ||
| public float a; | ||
| } | ||
|
|
||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal unsafe struct DWRITE_COLOR_GLYPH_RUN | ||
| { | ||
| public DWRITE_GLYPH_RUN glyphRun; | ||
| public void* glyphRunDescription; // DWRITE_GLYPH_RUN_DESCRIPTION* (nullable) | ||
| public float baselineOriginX; | ||
| public float baselineOriginY; | ||
| public DWRITE_COLOR_F runColor; | ||
| public ushort paletteIndex; | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
...Net.Wpf/src/PresentationCore/MS/internal/Interop/DWrite/IDWriteColorGlyphRunEnumerator.cs
This file contains hidden or 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,31 @@ | ||
| ο»Ώ// Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace MS.Internal.Interop.DWrite | ||
| { | ||
| /// <summary> | ||
| /// Managed interop for IDWriteColorGlyphRunEnumerator COM interface. | ||
| /// Vtable layout: IUnknown (0-2), MoveNext (3), GetCurrentRun (4). | ||
| /// </summary> | ||
| internal unsafe struct IDWriteColorGlyphRunEnumerator | ||
| { | ||
| public void** lpVtbl; | ||
|
|
||
| public uint Release() | ||
| { | ||
| return ((delegate* unmanaged<IDWriteColorGlyphRunEnumerator*, uint>)(lpVtbl[2]))((IDWriteColorGlyphRunEnumerator*)Unsafe.AsPointer(ref this)); | ||
| } | ||
|
|
||
| public int MoveNext(int* hasRun) | ||
| { | ||
| return ((delegate* unmanaged<IDWriteColorGlyphRunEnumerator*, int*, int>)(lpVtbl[3]))((IDWriteColorGlyphRunEnumerator*)Unsafe.AsPointer(ref this), hasRun); | ||
| } | ||
|
|
||
| public int GetCurrentRun(DWRITE_COLOR_GLYPH_RUN** colorGlyphRun) | ||
| { | ||
| return ((delegate* unmanaged<IDWriteColorGlyphRunEnumerator*, DWRITE_COLOR_GLYPH_RUN**, int>)(lpVtbl[4]))((IDWriteColorGlyphRunEnumerator*)Unsafe.AsPointer(ref this), colorGlyphRun); | ||
| } | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Interop/DWrite/IDWriteFactory2.cs
This file contains hidden or 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,49 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace MS.Internal.Interop.DWrite | ||
| { | ||
| internal unsafe struct IDWriteFactory2 : IUnknown | ||
| { | ||
| public void** lpVtbl; | ||
|
|
||
| public int QueryInterface(Guid* riid, void** ppvObject) | ||
| { | ||
| return ((delegate* unmanaged<IDWriteFactory2*, Guid*, void**, int>)(lpVtbl[0]))((IDWriteFactory2*)Unsafe.AsPointer(ref this), riid, ppvObject); | ||
| } | ||
|
|
||
| public uint AddRef() | ||
| { | ||
| return ((delegate* unmanaged<IDWriteFactory2*, uint>)(lpVtbl[1]))((IDWriteFactory2*)Unsafe.AsPointer(ref this)); | ||
| } | ||
|
|
||
| public uint Release() | ||
| { | ||
| return ((delegate* unmanaged<IDWriteFactory2*, uint>)(lpVtbl[2]))((IDWriteFactory2*)Unsafe.AsPointer(ref this)); | ||
| } | ||
|
|
||
| public int TranslateColorGlyphRun( | ||
| float baselineOriginX, | ||
| float baselineOriginY, | ||
| DWRITE_GLYPH_RUN* glyphRun, | ||
| void* glyphRunDescription, | ||
| int measuringMode, | ||
| void* worldAndDpiTransform, | ||
| uint colorPaletteIndex, | ||
| IDWriteColorGlyphRunEnumerator** colorLayers) | ||
| { | ||
| return ((delegate* unmanaged<IDWriteFactory2*, float, float, DWRITE_GLYPH_RUN*, void*, int, void*, uint, IDWriteColorGlyphRunEnumerator**, int>)(lpVtbl[28]))( | ||
| (IDWriteFactory2*)Unsafe.AsPointer(ref this), | ||
| baselineOriginX, | ||
| baselineOriginY, | ||
| glyphRun, | ||
| glyphRunDescription, | ||
| measuringMode, | ||
| worldAndDpiTransform, | ||
| colorPaletteIndex, | ||
| colorLayers); | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
...crosoft.DotNet.Wpf/src/PresentationCore/MS/internal/Text/TextInterface/ColorGlyphLayer.cs
This file contains hidden or 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,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace MS.Internal.Text.TextInterface | ||
| { | ||
| /// <summary> | ||
| /// Represents a single color layer from a COLR v0 color glyph run decomposition. | ||
| /// </summary> | ||
| internal struct ColorGlyphLayer | ||
| { | ||
| public ushort[] GlyphIndices; | ||
| public float[] GlyphAdvances; | ||
| public float[] GlyphOffsets; // Interleaved (advanceOffset, ascenderOffset) pairs; may be null. | ||
| public float BaselineOriginX; | ||
| public float BaselineOriginY; | ||
| public float ColorR; | ||
| public float ColorG; | ||
| public float ColorB; | ||
| public float ColorA; | ||
| public bool UseForegroundColor; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.