Exemplo n.º 1
0
        private bool IsFeaturePresent(TransformationParserBase parser, GlyphTypeface typeface, uint scriptId, uint languageId, uint featureId)
        {
            Tag scriptTest   = TagConverter.TagFromUint(scriptId);
            Tag languageTest = TagConverter.TagFromUint(languageId);
            Tag featureTest  = TagConverter.TagFromUint(featureId);

            foreach (Tag script in parser.GetScriptTags(typeface))
            {
                if (script == scriptTest)
                {
                    foreach (Tag language in parser.GetLangSysTags(typeface, script))
                    {
                        if (language == languageTest)
                        {
                            foreach (Tag feature in parser.GetAllFeatureTags(typeface))
                            {
                                if (feature == featureTest)
                                {
                                    return(true);
                                }
                            }

                            return(false);
                        }
                    }

                    return(false);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private static StateMachine GetOrCompile(TransformationParserBase parser, TransformationCompilerBase compiler, GlyphTypeface typeface, uint scriptId, uint languageId, uint featureId)
        {
            Tag scriptTag   = new Tag(ToTagString(scriptId));
            Tag languageTag = new Tag(ToTagString(languageId));
            Tag featureTag  = new Tag(ToTagString(featureId));

            string key = typeface.FontUri.OriginalString + scriptTag + languageTag + featureTag;

            StateMachine machine;

            if (!_machineCache.TryGetValue(key, out machine))
            {
                IEnumerable <Terka.FontBuilder.Parser.Output.IGlyphTransformationTable> tables;
                if (featureId == 0)
                {
                    tables = parser.GetTransformationTablesForRequiredFeature(typeface, scriptTag, languageTag);
                }
                else
                {
                    tables = parser.GetTransformationTablesForOptionalFeature(typeface, scriptTag, languageTag, featureTag);
                }

                _machineCache[key] = machine = compiler.Compile(tables);
            }

            return(machine);
        }