コード例 #1
0
        private void ParseTextStyleMappings()
        {
            parsedTextStyles = new Dictionary <string, CharFont[]>();

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

            if (textStyleMappings is 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[codeMapping] = new CharFont((char)character, fontId);
                }
                parsedTextStyles.Add(textStyleName, charFonts);
            }
        }
コード例 #2
0
        private TexFontMetrics GetMetrics(CharFont charFont, double size)
        {
            var metrics = fontInfoList[charFont.FontId].GetMetrics(charFont.Character);

            return(new TexFontMetrics(metrics[TexFontUtilities.MetricsWidth], metrics[TexFontUtilities.MetricsHeight],
                                      metrics[TexFontUtilities.MetricsDepth], metrics[TexFontUtilities.MetricsItalic],
                                      size * TexFontUtilities.PixelsPerPoint));
        }
コード例 #3
0
 public CharFont GetLigature(CharFont leftCharFont, CharFont rightCharFont) =>
 leftCharFont.FontId == rightCharFont.FontId
         ? fontInfoList[leftCharFont.FontId].GetLigature(leftCharFont.Character, rightCharFont.Character)
         : null;
コード例 #4
0
        public double GetSkew(CharFont charFont, TexStyle style)
        {
            var skewChar = fontInfoList[charFont.FontId].SkewCharacter;

            return(skewChar == 1 ? 0 : GetKern(charFont, new CharFont(skewChar, charFont.FontId), style));
        }
コード例 #5
0
 public double GetKern(CharFont leftCharFont, CharFont rightCharFont, TexStyle style) =>
 leftCharFont.FontId == rightCharFont.FontId
         ? fontInfoList[leftCharFont.FontId].GetKern(leftCharFont.Character, rightCharFont.Character,
                                                     GetSizeFactor(style) * TexFontUtilities.PixelsPerPoint)
         : 0;
コード例 #6
0
        public CharInfo GetCharInfo(CharFont charFont, TexStyle style)
        {
            var size = GetSizeFactor(style);

            return(new CharInfo(charFont.Character, fontInfoList[charFont.FontId].Font, size, charFont.FontId, GetMetrics(charFont, size)));
        }
コード例 #7
0
 public void SetNextLarger(char character, char LargerCharacter, int LargerFont) =>
 _NextLarger[character] = new CharFont(LargerCharacter, LargerFont);