コード例 #1
0
        public void CanParseAfmFile()
        {
            var input = StringBytesTestConverter.Convert(CourierAfmSnippet, false);

            var metrics = parser.Parse(input.Bytes, false);

            Assert.NotNull(metrics);
        }
コード例 #2
0
        private static void AddAdobeFontMetrics(string fontName, string afmName, Standard14Font?type = null)
        {
            Standard14Names.Add(fontName);
            Standard14Mapping.Add(fontName, afmName);

            if (Standard14AfmMap.TryGetValue(afmName, out var metrics))
            {
                Standard14AfmMap[fontName] = metrics;
            }

            try
            {
                var assembly = typeof(Standard14).Assembly;

                var name = $"UglyToad.PdfPig.Resources.AdobeFontMetrics.{afmName}.afm";

                IInputBytes bytes;
                using (var memory = new MemoryStream())
                    using (var resource = assembly.GetManifestResourceStream(name))
                    {
                        resource.CopyTo(memory);
                        bytes = new ByteArrayInputBytes(memory.ToArray());
                    }

                Standard14AfmMap[fontName] = Parser.Parse(bytes, true);
                if (type.HasValue)
                {
                    Standard14AfmTypeMap[type.Value] = Standard14AfmMap[fontName];
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Could not load {fontName} from the AFM files.", ex);
            }
        }
コード例 #3
0
        public void CanParseHelveticaAfmFile()
        {
            var helvetica = GetResourceBytes("UglyToad.PdfPig.Fonts.Resources.AdobeFontMetrics.Helvetica.afm");

            var input = new ByteArrayInputBytes(helvetica);

            var metrics = AdobeFontMetricsParser.Parse(input, false);

            Assert.NotNull(metrics);
        }