Exemple #1
0
        public override GlyphPart <TGlyph>[] GetVerticalGlyphAssembly(TGlyph rawGlyph, TFont font)
        {
            var glyphName         = GlyphNameProvider.GetGlyphName(rawGlyph);
            var glyphAssemblyInfo = _assemblyTable[glyphName];

            if (glyphAssemblyInfo == null)
            {
                return(null);
            }
            if (!(glyphAssemblyInfo[_assemblyPartsKey] is JArray parts))
            {
                // Should have been defined, but let's return null
                return(null);
            }
            List <GlyphPart <TGlyph> > r = new List <GlyphPart <TGlyph> >();

            foreach (JToken partInfo in parts)
            {
                var innerGlyphName       = partInfo[_glyphKey];
                var endConnectorLength   = _FontUnitsToPt(font, partInfo[_endConnectorKey].Value <int>());
                var startConnectorLength = _FontUnitsToPt(font, partInfo[_startConnectorKey].Value <int>());
                var fullAdvance          = _FontUnitsToPt(font, partInfo[_advanceKey].Value <int>());
                var glyphPartName        = partInfo[_glyphKey].Value <string>();
                r.Add(new GlyphPart <TGlyph> {
                    EndConnectorLength   = endConnectorLength,
                    StartConnectorLength = startConnectorLength,
                    FullAdvance          = fullAdvance,
                    IsExtender           = partInfo[_extenderKey].Value <bool>(),
                    Glyph = GlyphNameProvider.GetGlyph(glyphPartName)
                });
            }
            return(r.ToArray());
        }
Exemple #2
0
        private IEnumerable <TGlyph> GetVariantsForGlyph(TGlyph rawGlyph, JToken variants)
        {
            var glyphName     = GlyphNameProvider.GetGlyphName(rawGlyph);
            var variantGlyphs = variants[glyphName];

            if (!(variantGlyphs is JArray variantGlyphsArray))
            {
                var outputGlyph = GlyphNameProvider.GetGlyph(glyphName);
                if (!outputGlyph.Equals(rawGlyph))
                {
                    throw new InvalidCodePathException("GlyphNameProvider.GetGlyph(GlyphNameProvider.GetGlyphName(rawGlyph)) != rawGlyph");
                }
                yield return(outputGlyph);
            }