Exemplo n.º 1
0
        public IDictionary <string, FontSet> Build()
        {
            IDictionary <string, FontSet> fontDictionary = new Dictionary <string, FontSet>();

            foreach (XmlNode fontNode in  _fontNodeList)
            {
                if (fontNode.Attributes != null)
                {
                    string key     = fontNode.Attributes["key"].Value;
                    var    fontSet = new FontSet();

                    foreach (XmlNode fontStyleNode in fontNode)
                    {
                        if (fontStyleNode.Attributes != null)
                        {
                            var fontStyle =
                                (FontStyle)(Enum.Parse(typeof(FontStyle), fontStyleNode.Attributes["style"].Value));
                            string fontPath = fontStyleNode.Attributes["file"].Value;
                            fontSet.AddFont(fontStyle, Path.Combine(_fontBasePath, fontPath));
                        }
                    }
                    fontDictionary.Add(key, fontSet);
                }
            }
            return(fontDictionary);
        }
Exemplo n.º 2
0
        public void InitChatSystem()
        {
            FontSet font = FontSets.Standard;
            int     minY = 10 + (int)font.font_default.Height;

            ChatMenu     = new UIGroup(new UIPositionHelper(CWindow.MainUI).Anchor(UIAnchor.TOP_CENTER).GetterWidthHeight(() => Window.Width, () => Window.Height - minY - UIBottomHeight).ConstantXY(0, 0));
            ChatScroller = new UIScrollBox(new UIPositionHelper(CWindow.MainUI).Anchor(UIAnchor.TOP_CENTER).GetterWidthHeight(() => ChatMenu.Position.Width - (30 * 2), () => ChatMenu.Position.Height - minY).ConstantXY(0, minY))
            {
                Color = new Color4F(0f, 0.5f, 0.5f, 0.6f)
            };
            ChatBox = new UIInputBox("", "Enter a /command or a chat message...", font, new UIPositionHelper(CWindow.MainUI).Anchor(UIAnchor.TOP_CENTER).GetterWidth(() => ChatScroller.Position.Width).ConstantX(0).GetterY(() => (int)ChatScroller.Position.Height + minY))
            {
                EnterPressed = EnterChatMessage
            };
            ChatMenu.AddChild(ChatBox);
            ChatMenu.AddChild(ChatScroller);
            Channels = new bool[(int)TextChannelHelpers.COUNT];
            Func <int> xer = () => 30;

            Channels[0] = true;
            for (int i = 1; i < Channels.Length; i++)
            {
                Channels[i] = true;
                string     n    = ((TextChannel)i).ToString();
                int        len  = (int)FontSets.Standard.MeasureFancyText(n);
                UITextLink link = null;
                Func <int> fxer = xer;
                int        chan = i;
                link = new UITextLink(null, "^r^t^0^h^o^2" + n, "^!^e^t^0^h^o^2" + n, "^2^e^t^0^h^o^0" + n, FontSets.Standard, () => ToggleLink(link, n, chan), new UIPositionHelper(CWindow.MainUI).Anchor(UIAnchor.TOP_LEFT).GetterX(fxer).ConstantY(10));
                xer  = () => fxer() + len + 10;
                ChatMenu.AddChild(link);
            }
            ClearChat();
            ChatScrollToBottom();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Called at first-time load, loads required resources.
 /// </summary>
 /// <param name="sender">The sending object</param>
 /// <param name="e">The empty event args object</param>
 static void Window_Load(object sender, EventArgs e)
 {
     SysConsole.Output(OutputType.INIT, "Loading texture engine...");
     Texture.InitTextureSystem();
     SysConsole.Output(OutputType.INIT, "Loading shader engine...");
     Shader.InitShaderSystem();
     SysConsole.Output(OutputType.INIT, "Loading text engine...");
     GLFont.Init();
     SysConsole.Output(OutputType.INIT, "Loading font-set engine...");
     FontSet.Init();
     SysConsole.Output(OutputType.INIT, "Loading 3D model engine...");
     Model.Init();
     SysConsole.Output(OutputType.INIT, "Loading rendering helper engine...");
     Renderer.Init();
     SysConsole.Output(OutputType.INIT, "Adjusting OpenGL settings...");
     GL.Enable(EnableCap.DepthTest);
     GL.Enable(EnableCap.Blend);
     GL.Enable(EnableCap.Texture2D);
     GL.Viewport(0, 0, Window.Width, Window.Height);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.Enable(EnableCap.CullFace);
     GL.CullFace(CullFaceMode.Front);
     SysConsole.Output(OutputType.INIT, "Loading material->texture map...");
     MaterialTexture.Init();
     SysConsole.Output(OutputType.INIT, "Loading keyboard handling engine...");
     KeyHandler.Init();
     SysConsole.Output(OutputType.INIT, "Loading interactive console engine...");
     UIConsole.InitConsole();
     SysConsole.Output(OutputType.INIT, "Loading world...");
     InitWorld();
     SysConsole.Output(OutputType.INIT, "Displaying window...");
 }
Exemplo n.º 4
0
 public UIInputBox(string text, string info, FontSet fonts, UIAnchor anchor, Func <float> width, Func <int> xOff, Func <int> yOff)
     : base(anchor, width, () => fonts.font_default.Height, xOff, yOff)
 {
     Text  = text;
     Info  = info;
     Fonts = fonts;
 }
Exemplo n.º 5
0
 public Login()
 {
     InitializeComponent();
     ff = new FontSet();
     initFont();
     contextmenustripform.initFont();
 }
Exemplo n.º 6
0
			public static FontSet Create()
			{
				FontSet fs = new FontSet();
				fs.Fonts = new List<Font>();
				fs.Brushes = new List<Brush>();
				return fs;
			}
Exemplo n.º 7
0
        public void InitChatSystem()
        {
            FontSet font = FontSets.Standard;
            int     minY = 10 + (int)font.font_default.Height;

            ChatMenu     = new UIGroup(UIAnchor.TOP_CENTER, () => Window.Width, () => Window.Height - minY - UIBottomHeight, () => 0, () => 0);
            ChatScroller = new UIScrollBox(UIAnchor.TOP_CENTER, () => ChatMenu.GetWidth() - (30 * 2), () => ChatMenu.GetHeight() - minY, () => 0, () => minY)
            {
                Color = new Vector4(0f, 0.5f, 0.5f, 0.6f)
            };
            ChatBox = new UIInputBox("", "Enter a /command or a chat message...", font, UIAnchor.TOP_CENTER, ChatScroller.GetWidth, () => 0, () => (int)ChatScroller.GetHeight() + minY)
            {
                EnterPressed = EnterChatMessage
            };
            ChatMenu.AddChild(ChatBox);
            ChatMenu.AddChild(ChatScroller);
            Channels = new bool[(int)TextChannel.COUNT];
            Func <int> xer = () => 30;

            Channels[0] = true;
            for (int i = 1; i < Channels.Length; i++)
            {
                Channels[i] = true;
                string     n    = ((TextChannel)i).ToString();
                int        len  = (int)FontSets.Standard.MeasureFancyText(n);
                UITextLink link = null;
                Func <int> fxer = xer;
                int        chan = i;
                link = new UITextLink(null, "^r^t^0^h^o^2" + n, "^!^e^t^0^h^o^2" + n, "^2^e^t^0^h^o^0" + n, FontSets.Standard, () => ToggleLink(link, n, chan), UIAnchor.TOP_LEFT, fxer, () => 10);
                xer  = () => fxer() + len + 10;
                ChatMenu.AddChild(link);
            }
            ClearChat();
            ChatScrollToBottom();
        }
        internal virtual void ResolveFont(SvgDrawContext context)
        {
            FontProvider provider  = context.GetFontProvider();
            FontSet      tempFonts = context.GetTempFonts();

            font = null;
            if (!provider.GetFontSet().IsEmpty() || (tempFonts != null && !tempFonts.IsEmpty()))
            {
                String fontFamily = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_FAMILY);
                String fontWeight = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_WEIGHT);
                String fontStyle  = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_STYLE);
                fontFamily = fontFamily != null?fontFamily.Trim() : "";

                FontInfo fontInfo = ResolveFontName(fontFamily, fontWeight, fontStyle, provider, tempFonts);
                font = provider.GetPdfFont(fontInfo, tempFonts);
            }
            if (font == null)
            {
                try {
                    // TODO: DEVSIX-2057 each call of createFont() create a new instance of PdfFont.
                    // FontProvider shall be used instead.
                    font = PdfFontFactory.CreateFont();
                }
                catch (System.IO.IOException e) {
                    throw new SvgProcessingException(SvgLogMessageConstant.FONT_NOT_FOUND, e);
                }
            }
        }
