Пример #1
0
        public CharInfo GetCharInfo(CharFont charFont, TexStyle style)
        {
            var size     = GetSizeFactor(style);
            var fontInfo = fontInfoList[charFont.FontId];

            return(new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, GetMetrics(charFont, size)));
        }
Пример #2
0
        private void ParseTextStyleMappings()
        {
            this.parsedTextStyles = new Dictionary <string, CharFont[]>();

            var textStyleMappings = rootElement.Element("TextStyleMappings");

            if (textStyleMappings == null)
            {
                throw new InvalidOperationException("Cannot find TextStyleMappings element.");
            }

            foreach (var mappingElement in textStyleMappings.Elements("TextStyleMapping"))
            {
                var textStyleName = mappingElement.AttributeValue("name");
                var charFonts     = new CharFont[3];
                foreach (var mapRangeElement in mappingElement.Elements("MapRange"))
                {
                    var fontId      = mapRangeElement.AttributeInt32Value("fontId");
                    var character   = mapRangeElement.AttributeInt32Value("start");
                    var code        = mapRangeElement.AttributeValue("code");
                    var codeMapping = rangeTypeMappings[code];

                    charFonts[(int)codeMapping] = new CharFont((char)character, fontId);
                }
                this.parsedTextStyles.Add(textStyleName, charFonts);
            }
        }
Пример #3
0
        public Result <CharInfo> GetCharInfo(CharFont charFont, TexStyle style)
        {
            var size     = GetSizeFactor(style);
            var fontInfo = fontInfoList[charFont.FontId];
            var metrics  = GetMetrics(charFont, size);

            return(metrics.Map(m => new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, m)));
        }
Пример #4
0
        private TexFontMetrics GetMetrics(CharFont charFont, double size)
        {
            var fontInfo = fontInfoList[charFont.FontId];
            var metrics  = fontInfo.GetMetrics(charFont.Character);

            return(new TexFontMetrics(metrics[TexFontUtilities.MetricsWidth], metrics[TexFontUtilities.MetricsHeight],
                                      metrics[TexFontUtilities.MetricsDepth], metrics[TexFontUtilities.MetricsItalic],
                                      size * TexFontUtilities.PixelsPerPoint));
        }
Пример #5
0
        public CharFont GetLigature(CharFont leftCharFont, CharFont rightCharFont)
        {
            if (leftCharFont.FontId != rightCharFont.FontId)
            {
                return(null);
            }

            var fontInfo = fontInfoList[leftCharFont.FontId];

            return(fontInfo.GetLigature(leftCharFont.Character, rightCharFont.Character));
        }
Пример #6
0
        public double GetSkew(CharFont charFont, TexStyle style)
        {
            var  fontInfo = fontInfoList[charFont.FontId];
            char skewChar = fontInfo.SkewCharacter;

            if (skewChar == 1)
            {
                return(0);
            }
            return(GetKern(charFont, new CharFont(skewChar, charFont.FontId), style));
        }
Пример #7
0
        public double GetKern(CharFont leftCharFont, CharFont rightCharFont, TexStyle style)
        {
            if (leftCharFont.FontId != rightCharFont.FontId)
            {
                return(0);
            }

            var fontInfo = fontInfoList[leftCharFont.FontId];

            return(fontInfo.GetKern(leftCharFont.Character, rightCharFont.Character,
                                    GetSizeFactor(style) * TexFontUtilities.PixelsPerPoint));
        }
Пример #8
0
 public CharInfo GetCharInfo(CharFont charFont, TexStyle style) =>
 throw MethodNotSupported(nameof(GetCharInfo));
Пример #9
0
 public CharInfo GetCharInfo(CharFont charFont, TexStyle style)
 {
     var size = GetSizeFactor(style);
     var fontInfo = fontInfoList[charFont.FontId];
     return new CharInfo(charFont.Character, fontInfo.Font, size, charFont.FontId, GetMetrics(charFont, size));
 }
