예제 #1
0
        private void FillVerticalMetrics(TinyFont font)
        {
            GlyphMetadataAppendix metadata = font.GetOrAddNewAppendix <GlyphMetadataAppendix>();

            List <sbyte> marginTop    = new List <sbyte>();
            List <sbyte> marginBottom = new List <sbyte>();

            foreach (CharacterImportInfo info in from import in _characterImportList.Values
                     orderby import.Mapping.Character
                     select import)
            {
                marginTop.Add(Helper.FitIntoInt8(info.EmSideBearing.Top, Trace));
                marginBottom.Add(Helper.FitIntoInt8(info.EmSideBearing.Bottom, Trace));
            }

            foreach (CharacterImportInfo info in _glyphImportList)
            {
                marginTop.Add(Helper.FitIntoInt8(info.EmSideBearing.Top, Trace));
                marginBottom.Add(Helper.FitIntoInt8(info.EmSideBearing.Bottom, Trace));
            }

            GlyphMetadataAppendix.MetadataSetOffset offsetTop = new GlyphMetadataAppendix.MetadataSetOffset();
            offsetTop.Id   = GlyphMetadataAppendix.MarginTopSet;
            offsetTop.Bits = GlyphMetadataAppendix.MetadataSetBitLength.Eight;

            metadata.Sets.Add(marginTop.Select(m => (byte)m).ToArray());
            metadata.SetsOffsets.Add(offsetTop);

            GlyphMetadataAppendix.MetadataSetOffset offsetBottom = new GlyphMetadataAppendix.MetadataSetOffset();
            offsetBottom.Id   = GlyphMetadataAppendix.MarginBottomSet;
            offsetBottom.Bits = GlyphMetadataAppendix.MetadataSetBitLength.Eight;

            metadata.Sets.Add(marginBottom.Select(m => (byte)m).ToArray());
            metadata.SetsOffsets.Add(offsetBottom);
        }
예제 #2
0
        private void FillGraphemeClusterBoundaries(TinyFont font)
        {
            GlyphMetadataAppendix metadata = font.GetOrAddNewAppendix <GlyphMetadataAppendix>();

            byte[] clusterBoundaries = Resources.GraphemeBreakProperty;

            BitArray data = new BitArray(0);

            foreach (CharacterInfo info in font.EnumerateAllCharacterInfos())
            {
                byte property = FindClusterProperty(clusterBoundaries, info.Codepoint);
                data.AppendLsb(property, 4);
            }

            byte[] setData = new byte[(data.Length + 7) / 8];
            data.CopyTo(setData, 0);

            metadata.Sets.Add(setData);
            GlyphMetadataAppendix.MetadataSetOffset offset = new GlyphMetadataAppendix.MetadataSetOffset();
            offset.Id   = GlyphMetadataAppendix.GraphemeSet;
            offset.Bits = GlyphMetadataAppendix.MetadataSetBitLength.Four;

            metadata.SetsOffsets.Add(offset);
        }