Skip to content

AtlasEngine: Implement ClearType blending - #12242

Merged
4 commits merged into
mainfrom
dev/lhecker/atlas-engine-cleartype
Jan 27, 2022
Merged

4 commits merged into
mainfrom
dev/lhecker/atlas-engine-cleartype

Conversation

@lhecker

@lhecker Leonard Hecker (lhecker) commented Jan 24, 2022 •

Copy link
Copy Markdown
Member

This commit extracts DirectWrite related shader code into dwrite.hlsl
and adds support for ClearType blending.

Additionally the following changes are piggybacked into this commit:

  • Some incorrect code around fallback glyph sizing was removed as
    this is already accomplished by CreateTextLayout internally
  • Hot-reload failed to work with dwrite.hlsl as the pFileName
    parameter was missing
  • Legibility of the dotted underline was improved by increasing
    the line gap from 1:1 to 3:1

Part of #9999.

PR Checklist

  • I work here
  • Tests added/passed

Validation Steps Performed

  • Types are clear ✅

@lhecker Leonard Hecker (lhecker) added Issue-Task It's a feature request, but it doesn't really need a major design. Area-AtlasEngine labels Jan 24, 2022
@lhecker
Leonard Hecker (lhecker) force-pushed the dev/lhecker/atlas-engine-cleartype branch from f4e32c9 to ce0f6c6 Compare January 26, 2022 00:12
@lhecker
Leonard Hecker (lhecker) force-pushed the dev/lhecker/atlas-engine-cleartype branch from ce0f6c6 to 27dc7e3 Compare January 26, 2022 19:19
@DHowett

Copy link
Copy Markdown
Member

looks good, with a dash of "well, why not?"

@miniksa Michael Niksa (miniksa) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very excited for this!

/* pSrcData */ dataBeg.get(),
/* SrcDataSize */ fileSize,
/* pFileName */ nullptr,
const auto hr = D3DCompileFromFile(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that seems obvious in hindsight.

Comment on lines +98 to +104
// The history of these fonts is interesting. The glyph outlines were originally created by digitizing the typeballs of
// IBM Selectric typewriters. Digitizing the metal typeballs yielded very precise outlines. However, the strokes are
// consistently too thin in comparison with the corresponding typewritten characters because the thickness of the
// typewriter ribbon was not accounted for. This didn't matter in the earliest versions of Windows because the screen
// resolution was not that high and you could not have a stroke thinner than one pixel. However, with the introduction
// of anti-aliasing the thin strokes manifested in text that was too light. By this time, it was too late to change
// the fonts so instead a special case was added to render these fonts differently.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fascinating!

for (const auto familyName : thinFontFamilyNames)
{
n = wcscmp(canonicalFamilyName, familyName);
if (n <= 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trickery of the negative here isn't immediately comprehensible to me. Explain (in a comment)?

@lhecker Leonard Hecker (lhecker) Jan 27, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wcscmp, just like other cmp functions (memcmp), returns -1 if the first argument has a character of smaller numeric value than the second argument. wcscmp(L"foo", L"foz") returns -1.
Due to this reason, this loop acts like a call to std::lower_bound, but with linear search, because binary search is kinda overkill for just a few values (log2(x) is close to linear for small x, resulting in 2.6 comparisons with binary search and 3 comparisons with linear search on average here).

I can comment it, but I think a long comment would be boring, since the loop cannot be meaningfully improved, unless it's entirely rewritten from scratch (and I can't think of a short comment either atm 🤔).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right... I added a comment explaining the "why" instead of the "how". That seems the most helpful to me. 🙂

</ItemGroup>
<ItemGroup>
<FxCompile Include="dwrite.hlsl">
<ExcludedFromBuild>true</ExcludedFromBuild>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why excluded? You don't want it precompiled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it's #included from the shader.hlsl file already.

@lhecker Leonard Hecker (lhecker) added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 27, 2022
@ghost

Copy link
Copy Markdown

Hello Leonard Hecker (@lhecker)!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit 4ccfe0b into main Jan 27, 2022
@ghost
ghost deleted the dev/lhecker/atlas-engine-cleartype branch January 27, 2022 19:27
@zadjii-msft

Copy link
Copy Markdown
Member

Did we just re-break cleartype with a BG? I just merged main in and suddenly:

image

    "profiles": 
    {
        "defaults": 
        {
            "adjustIndistinguishableColors": false,
            "antialiasingMode": "cleartype",
            "closeOnExit": "graceful",
            "colorScheme": "Solarized Light",
            "experimental.useAtlasEngine": true,
                "icon": "d:\\dev\\private\\OpenConsole\\res\\terminal.ico",
            "useAcrylic": true,
            "bellSound": [
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk1.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk2.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk3.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk4.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk-muffled1.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk-muffled2.mp3",
                "C:\\Users\\migrie\\Downloads\\memes\\honks\\Honk-muffled3.mp3"
            ]
        },

...

            {
                "background": "#416E49",
                "backgroundImage": "C:\\Users\\migrie\\Downloads\\memes\\goose.gif",
                "backgroundImageAlignment": "bottomRight",
                "backgroundImageStretchMode": "none",
                "colorScheme": "One Half Dark",
                "commandline": "wsl.exe",
                "font": 
                {
                    "size": 14
                },
                "bellSound": null,
                "guid": "{c756bf8b-2671-54d8-a600-b310c233456b}",
                "hidden": false,
                "name": "HONK",
                "useAcrylic": false
        },

sorry quick notes before I log off.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AtlasEngine AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants