Repository navigation
[Managed DWrite] Migrate FontFileEnumerator to managed #10523
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
ThomasGoulet73
wants to merge
1
commit into
dotnet:main
Choose a base branch
from
ThomasGoulet73:managed-dwrite-FontFileEnumerator
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
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
56 changes: 0 additions & 56 deletions
56
src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.cpp
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FontFileEnumerator.h
This file was deleted.
Oops, something went wrong.
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
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
78 changes: 78 additions & 0 deletions
78
...soft.DotNet.Wpf/src/PresentationCore/MS/internal/Text/TextInterface/FontFileEnumerator.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,78 @@ | ||
| // 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; | ||
| using MS.Internal.Interop.DWrite; | ||
|
|
||
| namespace MS.Internal.Text.TextInterface | ||
| { | ||
| [ClassInterface(ClassInterfaceType.None)] | ||
| [ComVisible(true)] | ||
| internal unsafe class FontFileEnumerator : IDWriteFontFileEnumeratorMirror | ||
| { | ||
| private const int S_OK = unchecked((int)0L); | ||
| private const int E_INVALIDARG = unchecked((int)0x80070057L); | ||
|
|
||
| private readonly IEnumerator<IFontSource> _fontSourceCollectionEnumerator; | ||
| private readonly FontFileLoader _fontFileLoader; | ||
| private readonly IDWriteFactory* _factory; | ||
|
|
||
| public FontFileEnumerator() | ||
| { | ||
| Debug.Fail("Assertion failed"); | ||
| } | ||
|
|
||
| public FontFileEnumerator(IEnumerable<IFontSource> fontSourceCollection, FontFileLoader fontFileLoader, IDWriteFactory* factory) | ||
| { | ||
| _fontSourceCollectionEnumerator = fontSourceCollection.GetEnumerator(); | ||
| _fontFileLoader = fontFileLoader; | ||
| factory->AddRef(); | ||
| _factory = factory; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Advances to the next font file in the collection. When it is first created, the enumerator is positioned | ||
| /// before the first element of the collection and the first call to MoveNext advances to the first file. | ||
| /// </summary> | ||
| /// <param name="hasCurrentFile">Receives the value TRUE if the enumerator advances to a file, or FALSE if | ||
| /// the enumerator advanced past the last file in the collection.</param> | ||
| /// <returns> | ||
| /// Standard HRESULT error code. | ||
| /// </returns> | ||
| [ComVisible(true)] | ||
| public int MoveNext([MarshalAs(UnmanagedType.Bool)] out bool hasCurrentFile) | ||
| { | ||
| try | ||
| { | ||
| hasCurrentFile = _fontSourceCollectionEnumerator.MoveNext(); | ||
| return S_OK; | ||
| } | ||
| catch (Exception exception) | ||
| { | ||
| hasCurrentFile = default; | ||
| return Marshal.GetHRForException(exception); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a reference to the current font file. | ||
| /// </summary> | ||
| /// <param name="fontFile">Pointer to the newly created font file object.</param> | ||
| /// <returns> | ||
| /// Standard HRESULT error code. | ||
| /// </returns> | ||
| [ComVisible(true)] | ||
| public unsafe int GetCurrentFontFile(IDWriteFontFile** fontFile) | ||
| { | ||
| if (fontFile is null) | ||
| return E_INVALIDARG; | ||
|
|
||
| return InternalFactory.CreateFontFile( | ||
| (Native.IDWriteFactory*)_factory, | ||
| _fontFileLoader, | ||
| _fontSourceCollectionEnumerator.Current.Uri, | ||
| (Native.IDWriteFontFile**)fontFile | ||
| ); | ||
| } | ||
| } | ||
| } | ||
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
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.