コード例 #1
0
        private void Update(EvaluationContext context)
        {
            var overwrites = context.VariationOverwrites;

            // var id = new Variator.VariationId(Guid.Empty, Guid.Empty);
            if (!overwrites.TryGetValue(Variator.VariationId.EmptySet, out var entry))
            {
                entry = new VariationSelector();
                overwrites.Add(Variator.VariationId.EmptySet, entry);
            }

            entry.Index1 = Index1.GetValue(context);
            entry.Index2 = Index2.GetValue(context);
            entry.Weight = Weight.GetValue(context);
            Result.Value = Input.GetValue(context);
            overwrites.Remove(Variator.VariationId.EmptySet);
        }
コード例 #2
0
ファイル: cmap.cs プロジェクト: Reavenk/Berny_Core
            public List <VariationSelector> varSelector;           // Array of VariationSelector records.

            public void Read(TTFReader r, bool readformat = false)
            {
                if (readformat == true)
                {
                    r.ReadInt(out this.format);
                }
                else
                {
                    this.format = 14;
                }

                r.ReadInt(out this.length);
                r.ReadInt(out this.numVarSelectorRecords);

                this.varSelector = new List <VariationSelector>();
                for (int i = 0; i < this.numVarSelectorRecords; ++i)
                {
                    VariationSelector vs = new VariationSelector();
                    vs.Read(r);
                    this.varSelector.Add(vs);
                }
            }
コード例 #3
0
        public static CharMapFormat14 Create(BinaryReader reader)
        {
            // 'cmap' Subtable Format 14:
            // Type                 Name                                Description
            // uint16               format                              Subtable format.Set to 14.
            // uint32               length                              Byte length of this subtable (including this header)
            // uint32               numVarSelectorRecords               Number of variation Selector Records
            // VariationSelector    varSelector[numVarSelectorRecords]  Array of VariationSelector records.
            // ---
            //
            // Each variation selector records specifies a variation selector character, and
            // offsets to “default” and “non-default” tables used to map variation sequences using
            // that variation selector.
            //
            // VariationSelector Record:
            // Type      Name                 Description
            // uint24    varSelector          Variation selector
            // Offset32  defaultUVSOffset     Offset from the start of the format 14 subtable to
            //                                Default UVS Table.May be 0.
            // Offset32  nonDefaultUVSOffset  Offset from the start of the format 14 subtable to
            //                                Non-Default UVS Table. May be 0.
            //
            // The Variation Selector Records are sorted in increasing order of ‘varSelector’. No
            // two records may have the same ‘varSelector’.
            // A Variation Selector Record and the data its offsets point to specify those UVSes
            // supported by the font for which the variation selector is the ‘varSelector’ value
            // of the record. The base characters of the UVSes are stored in the tables pointed
            // to by the offsets.The UVSes are partitioned by whether they are default or
            // non-default UVSes.
            // Glyph IDs to be used for non-default UVSes are specified in the Non-Default UVS table.

            long beginAt = reader.BaseStream.Position - 2; // account for header format entry
            uint length  = reader.ReadUInt32();            // Byte length of this subtable (including the header)
            uint numVarSelectorRecords = reader.ReadUInt32();

            var variationSelectors = new Dictionary <int, VariationSelector>();

            int[]  varSelectors         = new int[numVarSelectorRecords];
            uint[] defaultUVSOffsets    = new uint[numVarSelectorRecords];
            uint[] nonDefaultUVSOffsets = new uint[numVarSelectorRecords];
            for (int i = 0; i < numVarSelectorRecords; ++i)
            {
                varSelectors[i]         = Utils.ReadUInt24(reader);
                defaultUVSOffsets[i]    = reader.ReadUInt32();
                nonDefaultUVSOffsets[i] = reader.ReadUInt32();
            }


            for (int i = 0; i < numVarSelectorRecords; ++i)
            {
                var sel = new VariationSelector();

                if (defaultUVSOffsets[i] != 0)
                {
                    // Default UVS table
                    //
                    // A Default UVS Table is simply a range-compressed list of Unicode scalar
                    // values, representing the base characters of the default UVSes which use
                    // the ‘varSelector’ of the associated Variation Selector Record.
                    //
                    // DefaultUVS Table:
                    // Type          Name                           Description
                    // uint32        numUnicodeValueRanges          Number of Unicode character ranges.
                    // UnicodeRange  ranges[numUnicodeValueRanges]  Array of UnicodeRange records.
                    //
                    // Each Unicode range record specifies a contiguous range of Unicode values.
                    //
                    // UnicodeRange Record:
                    // Type    Name               Description
                    // uint24  startUnicodeValue  First value in this range
                    // uint8   additionalCount    Number of additional values in this range
                    //
                    // For example, the range U+4E4D&endash; U+4E4F (3 values) will set
                    // ‘startUnicodeValue’ to 0x004E4D and ‘additionalCount’ to 2. A singleton
                    // range will set ‘additionalCount’ to 0.
                    // (‘startUnicodeValue’ + ‘additionalCount’) must not exceed 0xFFFFFF.
                    // The Unicode Value Ranges are sorted in increasing order of
                    // ‘startUnicodeValue’. The ranges must not overlap; i.e.,
                    // (‘startUnicodeValue’ + ‘additionalCount’) must be less than the
                    // ‘startUnicodeValue’ of the following range (if any).

                    reader.BaseStream.Seek(beginAt + defaultUVSOffsets[i], SeekOrigin.Begin);
                    uint numUnicodeValueRanges = reader.ReadUInt32();
                    for (int n = 0; n < numUnicodeValueRanges; ++n)
                    {
                        int startCode = (int)Utils.ReadUInt24(reader);
                        sel.DefaultStartCodes.Add(startCode);
                        sel.DefaultEndCodes.Add(startCode + reader.ReadByte());
                    }
                }

                if (nonDefaultUVSOffsets[i] != 0)
                {
                    // Non-Default UVS table
                    //
                    // A Non-Default UVS Table is a list of pairs of Unicode scalar values and
                    // glyph IDs.The Unicode values represent the base characters of all
                    // non -default UVSes which use the ‘varSelector’ of the associated Variation
                    // Selector Record, and the glyph IDs specify the glyph IDs to use for the
                    // UVSes.
                    //
                    // NonDefaultUVS Table:
                    // Type        Name                         Description
                    // uint32      numUVSMappings               Number of UVS Mappings that follow
                    // UVSMapping  uvsMappings[numUVSMappings]  Array of UVSMapping records.
                    //
                    // Each UVSMapping record provides a glyph ID mapping for one base Unicode
                    // character, when that base character is used in a variation sequence with
                    // the current variation selector.
                    //
                    // UVSMapping Record:
                    // Type    Name          Description
                    // uint24  unicodeValue  Base Unicode value of the UVS
                    // uint16  glyphID       Glyph ID of the UVS
                    //
                    // The UVS Mappings are sorted in increasing order of ‘unicodeValue’. No two
                    // mappings in this table may have the same ‘unicodeValue’ values.

                    reader.BaseStream.Seek(beginAt + nonDefaultUVSOffsets[i], SeekOrigin.Begin);
                    uint numUVSMappings = reader.ReadUInt32();
                    for (int n = 0; n < numUVSMappings; ++n)
                    {
                        int    unicodeValue = (int)Utils.ReadUInt24(reader);
                        ushort glyphID      = reader.ReadUInt16();
                        sel.UVSMappings.Add(unicodeValue, glyphID);
                    }
                }

                variationSelectors.Add(varSelectors[i], sel);
            }

            return(new CharMapFormat14 {
                _variationSelectors = variationSelectors
            });
        }