Script.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / MS / Internal / Shaping / Script.cs / 2 / Script.cs

                            //+------------------------------------------------------------------------ 
//
//  Microsoft Windows Client Platform
//  Copyright (C) Microsoft Corporation
// 
//  File:      Script.cs
// 
//  Contents:  Script identifier 
//
//  Created:   3-21-2005 [....] ([....]) 
//
//-----------------------------------------------------------------------

 
using System;
using System.Collections; 
 

namespace MS.Internal.Shaping 
{
    /// 
    /// Script identifier that maps to OpenType script tags
    ///  
    internal static class Script
    { 
        static Script() 
        {
            // Hash the the reverse lookup for script id 
            for(int i = 0; i < (int)ScriptID.Max; i++)
            {
                _idHash.Add(_tags[i], (ScriptID)i);
            } 
        }
 
        static internal ScriptTags[] AllTags 
        {
            get { return _tags; } 
        }

        static internal ScriptID ToID(ScriptTags scriptTag)
        { 
            object script = _idHash[scriptTag];
            if(script != null) 
            { 
                return (ScriptID)script;
            } 
            return ScriptID.Default;
        }

        static internal ScriptTags ToTag(ScriptID script) 
        {
            return _tags[(int)script]; 
        } 

        static private Hashtable _idHash = new Hashtable((int)ScriptID.Max); 
        static private readonly ScriptTags[] _tags = new ScriptTags[]
        {
            ScriptTags.Default,                                // 'dflt'
            ScriptTags.Arabic,                                 // 'arab' 
            ScriptTags.Armenian,                               // 'armn'
            ScriptTags.Bengali,                                // 'beng' 
            ScriptTags.Bopomofo,                               // 'bopo' 
            ScriptTags.Braille,                                // 'brai'
            ScriptTags.Buginese,                               // 'bugi' 
            ScriptTags.Buhid,                                  // 'buhd'
            ScriptTags.CanadianSyllabics,                      // 'cans'
            ScriptTags.Cherokee,                               // 'cher'
            ScriptTags.CJKIdeographic,                         // 'hani' 
            ScriptTags.Coptic,                                 // 'copt'
            ScriptTags.CypriotSyllabary,                       // 'cprt' 
            ScriptTags.Cyrillic,                               // 'cyrl' 
            ScriptTags.Deseret,                                // 'dsrt'
            ScriptTags.Devanagari,                             // 'deva' 
            ScriptTags.Ethiopic,                               // 'ethi'
            ScriptTags.Georgian,                               // 'geor'
            ScriptTags.Glagolitic,                             // 'glag'
            ScriptTags.Gothic,                                 // 'goth' 
            ScriptTags.Greek,                                  // 'grek'
            ScriptTags.Gujarati,                               // 'gujr' 
            ScriptTags.Gurmukhi,                               // 'guru' 
            ScriptTags.Hangul,                                 // 'hang'
            ScriptTags.Hanunoo,                                // 'hano' 
            ScriptTags.Hebrew,                                 // 'hebr'
            ScriptTags.Kannada,                                // 'knda'
            ScriptTags.Hiragana,                               // 'kana'
//            ScriptTags.Katakana,                               // 'kana' (same tag as Hiragana) 
            ScriptTags.Kharosthi,                              // 'khar'
            ScriptTags.Khmer,                                  // 'khmr' 
            ScriptTags.Lao,                                    // 'lao ' 
            ScriptTags.Latin,                                  // 'latn'
            ScriptTags.Limbu,                                  // 'limb' 
            ScriptTags.LinearB,                                // 'linb'
            ScriptTags.Malayalam,                              // 'mlym'
            ScriptTags.MathematicalAlphanumericSymbols,        // 'math'
            ScriptTags.Mongolian,                              // 'mong' 
            ScriptTags.MusicalSymbols,                         // 'musc'
            ScriptTags.Myanmar,                                // 'mymr' 
            ScriptTags.NewTaiLue,                              // 'talu' 
            ScriptTags.Ogham,                                  // 'ogam'
            ScriptTags.OldItalic,                              // 'ital' 
            ScriptTags.OldPersianCuneiform,                    // 'xpeo'
            ScriptTags.Oriya,                                  // 'orya'
            ScriptTags.Osmanya,                                // 'osma'
            ScriptTags.Runic,                                  // 'runr' 
            ScriptTags.Shavian,                                // 'shaw'
            ScriptTags.Sinhala,                                // 'sinh' 
            ScriptTags.SylotiNagri,                            // 'sylo' 
            ScriptTags.Syriac,                                 // 'syrc'
            ScriptTags.Tagalog,                                // 'tglg' 
            ScriptTags.Tagbanwa,                               // 'tagb'
            ScriptTags.TaiLe,                                  // 'tale'
            ScriptTags.Tamil,                                  // 'taml'
            ScriptTags.Telugu,                                 // 'telu' 
            ScriptTags.Thaana,                                 // 'thaa'
            ScriptTags.Thai,                                   // 'thai' 
            ScriptTags.Tibetan,                                // 'tibt' 
            ScriptTags.Tifinagh,                               // 'tfng'
            ScriptTags.UgariticCuneiform,                      // 'ugar' 
            ScriptTags.Yi,                                     // 'yi  '
            Script.TagDigit,                                   // 'zzz0'
            Script.TagControl,                                 // 'zzz1'
            Script.TagMirror,                                  // 'zzz2' 
        };
 
 
        internal const ScriptTags TagDigit = (ScriptTags)0x307a7a7a; // 'zzz0'
        internal const ScriptTags TagControl = (ScriptTags)0x317a7a7a; // 'zzz1' 
        internal const ScriptTags TagMirror = (ScriptTags)0x327a7a7a; // 'zzz2'

