コード例 #1
0
ファイル: GlyphSubstitution.cs プロジェクト: ywscr/Typography
        public void DoSubstitution(IGlyphIndexList glyphIndexList)
        {
            // Rebuild tables if configuration changed
            if (_mustRebuildTables)
            {
                RebuildTables();
                _mustRebuildTables = false;
            }


            // Iterate over lookups, then over glyphs, as explained in the spec:
            // "During text processing, a client applies a lookup to each glyph
            // in the string before moving to the next lookup."
            // https://www.microsoft.com/typography/otspec/gsub.htm
            foreach (GSubLkContext lookupCtx in _lookupTables)
            {
                GSUB.LookupTable lookupTable = lookupCtx.lookup;
                lookupCtx.SetGlyphCount(glyphIndexList.Count);

                for (int pos = 0; pos < glyphIndexList.Count; ++pos)
                {
                    if (!lookupCtx.WillCheckThisGlyph(pos))
                    {
                        continue;
                    }
                    lookupTable.DoSubstitutionAt(glyphIndexList, pos, glyphIndexList.Count - pos);
                }
            }
        }
コード例 #2
0
        public void DoSubstitution(IGlyphIndexList outputCodePoints)
        {
            if (lookupTables == null)
            {
                return;
            }                                     //early exit if no lookup tables

            //
            //load
            int j = lookupTables.Count;

            for (int i = 0; i < j; ++i)
            {
                GSUB.LookupTable lookupTable = lookupTables[i];
                //
                if (!EnableLigation &&
                    lookupTable.ForUseWithFeatureId == Features.liga.shortname)
                {
                    //skip this feature
                    continue;
                }

                lookupTable.DoSubstitution(outputCodePoints, 0, outputCodePoints.Count);
            }
        }
コード例 #3
0
ファイル: GlyphSubstitution.cs プロジェクト: ywscr/Typography
 public GSubLkContext(GSUB.LookupTable lookup)
 {
     this.lookup = lookup;
 }
コード例 #4
0
            public GlyphSubStitution(Typeface typeface, string lang)
            {
                this.EnableLigation = true;//enable by default
                this.Lang           = lang;
                this.typeface       = typeface;
                //check if this lang has
                gsubTable = typeface.GSUBTable;
                ScriptTable scriptTable = gsubTable.ScriptList.FindScriptTable(lang);

                //---------
                if (scriptTable == null)
                {
                    return;
                }                                      //early exit if no lookup tables

                //---------
                ScriptTable.LangSysTable selectedLang = null;
                if (scriptTable.langSysTables != null && scriptTable.langSysTables.Length > 0)
                {
                    //TODO: review here

                    selectedLang = scriptTable.langSysTables[0];
                }
                else
                {
                    selectedLang = scriptTable.defaultLang;
                }

                if (selectedLang.HasRequireFeature)
                {
                    //TODO: review here
                }

                //other feature
                if (selectedLang.featureIndexList != null)
                {
                    //get features
                    var features = new List <FeatureList.FeatureTable>();
                    for (int i = 0; i < selectedLang.featureIndexList.Length; ++i)
                    {
                        FeatureList.FeatureTable feature = gsubTable.FeatureList.featureTables[selectedLang.featureIndexList[i]];
                        switch (feature.TagName)
                        {
                        case "ccmp":     //glyph composition/decomposition
                            //this version we implement ccmp
                            features.Add(feature);
                            break;

                        case "liga":
                            //Standard Ligatures --enable by default
                            features.Add(feature);
                            break;
                        }
                    }
                    //-----------------------
                    lookupTables = new List <GSUB.LookupTable>();
                    int j = features.Count;
                    for (int i = 0; i < j; ++i)
                    {
                        FeatureList.FeatureTable feature = features[i];
                        ushort[] lookupListIndices       = feature.LookupListIndice;
                        foreach (ushort lookupIndex in lookupListIndices)
                        {
                            GSUB.LookupTable lktable = gsubTable.GetLookupTable(lookupIndex);
                            lktable.ForUseWithFeatureId = feature.TagName;
                            lookupTables.Add(gsubTable.GetLookupTable(lookupIndex));
                        }
                    }
                }
            }