Exemplo n.º 9
0
        protected internal override void DoDraw(SvgDrawContext context)
        {
            if (this.attributesAndStyles != null && this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.TEXT_CONTENT
                                                                                         ))
            {
                PdfCanvas      currentCanvas    = context.GetCurrentCanvas();
                String         xRawValue        = this.attributesAndStyles.Get(SvgConstants.Attributes.X);
                String         yRawValue        = this.attributesAndStyles.Get(SvgConstants.Attributes.Y);
                String         fontSizeRawValue = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_SIZE);
                IList <String> xValuesList      = SvgCssUtils.SplitValueList(xRawValue);
                IList <String> yValuesList      = SvgCssUtils.SplitValueList(yRawValue);
                float          x        = 0f;
                float          y        = 0f;
                float          fontSize = 0f;
                if (fontSizeRawValue != null && !String.IsNullOrEmpty(fontSizeRawValue))
                {
                    fontSize = CssUtils.ParseAbsoluteLength(fontSizeRawValue, CommonCssConstants.PT);
                }
                if (!xValuesList.IsEmpty())
                {
                    x = CssUtils.ParseAbsoluteLength(xValuesList[0]);
                }
                if (!yValuesList.IsEmpty())
                {
                    y = CssUtils.ParseAbsoluteLength(yValuesList[0]);
                }
                currentCanvas.BeginText();
                FontProvider provider  = context.GetFontProvider();
                FontSet      tempFonts = context.GetTempFonts();
                PdfFont      font      = null;
                if (!provider.GetFontSet().IsEmpty() || (tempFonts != null && !tempFonts.IsEmpty()))
                {
                    String fontFamily = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_FAMILY);
                    String fontWeight = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_WEIGHT);
                    String fontStyle  = this.attributesAndStyles.Get(SvgConstants.Attributes.FONT_STYLE);
                    fontFamily = fontFamily != null?fontFamily.Trim() : "";

                    FontInfo fontInfo = ResolveFontName(fontFamily, fontWeight, fontStyle, provider, tempFonts);
                    font = provider.GetPdfFont(fontInfo, tempFonts);
                }
                if (font == null)
                {
                    try {
                        // TODO (DEVSIX-2057)
                        // TODO each call of createFont() create a new instance of PdfFont.
                        // TODO FontProvider shall be used instead.
                        font = PdfFontFactory.CreateFont();
                    }
                    catch (System.IO.IOException e) {
                        throw new SvgProcessingException(SvgLogMessageConstant.FONT_NOT_FOUND, e);
                    }
                }
                currentCanvas.SetFontAndSize(font, fontSize);
                //Current transformation matrix results in the character glyphs being mirrored, correct with inverse tf
                currentCanvas.SetTextMatrix(1, 0, 0, -1, x, y);
                currentCanvas.SetColor(ColorConstants.BLACK, true);
                currentCanvas.ShowText(this.attributesAndStyles.Get(SvgConstants.Attributes.TEXT_CONTENT));
                currentCanvas.EndText();
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Constructs a new text input box.
 /// </summary>
 /// <param name="text">The default text in the box.</param>
 /// <param name="info">Information about the box.</param>
 /// <param name="fonts">The font to use.</param>
 /// <param name="pos">The position of the element.</param>
 public UIInputBox(string text, string info, FontSet fonts, UIPositionHelper pos)
     : base(pos.Height <= 0 ? pos.ConstantHeight((int)fonts.font_default.Height) : pos)
 {
     Text  = text;
     Info  = info;
     Fonts = fonts;
 }
