示例#1
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);
            }
        }
示例#2
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)));
        }
示例#3
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));
        }
示例#4
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));
        }
示例#5
0
        private static Result <TexFontMetrics> GetMetrics(CharFont charFont, double size)
        {
            var fontInfo = fontInfoList[charFont.FontId];
            var metrics  = fontInfo.GetMetrics(charFont.Character);

            return(metrics.Map(m => new TexFontMetrics(
                                   m[TexFontUtilities.MetricsWidth],
                                   m[TexFontUtilities.MetricsHeight],
                                   m[TexFontUtilities.MetricsDepth],
                                   m[TexFontUtilities.MetricsItalic],
                                   size * TexFontUtilities.PixelsPerPoint)));
        }
示例#6
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));
        }
示例#7
0
 public double GetSkew(CharFont charFont, TexStyle style) => throw MethodNotSupported(nameof(GetSkew));
示例#8
0
 public double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style) => 0.0;
示例#9
0
 public Result <CharInfo> GetCharInfo(CharFont charFont, TexStyle style) =>
 Result.Error <CharInfo>(MethodNotSupported(nameof(this.GetCharInfo)));
示例#10
0
 public CharFont GetLigature(CharFont leftChar, CharFont rightChar) => null;