microsoft / cascadia-code

This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal.
Other
25.11k stars 796 forks source link

UnauthorizedAccessException accessing font programmatically #691

Open stinos opened 1 year ago

stinos commented 1 year ago

Cascadia family version

2111.001

Cascadia family variant(s)

Cascadia Code (the version with ligatures)

Font file format(s)

Windows Terminal included version (TTF (variable)), .ttf (variable)

Platform

Windows 10

Other Software

No response

What happened?

I'm assuming VSCode or Windows Terminal installed the Cascadia fonts (I have Code and Mono). Recently, running the latest release of https://github.com/lucasg/Dependencies resulted in an unhandled exception. Likewise, going to Start->Font Settings and clicking on the Cascadia Mono font results in an unhandled exception in SystemSettings.exe. I uninstalled all Cascadia fonts, downloaded the ttf and installed them again 'For all users' but the issue remains. In the Dependencies code it can be seen that the exception occurs when calling GetTypefaces on the FontFamily instance for Cascadia Code.

Code to reproduce:

            foreach (var family in System.Windows.Media.Fonts.SystemFontFamilies)
            {
                foreach (var typeface in family.GetTypefaces())
                {
                }
            }

Exception message is "UnauthorizedAccessException: Attempted to perform an unauthorized operation."

Call stack:

   at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
   at MS.Internal.Text.TextInterface.FontList.get_Item(UInt32 A_0)
   at MS.Internal.FontFace.TypefaceCollection.Enumerator.get_Current()
rampaa commented 5 months ago

Having the same problem here, any news on this?