コード例 #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());
        }
コード例 #2
0
        /*
         *     NSDictionary* italics = (NSDictionary*) _mathTable[kItalic];
         * NSString* glyphName = [self.font getGlyphName:glyph];
         * NSNumber* val = (NSNumber*) italics[glyphName];
         * // if val is nil, this returns 0.
         * return [self fontUnitsToPt:val.intValue];*/
        public override float GetItalicCorrection(TFont font, TGlyph glyph)
        {
            var glyphName = GlyphNameProvider.GetGlyphName(glyph);
            var entry     = _italicTable[glyphName];

            if (entry == null)
            {
                return(0);
            }
            var intEntry = entry.Value <int>();

            return(_FontUnitsToPt(font, intEntry));
        }
コード例 #3
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);
            }
コード例 #4
0
 public override IEnumerable <GlyphPart <TGlyph> > GetVerticalGlyphAssembly(TGlyph rawGlyph, TFont font) =>
 _assemblyTable[GlyphNameProvider.GetGlyphName(rawGlyph)]?[_assemblyPartsKey] is JArray parts?
コード例 #5
0
ファイル: JsonMathTable.cs プロジェクト: zzxxhhzxh/CSharpMath
 /*
  *     NSDictionary* italics = (NSDictionary*) _mathTable[kItalic];
  * NSString* glyphName = [self.font getGlyphName:glyph];
  * NSNumber* val = (NSNumber*) italics[glyphName];
  * // if val is nil, this returns 0.
  * return [self fontUnitsToPt:val.intValue];*/
 public override float GetItalicCorrection(TFont font, TGlyph glyph) =>
 _italicTable[GlyphNameProvider.GetGlyphName(glyph)] is JToken entry