public TextServiceDirectWrite()
        {
            try
            {
                interop = new TextServiceDirectWriteInterop();
            }
            catch (Exception exception)
            {
                // dll load issue
                Debugger.Break();
                MessageBox.Show("Failed to load DirectWrite interop dll: " + exception.ToString());
            }

            #if true
            uniscribeService = new TextServiceUniscribe();
            #else // TODO: support Windows.Data.Text for universal script segmentation support
            #endif
        }
        private static TextServiceDirectWriteInterop EnsureInterop(Font font)
        {
            if (interops == null)
            {
                interops = new List<KeyValuePair<Font, TextServiceDirectWriteInterop>>(MaxCachedInterops);
            }

            if (lastWidth != Screen.PrimaryScreen.Bounds.Width)
            {
                ClearCache();
            }
            lastWidth = Screen.PrimaryScreen.Bounds.Width;

            int index = -1;
            for (int i = 0; i < interops.Count; i++)
            {
                if (font.Equals(interops[i].Key))
                {
                    index = i;
                }
            }
            if (index < 0)
            {
                if (interops.Count >= MaxCachedInterops)
                {
                    ClearCache();
                }
                index = interops.Count;
                TextServiceDirectWriteInterop interop = new TextServiceDirectWriteInterop();
                interop.Reset(TextServiceDirectWrite.InteropGlobals, font, lastWidth);
                interops.Add(new KeyValuePair<Font, TextServiceDirectWriteInterop>(font, interop));
            #if DEBUG
                Debugger.Log(
                    1,
                    "TextServiceDirectWrite",
                    String.Concat(
                        DateTime.Now.ToString(),
                        ": Added DirectWrite interop for ",
                        font.ToString(),
                        " ",
                        font.Style.ToString(),
                        Environment.NewLine));
            #endif
            }
            return interops[index].Value;
        }