Пример #10
0
        public double GetKern(CharFont leftCharFont, CharFont rightCharFont, TexStyle style)
        {
            if (leftCharFont.FontId != rightCharFont.FontId)
                return 0;

            var fontInfo = fontInfoList[leftCharFont.FontId];
            return fontInfo.GetKern(leftCharFont.Character, rightCharFont.Character,
                GetSizeFactor(style) * TexFontUtilities.PixelsPerPoint);
        }
Пример #11
0
 public double GetSkew(CharFont charFont, TexStyle style) => throw MethodNotSupported(nameof(GetSkew));
Пример #12
0
        private void ParseTextStyleMappings()
        {
            this.parsedTextStyles = new Dictionary<string, CharFont[]>();

            var textStyleMappings = rootElement.Element("TextStyleMappings");
            if (textStyleMappings == null)
                throw new InvalidOperationException("Cannot find TextStyleMappings element.");

            foreach (var mappingElement in textStyleMappings.Elements("TextStyleMapping"))
            {
                var textStyleName = mappingElement.AttributeValue("name");
                var charFonts = new CharFont[3];
                foreach (var mapRangeElement in mappingElement.Elements("MapRange"))
                {
                    var fontId = mapRangeElement.AttributeInt32Value("fontId");
                    var character = mapRangeElement.AttributeInt32Value("start");
                    var code = mapRangeElement.AttributeValue("code");
                    var codeMapping = rangeTypeMappings[code];

                    charFonts[(int)codeMapping] = new CharFont((char)character, fontId);
                }
                this.parsedTextStyles.Add(textStyleName, charFonts);
            }
        }
Пример #13
0
 public Result <CharInfo> GetCharInfo(CharFont charFont, TexStyle style) =>
 Result.Error <CharInfo>(MethodNotSupported(nameof(this.GetCharInfo)));
Пример #14
0
 public double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style) => 0.0;
Пример #15
0
 public FixedCharAtom(CharFont charFont)
 {
     this.CharFont = charFont;
 }
Пример #16
0
 public CharFont GetLigature(CharFont leftChar, CharFont rightChar) => null;
Пример #17
0
 public FixedCharAtom(CharFont charFont)
 {
     this.CharFont = charFont;
 }
Пример #18
0
        public CharFont GetLigature(CharFont leftCharFont, CharFont rightCharFont)
        {
            if (leftCharFont.FontId != rightCharFont.FontId)
                return null;

            var fontInfo = fontInfoList[leftCharFont.FontId];
            return fontInfo.GetLigature(leftCharFont.Character, rightCharFont.Character);
        }
Пример #19
0
 private TexFontMetrics GetMetrics(CharFont charFont, double size)
 {
     var fontInfo = fontInfoList[charFont.FontId];
     var metrics = fontInfo.GetMetrics(charFont.Character);
     return new TexFontMetrics(metrics[TexFontUtilities.MetricsWidth], metrics[TexFontUtilities.MetricsHeight],
         metrics[TexFontUtilities.MetricsDepth], metrics[TexFontUtilities.MetricsItalic],
         size * TexFontUtilities.PixelsPerPoint);
 }
Пример #20
0
        private CharInfo GetCharInfo(char character, CharFont[] charFont, TexStyle style)
        {
            TexCharKind charKind;
            int charIndexOffset;
            if (character >= '0' && character <= '9')
            {
                charKind = TexCharKind.Numbers;
                charIndexOffset = character - '0';
            }
            else if (character >= 'a' && character <= 'z')
            {
                charKind = TexCharKind.Small;
                charIndexOffset = character - 'a';
            }
            else
            {
                charKind = TexCharKind.Capitals;
                charIndexOffset = character - 'A';
            }

            if (charFont[(int)charKind] == null)
                return GetDefaultCharInfo(character, style);
            else
                return GetCharInfo(new CharFont((char)(charFont[(int)charKind].Character + charIndexOffset),
                    charFont[(int)charKind].FontId), style);
        }
Пример #21
0
 public double GetSkew(CharFont charFont, TexStyle style)
 {
     var fontInfo = fontInfoList[charFont.FontId];
     char skewChar = fontInfo.SkewCharacter;
     if (skewChar == 1)
         return 0;
     return GetKern(charFont, new CharFont(skewChar, charFont.FontId), style);
 }