        internal static readonly ScriptFlags[] Flags = new ScriptFlags[]
        { 
            /* Default              */    ScriptFlags.None,
            /* Arabic               */    ScriptFlags.None, 
            /* Armenian             */    ScriptFlags.None, 
            /* Bengali              */    ScriptFlags.NeedsCaretInfo,
            /* Bopomofo             */    ScriptFlags.None, 
            /* Braille              */    ScriptFlags.None,
            /* Buginese             */    ScriptFlags.NeedsCaretInfo,
            /* Buhid                */    ScriptFlags.None,
            /* CanadianSyllabics    */    ScriptFlags.None, 
            /* Cherokee             */    ScriptFlags.None,
            /* CJKIdeographic       */    ScriptFlags.None, 
            /* Coptic               */    ScriptFlags.None, 
            /* CypriotSyllabary     */    ScriptFlags.None,
            /* Cyrillic             */    ScriptFlags.None, 
            /* Deseret              */    ScriptFlags.None,
            /* Devanagari           */    ScriptFlags.NeedsCaretInfo,
            /* Ethiopic             */    ScriptFlags.None,
            /* Georgian             */    ScriptFlags.None, 
            /* Glagolitic           */    ScriptFlags.None,
            /* Gothic               */    ScriptFlags.None, 
            /* Greek                */    ScriptFlags.None, 
            /* Gujarati             */    ScriptFlags.NeedsCaretInfo,
            /* Gurmukhi             */    ScriptFlags.NeedsCaretInfo, 
            /* Hangul               */    ScriptFlags.NeedsCaretInfo,
            /* Hanunoo              */    ScriptFlags.None,
            /* Hebrew               */    ScriptFlags.NeedsCaretInfo,
            /* Kannada              */    ScriptFlags.NeedsCaretInfo, 
            /* Kana                 */    ScriptFlags.None,
            /* Kharoshthi           */    ScriptFlags.NeedsCaretInfo, 
            /* Khmer                */    ScriptFlags.NeedsCaretInfo, 
            /* Lao                  */    ScriptFlags.NeedsCaretInfo,
            /* Latin                */    ScriptFlags.None, 
            /* Limbu                */    ScriptFlags.NeedsCaretInfo,
            /* LinearB              */    ScriptFlags.None,
            /* Malayalam            */    ScriptFlags.NeedsCaretInfo,
            /* MathematicalAlphanumericSymbols */ ScriptFlags.None, 
            /* Mongolian            */    ScriptFlags.NeedsCaretInfo,
            /* MusicalSymbols       */    ScriptFlags.None, 
            /* Myanmar              */    ScriptFlags.NeedsCaretInfo, 
            /* NewTaiLue            */    ScriptFlags.NeedsCaretInfo,
            /* Ogham                */    ScriptFlags.None, 
            /* OldItalic            */    ScriptFlags.None,
            /* OldPersianCuneiform  */    ScriptFlags.None,
            /* Oriya                */    ScriptFlags.NeedsCaretInfo,
            /* Osmanya              */    ScriptFlags.None, 
            /* Runic                */    ScriptFlags.None,
            /* Shavian              */    ScriptFlags.None, 
            /* Sinhala              */    ScriptFlags.NeedsCaretInfo, 
            /* SylotiNagri          */    ScriptFlags.NeedsCaretInfo,
            /* Syriac               */    ScriptFlags.None, 
            /* Tagalog              */    ScriptFlags.None,
            /* Tagbanwa             */    ScriptFlags.None,
            /* TaiLe                */    ScriptFlags.None,
            /* Tamil                */    ScriptFlags.NeedsCaretInfo, 
            /* Telugu               */    ScriptFlags.NeedsCaretInfo,
            /* Thaana               */    ScriptFlags.NeedsCaretInfo, 
            /* Thai                 */    ScriptFlags.NeedsCaretInfo, 
            /* Tibetan              */    ScriptFlags.NeedsCaretInfo,
            /* Tifinagh             */    ScriptFlags.None, 
            /* UgariticCuneiform    */    ScriptFlags.None,
            /* Yi                   */    ScriptFlags.None,
            /* Digit                */    ScriptFlags.None,
            /* Control              */    ScriptFlags.None, 
            /* Mirror               */    ScriptFlags.None,
        }; 
    } 

 
    /// 
    /// Script-specific flags
    /// 
    [Flags] 
    internal enum ScriptFlags : ushort
    { 
        None = 0, 
        NeedsCaretInfo = 1,    // Requires complex caret restriction
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK