-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Managed DWrite] Migrate part of DWriteTypeConverter to managed #9902
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
3
commits into
dotnet:main
Choose a base branch
from
ThomasGoulet73:managed-dwrite-DWriteTypeConverter
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
3 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
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
21 changes: 0 additions & 21 deletions
21
src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/CPP/DWriteWrapper/FactoryType.h
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...crosoft.DotNet.Wpf/src/PresentationCore/MS/internal/Interop/DWrite/DWRITE_FACTORY_TYPE.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,29 @@ | ||
// 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.Interop.DWrite | ||
{ | ||
/// <summary> | ||
/// Specifies the type of DirectWrite factory object. | ||
/// DirectWrite factory contains internal state such as font loader registration and cached font data. | ||
/// In most cases it is recommended to use the shared factory object, because it allows multiple components | ||
/// that use DirectWrite to share internal DirectWrite state and reduce memory usage. | ||
/// However, there are cases when it is desirable to reduce the impact of a component, | ||
/// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it | ||
/// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed | ||
/// component. | ||
/// </summary> | ||
internal enum DWRITE_FACTORY_TYPE | ||
{ | ||
/// <summary> | ||
/// Shared factory allow for re-use of cached font data across multiple in process components. | ||
/// Such factories also take advantage of cross process font caching components for better performance. | ||
/// </summary> | ||
DWRITE_FACTORY_TYPE_SHARED, | ||
|
||
/// <summary> | ||
/// Objects created from the isolated factory do not interact with internal DirectWrite state from other components. | ||
/// </summary> | ||
DWRITE_FACTORY_TYPE_ISOLATED | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...osoft.DotNet.Wpf/src/PresentationCore/MS/internal/Interop/DWrite/DWRITE_MEASURING_MODE.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,27 @@ | ||
// 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.Interop.DWrite | ||
{ | ||
/// <summary> | ||
/// The measuring method used for text layout. | ||
/// </summary> | ||
internal enum DWRITE_MEASURING_MODE | ||
{ | ||
/// <summary> | ||
/// Text is measured using glyph ideal metrics whose values are independent to the current display resolution. | ||
/// </summary> | ||
DWRITE_MEASURING_MODE_NATURAL, | ||
|
||
/// <summary> | ||
/// Text is measured using glyph display compatible metrics whose values tuned for the current display resolution. | ||
/// </summary> | ||
DWRITE_MEASURING_MODE_GDI_CLASSIC, | ||
|
||
/// <summary> | ||
// Text is measured using the same glyph display metrics as text measured by GDI using a font | ||
// created with CLEARTYPE_NATURAL_QUALITY. | ||
/// </summary> | ||
DWRITE_MEASURING_MODE_GDI_NATURAL | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...t.DotNet.Wpf/src/PresentationCore/MS/internal/Text/TextInterface/DWriteTypeConverterEx.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,59 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Windows.Media; | ||
using MS.Internal.Interop.DWrite; | ||
|
||
namespace MS.Internal.Text.TextInterface | ||
{ | ||
/// <summary> | ||
/// This class is used to convert data types back and forth between DWrite and DWriteWrapper. | ||
/// </summary> | ||
internal static class DWriteTypeConverterEx | ||
{ | ||
internal static DWRITE_FACTORY_TYPE Convert(FactoryType factoryType) | ||
{ | ||
switch (factoryType) | ||
{ | ||
case FactoryType.Shared: | ||
return DWRITE_FACTORY_TYPE.DWRITE_FACTORY_TYPE_SHARED; | ||
case FactoryType.Isolated: | ||
return DWRITE_FACTORY_TYPE.DWRITE_FACTORY_TYPE_ISOLATED; | ||
default: | ||
throw new InvalidOperationException(); | ||
} | ||
} | ||
|
||
internal static DWRITE_MEASURING_MODE Convert(TextFormattingMode measuringMode) | ||
{ | ||
switch (measuringMode) | ||
{ | ||
case TextFormattingMode.Ideal: | ||
return DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL; | ||
case TextFormattingMode.Display: | ||
return DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_GDI_CLASSIC; | ||
// We do not support Natural Metrics mode in WPF | ||
default: | ||
throw new InvalidOperationException(); | ||
} | ||
} | ||
|
||
internal static TextFormattingMode Convert(DWRITE_MEASURING_MODE dwriteMeasuringMode) | ||
{ | ||
switch (dwriteMeasuringMode) | ||
{ | ||
case DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL: | ||
return TextFormattingMode.Ideal; | ||
case DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_GDI_CLASSIC: | ||
return TextFormattingMode.Display; | ||
// We do not support Natural Metrics mode in WPF | ||
// However, the build system complained about not having an explicit case | ||
// for DWRITE_TEXT_MEASURING_METHOD_USE_DISPLAY_NATURAL_METRICS | ||
case DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_GDI_NATURAL: | ||
default: | ||
throw new InvalidOperationException(); | ||
} | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Text/TextInterface/FactoryType.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,14 @@ | ||
// 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> | ||
/// The type of the Factory. | ||
/// </summary> | ||
internal enum FactoryType | ||
{ | ||
Shared, | ||
Isolated | ||
} | ||
} |
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
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.