コード例 #1
0
        /// <summary>
        /// Gets a collection of all language systems supported by a single script the typeface. List of all known lang sys tags can be found here: http://www.microsoft.com/typography/developers/opentype/languagetags.aspx .
        /// </summary>
        /// <param name="typeface">The typeface.</param>
        /// <param name="script">The script tag.</param>
        /// <returns>
        /// Collection of tags.
        /// </returns>
        public IEnumerable <Tag> GetLangSysTags(GlyphTypeface typeface, Tag script)
        {
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic fontTable       = this.GetFontTable(typeface);

            if (!fontTable.IsPresent)
            {
                yield break;
            }

            dynamic scriptList  = new AccessPrivateWrapper(fontTableHeader.GetScriptList(fontTable.Wrapped));
            dynamic scriptTable = new AccessPrivateWrapper(scriptList.FindScript(fontTable.Wrapped, TagConverter.UintFromTag(script)));

            if (scriptTable.IsNull)
            {
                throw new ArgumentOutOfRangeException("script");
            }

            if (scriptTable.IsDefaultLangSysExists(fontTable.Wrapped))
            {
                yield return(new Tag("dflt"));
            }

            var uintTags = this.GetEnumerableFromInternalList(
                () => scriptTable.GetLangSysCount(fontTable.Wrapped),
                p => (uint)scriptTable.GetLangSysTag(fontTable.Wrapped, p));

            foreach (var uintTag in uintTags)
            {
                yield return(TagConverter.TagFromUint(uintTag));
            }
        }