コード例 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the font tag for the given writing system.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private string FontTagForWs(ICharacterStyleInfo characterStyleInfo)
        {
            string sFontName = characterStyleInfo.FontName.Value;
            int    fontId;

            Fonts.TryGetValue(sFontName, out fontId);
            return(sFontName == null || fontId < 1 ? string.Empty :
                   IntegerWithTag(fontId, @"\f"));
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the font name to the list if it is a real font name (not magic).
        /// </summary>
        /// <param name="fontNames">The list of font names.</param>
        /// <param name="fontInfo">The font info.</param>
        /// ------------------------------------------------------------------------------------
        private static void AddFontInfoName(List <string> fontNames, ICharacterStyleInfo fontInfo)
        {
            if (!fontInfo.FontName.ValueIsSet)
            {
                return;
            }
            string fontName = fontInfo.FontName.Value;

            if (!fontNames.Contains(fontName) && !StyleServices.IsMagicFontName(fontName))
            {
                fontNames.Add(fontName);
            }
        }
コード例 #3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the font info colors.
 /// </summary>
 /// <param name="colors">The list of colors (RGB values).</param>
 /// <param name="fontInfo">The font info.</param>
 /// ------------------------------------------------------------------------------------
 private static void AddFontInfoColors(List <Color> colors, ICharacterStyleInfo fontInfo)
 {
     if (fontInfo.FontColor.ValueIsSet && !colors.Contains(fontInfo.FontColor.Value))
     {
         colors.Add(fontInfo.FontColor.Value);
     }
     if (fontInfo.BackColor.ValueIsSet && !colors.Contains(fontInfo.BackColor.Value))
     {
         colors.Add(fontInfo.BackColor.Value);
     }
     if (!fontInfo.UnderlineColor.ValueIsSet && !colors.Contains(fontInfo.UnderlineColor.Value))
     {
         colors.Add(fontInfo.UnderlineColor.Value);
     }
 }
コード例 #4
0
        static string GetPropValue <T>(ICharacterStyleInfo defProps, ICharacterStyleInfo overrides, Func <ICharacterStyleInfo, IStyleProp <T> > getter,
                                       Func <T, string> writer)
        {
            var def = getter(defProps);

            if (overrides != null)
            {
                var over = getter(overrides);
                if (over != null && over.ValueIsSet)
                {
                    return(writer(over.Value));
                }
            }
            if (def != null && def.ValueIsSet)
            {
                return(writer(def.Value));
            }
            return("");
        }
コード例 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the superscript/subscript setting into a string representation
        /// </summary>
        /// <param name="fontInfo">The font info.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private static string SuperSubString(ICharacterStyleInfo fontInfo)
        {
            if (fontInfo != null && fontInfo.SuperSub != null)
            {
                if (fontInfo.SuperSub.ValueIsSet)
                {
                    switch (fontInfo.SuperSub.Value)
                    {
                    case FwSuperscriptVal.kssvOff:
                        return(@"\nosupersub");

                    case FwSuperscriptVal.kssvSuper:
                        return(@"\super");

                    case FwSuperscriptVal.kssvSub:
                        return(@"\sub");
                    }
                }
            }
            return(string.Empty);
        }
コード例 #6
0
		private void ApplyCharacterStyleInfo(ICharacterStyleInfo fontInfo)
		{
			if (fontInfo == null)
				return;
			if (fontInfo.Bold != null && fontInfo.Bold.ValueIsSet)
				FontWeight = fontInfo.Bold.Value ? (int) VwFontWeight.kvfwBold : (int) VwFontWeight.kvfwNormal;
			if (fontInfo.FontSize != null && fontInfo.FontSize.ValueIsSet)
				m_chrp.dympHeight = fontInfo.FontSize.Value;
			if (fontInfo.BackColor != null && fontInfo.BackColor.ValueIsSet)
				m_chrp.clrBack = ColorUtil.ConvertColorToBGR(fontInfo.BackColor.Value);
			if (fontInfo.FontColor != null && fontInfo.FontColor.ValueIsSet)
				m_chrp.clrFore = ColorUtil.ConvertColorToBGR(fontInfo.FontColor.Value);
			if (fontInfo.Italic != null && fontInfo.Italic.ValueIsSet)
				m_chrp.ttvItalic = fontInfo.Italic.Value ? (int)FwTextToggleVal.kttvForceOn : (int)FwTextToggleVal.kttvOff;
			if (fontInfo.Offset != null && fontInfo.Offset.ValueIsSet)
				m_chrp.dympOffset = fontInfo.Offset.Value;
			if (fontInfo.UnderlineColor != null && fontInfo.UnderlineColor.ValueIsSet)
				m_chrp.clrUnder = ColorUtil.ConvertColorToBGR(fontInfo.UnderlineColor.Value);
			if (fontInfo.FontName != null && fontInfo.FontName.ValueIsSet && fontInfo.FontName.Value != null)
				SetFaceName(fontInfo.FontName.Value);
			if (fontInfo.Underline != null && fontInfo.Underline.ValueIsSet)
				m_chrp.unt = (int)fontInfo.Underline.Value;
			// Todo: supersub, font features
		}