Exemplo n.º 11
0
 public void initFont()
 {
     Room_Name.Font = FontSet.setBold(10f);
     //chatBox.Font = FontSet.set(10f);
     textMessage.Font = FontSet.set(9f);
     sendBtn.Font     = FontSet.setBold(10f);
 }
Exemplo n.º 12
0
 private static FontSet AddTimesFonts(FontSet set)
 {
     set.AddFont(StandardFonts.TIMES_ROMAN);
     set.AddFont(StandardFonts.TIMES_BOLD);
     set.AddFont(StandardFonts.TIMES_BOLDITALIC);
     set.AddFont(StandardFonts.TIMES_ITALIC);
     return(set);
 }
Exemplo n.º 13
0
 public SvgProcessorResult(IDictionary <String, ISvgNodeRenderer> namedObjects, ISvgNodeRenderer root, FontProvider
                           fontProvider, FontSet tempFonts)
 {
     this.namedObjects = namedObjects;
     this.root         = root;
     this.fontProvider = fontProvider;
     this.tempFonts    = tempFonts;
 }
Exemplo n.º 14
0
 public UIButton(string buttontexname, string buttontext, FontSet font, Action clicked, UIAnchor anchor, Func <float> width, Func <float> height, Func <int> xOff, Func <int> yOff)
     : base(anchor, width, height, xOff, yOff)
 {
     tName       = buttontexname;
     Text        = buttontext;
     TextFont    = font;
     ClickedTask = clicked;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Constructs a new button.
 /// </summary>
 /// <param name="buttontexname">The name of the texture to use.</param>
 /// <param name="buttontext">The text to display.</param>
 /// <param name="font">The font to use.</param>
 /// <param name="clicked">The action to run when clicked.</param>
 /// <param name="pos">The position of the element.</param>
 public UIButton(string buttontexname, string buttontext, FontSet font, Action clicked, UIPositionHelper pos)
     : base(pos)
 {
     tName       = buttontexname;
     Text        = buttontext;
     TextFont    = font;
     ClickedTask = clicked;
 }
Exemplo n.º 16
0
        public virtual void OpenSansFontSetExtraBoldTest01()
        {
            FontSet set = GetOpenSansFontSet();

            AddTimesFonts(set);
            CheckSelector(set.GetFonts(), "Open Sans ExtraBold", "Times-Bold", "Times-Bold", "Times-BoldItalic", "Times-BoldItalic"
                          );
        }
Exemplo n.º 17
0
 /// <summary>Add temporary font from @font-face.</summary>
 /// <param name="fontInfo">the font info</param>
 /// <param name="alias">the alias</param>
 public virtual void AddTemporaryFont(FontInfo fontInfo, String alias)
 {
     if (tempFonts == null)
     {
         tempFonts = new FontSet();
     }
     tempFonts.AddFont(fontInfo, alias);
 }
Exemplo n.º 18
0
            public static FontSet Create()
            {
                FontSet fs = new FontSet();

                fs.Fonts   = new List <Font>();
                fs.Brushes = new List <Brush>();
                return(fs);
            }
Exemplo n.º 19
0
 public void initFont()
 {
     openToolStripMenuItem.Font       = FontSet.set(10f);
     createroomToolStripMenuItem.Font = FontSet.set(10f);
     logoutToolStripMenuItem.Font     = FontSet.set(10f);
     exitToolStripMenuItem.Font       = FontSet.set(10f);
     LockModeToolStripMenuItem.Font   = FontSet.set(10f);
 }
Exemplo n.º 20
0
 /// <summary>Add temporary font from @font-face.</summary>
 /// <param name="fontProgram">the font program</param>
 /// <param name="encoding">the encoding</param>
 /// <param name="alias">the alias</param>
 public virtual void AddTemporaryFont(FontProgram fontProgram, String encoding, String alias)
 {
     if (tempFonts == null)
     {
         tempFonts = new FontSet();
     }
     tempFonts.AddFont(fontProgram, encoding, alias);
 }
Exemplo n.º 21
0
 public void initFont()
 {
     label1.Font         = FontSet.set(8f);
     label2.Font         = FontSet.setBold(14f);
     userList.Font       = FontSet.set(10f);
     selectUserlist.Font = FontSet.set(10f);
     finishBtn.Font      = FontSet.set(10f);
     cencelBtn.Font      = FontSet.set(10f);
 }
 /// <summary>
 /// Creates new
 /// <see cref="SvgProcessorResult"/>
 /// entity.
 /// </summary>
 /// <param name="namedObjects">
 /// a map of named-objects with their id's as
 /// <see cref="System.String"/>
 /// keys and
 /// the
 /// <see cref="iText.Svg.Renderers.ISvgNodeRenderer"/>
 /// objects as values.
 /// </param>
 /// <param name="root">
 /// a wrapped
 /// <see cref="iText.Svg.Renderers.ISvgNodeRenderer"/>
 /// root renderer.
 /// </param>
 /// <param name="context">
 /// a
 /// <see cref="SvgProcessorContext"/>
 /// instance.
 /// </param>
 public SvgProcessorResult(IDictionary <String, ISvgNodeRenderer> namedObjects, ISvgNodeRenderer root, SvgProcessorContext
                           context)
 {
     this.namedObjects = namedObjects;
     this.root         = root;
     this.fontProvider = context.GetFontProvider();
     this.tempFonts    = context.GetTempFonts();
     this.context      = context;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Constructs a new label.
 /// </summary>
 /// <param name="btext">The text to display on the label.</param>
 /// <param name="font">The font to use.</param>
 /// <param name="pos">The position of the element.</param>
 public UILabel(string btext, FontSet font, UIPositionHelper pos)
     : base(pos)
 {
     InternalText     = btext;
     InternalTextFont = font;
     // TODO: Dynamic scaling support?
     CustomWidthValue = Position.Width;
     FixScale();
 }
Exemplo n.º 24
0
 public UILabel(string btext, FontSet font, UIAnchor anchor, Func <int> xOff, Func <int> yOff, Func <int> maxx = null)
     : base(anchor, () => 0, () => 0, xOff, yOff)
 {
     Text     = btext;
     TextFont = font;
     Width    = () => (float)TextFont.MeasureFancyLinesOfText(MaxX != null ? TextFont.SplitAppropriately(Text, MaxX()) : Text, BColor).X;
     Height   = () => (float)TextFont.MeasureFancyLinesOfText(MaxX != null ? TextFont.SplitAppropriately(Text, MaxX()) : Text, BColor).Y;
     MaxX     = maxx;
 }
Exemplo n.º 25
0
        /// <summary>
        /// Initialize this instance of the chip8 emulator
        /// </summary>
        public void Init()
        {
            try
            {
                // reset the registers
                V.ToList().ForEach(r => r = 0);

                // reset the address (index) register
                I = 0;

                // reset the current opcode
                OpCode = 0;

                // set the program counter to 200 - where the loaded program starts
                PC = MEM_PROGRAMSTART;

                // clean up the stack
                stack.Clear();

                // clear the graphics mem
                //GraphicsMemory.ToList().ForEach(gm => gm = 0);
                //_baGraphicsMemory = Enumerable.Repeat((byte)0, GraphicsMemory.Length).ToArray();
                _clearByteArray(ref _baGraphicsMemory);

                // changed the mem, indicate it
                GraphicsMemoryChanged = true;

                // clear the memory
                //Memory.ToList().ForEach(m => m = 0);
                //_baMemory = Enumerable.Repeat((byte)0, Memory.Length).ToArray();
                _clearByteArray(ref _baMemory);
                MemoryChanged = true;

                // reset the key states
                //KeyPad.ToList().ForEach(k => k = 0);
                //_baKeyPad = Enumerable.Repeat((byte)0, KeyPad.Length).ToArray();
                _clearByteArray(ref _baKeyPad);

                // reset the timers
                DelayTimer = 0;
                SoundTimer = 0;

                // load the fontset
                FontSet.CopyTo(Memory, MEM_FONTSETSTART);

                // there is no rom loaded yet
                ROMLoaded = false;

                // reset the cycle counter
                CycleCounter = 0;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while trying to initialize the emulator", ex);
            }
        }
Exemplo n.º 26
0
        public void initFont()
        {
            roomidLabel.Font = FontSet.set(10f);
            pwLabel.Font     = FontSet.set(10f);
            idBox.Font       = FontSet.set(9f);
            pwBox.Font       = FontSet.set(9f);

            okBtn.Font     = FontSet.set(10f);
            cencelBtn.Font = FontSet.set(10f);
        }
Exemplo n.º 27
0
        public virtual void OpenSansFontSetExtraBoldTest01()
        {
            // TODO DEVSIX-2120 ExtraBold subfamily is not processed
            // TODO DEVSIX-2135 if FontCharacteristics instance is not modified, font-family is parsed and 'bold' substring is considered as a reason to set bold flag in FontCharacteristics instance. That should be reviewed.
            FontSet set = GetOpenSansFontSet();

            AddTimesFonts(set);
            CheckSelector(set.GetFonts(), "Open Sans ExtraBold", "Times-Bold", "Times-Bold", "Times-BoldItalic", "Times-BoldItalic"
                          );
        }
Exemplo n.º 28
0
        public virtual void OpenSansFontSetRegularTest01()
        {
            // TODO DEVSIX-2120 Currently both light and regular fonts have the same score so that light is picked up lexicographically. After the changes are implemented the correct one (regular) font shall be selected and the expected constants should be updated
            // TODO Default font shall be specified.
            FontSet set = GetOpenSansFontSet();

            AddTimesFonts(set);
            CheckSelector(set.GetFonts(), "Open Sans", "OpenSans-Light", "OpenSans-Bold", "OpenSans-LightItalic", "OpenSans-BoldItalic"
                          );
        }
Exemplo n.º 29
0
        public void TextLostFocus(object sender, EventArgs e)
        {
            TextBox searchRoomID = (TextBox)sender;

            if (searchRoomID.Text == "")
            {
                searchRoomID.Text      = "방 이름을 검색 후 Enter";
                searchRoomID.Font      = FontSet.set(10f);
                searchRoomID.ForeColor = Color.LightGray;
            }
        }
Exemplo n.º 30
0
 private void initFont()
 {
     searchRoomID.Font            = FontSet.set(10f);
     participateRoomList.Font     = FontSet.set(10f);
     menuImageBtn.Font            = FontSet.set(10f);
     createRoomImageBtn.Font      = FontSet.set(10f);
     resetBtn.Font                = FontSet.set(10f);
     LogoutToolStripMenuItem.Font = FontSet.set(10f);
     ExitToolStripMenuItem.Font   = FontSet.set(10f);
     label1.Font = FontSet.setBold(13f);
 }
Exemplo n.º 31
0
        public virtual void OpenSansFontSetLightTest01()
        {
            // TODO DEVSIX-2127 After DEVSIX-2120 the font should be selected correctly, but the text will still need to be bolded via emulation
            // TODO DEVSIX-2120 Light subfamily is not processed
            // TODO Default font shall be specified.
            FontSet set = GetOpenSansFontSet();

            AddTimesFonts(set);
            CheckSelector(set.GetFonts(), "Open Sans Light", "OpenSans-Light", "OpenSans-Bold", "OpenSans-LightItalic"
                          , "OpenSans-BoldItalic");
        }
Exemplo n.º 32
0
    /// <summary>
    /// Detects font sets by analyzing all "text-face-name" properties.
    /// </summary>
    /// <param name="definitions"></param>
    /// <param name="env"></param>
    public static void SetFontSets(Map map, List<CartoDefinition> definitions, Env env, ICartoTranslator cartoTranslator)
    {
      List<FontSet> fontSets = new List<FontSet>();
      Dictionary<string, FontSet> dictFontSets = new Dictionary<string, FontSet>();

      using (FontFamilyCollection fontCollection = FontUtility.GetFontFamilyCollection())
      {
        List<FontFamilyTypeface> typeFaces = new List<FontFamilyTypeface>();
        List<string> notFoundFontNames = new List<string>();

        int fontSetCounter = 0;

        foreach (CartoDefinition def in definitions)
        {
          foreach (CartoRule rule in def.Rules)
          {
            if (rule.Name == "text-face-name" || rule.Name == "shield-face-name")
            {
              try
              {
                Value value = rule.Value as Value;
                string strFontNames = value.Evaluate(env).ToString().Replace("\"", "");

                FontSet fontSet = null;
                if (_dictFontSets.TryGetValue(strFontNames, out fontSet))
                {
                  if (!fontSets.Contains(fontSet))
                  {
                    fontSets.Add((FontSet)fontSet.Clone());
                    dictFontSets.Add(strFontNames, fontSet);
                  }

                  continue;
                }

                string[] fontNames = strFontNames.Split(',');

                for (int i = 0; i < fontNames.Length; i++)
                {
                  fontNames[i] = fontNames[i].Trim('\'').Trim();
                }

                typeFaces.Clear();

                foreach (string fontName in fontNames)
                {
                  string fName = fontName.Replace(" ", "");
                  FontFamilyTypeface typeFace = null;

                  foreach (MapSurfer.Drawing.FontFamily fontFamily in fontCollection.FontFamilies)
                  {
                    if (typeFace != null)
                      break;

                    foreach (FontFamilyTypeface fft in fontFamily.GetTypefaces())
                    {
                      foreach (string faceName in fft.FaceNames)
                      {
                        string fullName = (fontFamily.Name + faceName).Replace(" ", "");

                        if (string.Equals(fName, fullName, StringComparison.OrdinalIgnoreCase))
                        {
                          typeFace = fft;
                          break;
                        }
                      }
                    }
                  }

                  // We were not able to find appropriate type face
                  if (typeFace == null)
                  {
                    if (!notFoundFontNames.Contains(fontName))
                    {
                      notFoundFontNames.Add(fontName);
                      LogFactory.WriteLogEntry(Logger.Default, string.Format("Unable to find font face(s) for '{0}'", fontName), LogEntryType.Warning);
                    }
                  }
                  else
                  {
                    typeFaces.Add(typeFace);
                  }
                }

                string fontSetName = "fontset-" + fontSetCounter.ToString();

                if (typeFaces.Count > 0)
                {
                  FontSet fs = new FontSet(fontSetName, typeFaces[0].Style, typeFaces[0].Weight);
                  foreach (FontFamilyTypeface fft in typeFaces)
                  {
                    fs.FontNames.Add(fft.FontFamily.Name);
                  }

                  fontSets.Add((FontSet)fs.Clone());
                  _dictFontSets.TryAdd(strFontNames, fs);
                  dictFontSets.Add(strFontNames, fs);

                  fontSetCounter++;
                }
              }
              catch
              { }
            }
          }
        }
      }

      if (fontSets.Count > 0)
        map.FontSets.AddRange(fontSets);

      cartoTranslator.FontSets = dictFontSets;
    }
Exemplo n.º 33
0
	public static void Add(string name, FontSet s) {
		if (fonts == null) { fonts = new Dictionary<string, FontSet>(); }
		if (fonts.ContainsKey(name)) { fonts[name] = s; }
		else { fonts.Add(name, s); }
	}
Exemplo n.º 34
0
	public static void Add(FontSet s) { Add(s.name, s); }
Exemplo n.º 35
0
	public static void AddAll(FontSet[] s) { foreach (FontSet fs in s) { Add(fs); } }
Exemplo n.º 36
0
		public CallTrees()
		{
			InitializeComponent();

			m_regex = new Regex(@"\\([0-9])");
			const string fontName = "Arial";
			const int fontSize = 9;

			m_normalFonts = FontSet.Create();
			m_normalFonts.Add(new Font(fontName, fontSize, FontStyle.Regular), Brushes.Black);
			m_normalFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.Blue);
			m_normalFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.Black);
			m_normalFonts.Add(new Font(fontName, fontSize, FontStyle.Regular), Brushes.Blue);
			m_normalFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.Green);

			m_filteredFonts = FontSet.Create();
			m_filteredFonts.Add(new Font(fontName, fontSize, FontStyle.Regular), Brushes.DimGray);
			m_filteredFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.DimGray);
			m_filteredFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.DimGray);
			m_filteredFonts.Add(new Font(fontName, fontSize, FontStyle.Regular), Brushes.DimGray);
			m_filteredFonts.Add(new Font(fontName, fontSize, FontStyle.Bold), Brushes.DimGray);
		}