当前位置: 首页>>代码示例>>C#>>正文


C# Context.SelectFontFace方法代码示例

本文整理汇总了C#中Cairo.Context.SelectFontFace方法的典型用法代码示例。如果您正苦于以下问题:C# Context.SelectFontFace方法的具体用法?C# Context.SelectFontFace怎么用?C# Context.SelectFontFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cairo.Context的用法示例。


在下文中一共展示了Context.SelectFontFace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePng

	public void CreatePng ()
	{
		const int Width = 480;
		const int Height = 160;
		const int CheckSize = 10;
		const int Spacing = 2;

		// Create an Image-based surface with data stored in ARGB32 format and a context,
		// "using" is used here to ensure that they are Disposed once we are done
		using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height))
		using (Context cr = new Cairo.Context (surface))
		{
			// Start drawing a checkerboard
			int i, j, xcount, ycount;
			xcount = 0;
			i = Spacing;
			while (i < Width) {
				j = Spacing;
				ycount = xcount % 2; // start with even/odd depending on row
				while (j < Height) {
					if (ycount % 2 != 0)
						cr.SetSourceRGB (1, 0, 0);
					else
						cr.SetSourceRGB (1, 1, 1);
					// If we're outside the clip, this will do nothing.
					cr.Rectangle (i, j, CheckSize, CheckSize);
					cr.Fill ();

					j += CheckSize + Spacing;
					++ycount;
				}
				i += CheckSize + Spacing;
				++xcount;
			}

			// Select a font to draw with
			cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize (64.0);

			// Select a color (blue)
			cr.SetSourceRGB (0, 0, 1);

			// Draw
			cr.MoveTo (20, 100);
			cr.ShowText ("Hello, World");

			surface.WriteToPng ("test.png");
		}
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:49,代码来源:CairoPng.cs

示例2: OnExposed

 protected override bool OnExposed(Context cr, Rectangle area)
 {
     cr.Save();
     if(!base.OnExposed(cr, area))
     {
         cr.Color = new Color(1.0, 0.0, 0.0);
         cr.SetFontSize(100.0);
         cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
         cr.ShowText(role.ToString());
         cr.Restore();
         return true;
     }
     cr.Restore();
     return true;
 }
开发者ID:sciaopin,项目名称:bang-sharp,代码行数:15,代码来源:RoleCardWidget.cs

示例3: text

		public void text(Context cr, int width, int height)
		{
			Normalize (cr, width, height);
			cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize(0.35);

			cr.MoveTo(0.04, 0.53);
			cr.ShowText("Hello");

			cr.MoveTo(0.27, 0.65);
			cr.TextPath("void");
			cr.Save();
			cr.Color = new Color (0.5,0.5,1);
			cr.Fill();
			cr.Restore();
			cr.LineWidth = 0.01;
			cr.Stroke();

			// draw helping lines
			cr.Color = new Color (1.0, 0.2, 0.2, 0.6);
			cr.Arc(0.04, 0.53, 0.02, 0, 2*Math.PI);
			cr.Arc(0.27, 0.65, 0.02, 0, 2*Math.PI);
			cr.Fill();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:24,代码来源:Snippets.cs

示例4: Text

 public void Text(Context context,  string txt, HorizontalTextAlignment horizontal = HorizontalTextAlignment.Center, VerticalTextAlignment vertical = VerticalTextAlignment.Middle)
 {
     context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Normal);
     //context.SetFontSize (_surface.Height / 10);
     context.SetFontSize (14);
     var extends = context.TextExtents (txt);
     double x, y;
     x = -(((double)horizontal) / 2 * extends.Width + extends.XBearing);
     y = -(((double)vertical) / 2 * extends.Height + extends.YBearing);
     context.RelMoveTo (x, y);
     context.ShowText (txt);
 }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:12,代码来源:AxisProperties.cs

示例5: UseStandardLineDrawing

 protected void UseStandardLineDrawing(Context g)
 {
     g.Antialias = Antialias.Subpixel;
     g.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Normal); //Draw backround reference lines.
     g.SetFontSize (12);
     g.SetSourceRGB (referenceLineColor, referenceLineColor, referenceLineColor);
     g.LineWidth = 2;
 }
开发者ID:haved,项目名称:MyPrograms,代码行数:8,代码来源:HChart.cs

示例6: Draw

		public static void Draw (Context grw, TextElement text)
		{
			double dY = 0;

			if (text.Foregraund != null) {
				grw.SetSourceRGB (
					text.Foregraund.Red, 
					text.Foregraund.Green, 
					text.Foregraund.Blue);
			}

			grw.SelectFontFace (
				text.FontFamily, 
				FontSlant.Normal, 
				(FontWeight)text.Weight);

			grw.SetFontSize (text.ScaledFontSize);
			var te = grw.TextExtents (text.Text);

			double dX = 0;
			if (text.Align != null) {
				switch (text.Align.ToLowerInvariant()) {
				case AlignType.Center:
					dX = 0.5 * te.Width;

					break;
				case AlignType.Right:
					dX = te.Width;

					break;
				case AlignType.Left:
					dX = 0;
					break;
				default:					
					return;
				}
			}

			if (text.VAlign != null) {
				switch (text.VAlign.ToLowerInvariant ()) {
				case VAlignType.Top:
					dY = te.YBearing;
					break;
				case VAlignType.Center:
					dY = 0.5 * te.YBearing;
					break;
				case VAlignType.Bottom:
					dY = 0;
					break;
				default:					
					return;
				}
			}

			grw.MoveTo (
				text.Start.GeometryX - dX, 
				text.Start.GeometryY - dY);

			grw.ShowText (text.FormattedText);

			grw.Stroke ();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:62,代码来源:TextBrush.cs

示例7: OnExposed

 protected override bool OnExposed(Context cr, Rectangle area)
 {
     cr.Save();
     if(!base.OnExposed(cr, area))
     {
         cr.Color = new Color(1.0, 0.0, 1.0);
         cr.Rectangle(new Rectangle(2.0, 2.0, Allocation.Width - 4.0, Allocation.Height - 4.0));
         cr.LineWidth = 4.0;
         cr.LineJoin = LineJoin.Round;
         cr.Stroke();
         cr.SetFontSize(20.0);
         cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
         cr.Translate(0.0, Allocation.Height / 2);
         cr.ShowText(type.ToString());
         cr.Restore();
         return true;
     }
     cr.Restore();
     return true;
 }
开发者ID:sciaopin,项目名称:bang-sharp,代码行数:20,代码来源:CharacterCardWidget.cs

示例8: measureRawSize

        protected override int measureRawSize(LayoutingType lt)
        {
            if (lines == null)
                lines = getLines;

            using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
                using (Context gr = new Context (img)) {
                    //Cairo.FontFace cf = gr.GetContextFontFace ();

                    gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
                    gr.SetFontSize (Font.Size);

                    fe = gr.FontExtents;
                    te = new TextExtents();

                    if (lt == LayoutingType.Height){
                        int lc = lines.Count;
                        //ensure minimal height = text line height
                        if (lc == 0)
                            lc = 1;

                        return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
                    }

                    foreach (string s in lines) {
                        string l = s.Replace("\t", new String (' ', Interface.TabSize));

                        TextExtents tmp = gr.TextExtents (l);

                        if (tmp.XAdvance > te.XAdvance)
                            te = tmp;
                    }
                    return (int)Math.Ceiling (te.XAdvance) + Margin * 2;
                }
            }
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:36,代码来源:Label.cs

示例9: SetFontFaceNormal

 public static void SetFontFaceNormal(Context ctx)
 {
     ctx.SelectFontFace("Arial",FontSlant.Normal,FontWeight.Normal);
     ctx.SetFontSize(12.0d);
 }
开发者ID:KommuSoft,项目名称:CplKul2012,代码行数:5,代码来源:KnownColors.cs

示例10: PixbufText

        private Pixbuf PixbufText(string text, int size, bool transparent)
        {
            int x=0, y=36;

            surface = new Cairo.ImageSurface(Cairo.Format.Argb32,  800, 600);
            cr = new Cairo.Context(surface);

            if (!transparent) {
                cr.SetSourceRGBA (0.0, 0.0, 0.0, 1.0);
                cr.Rectangle (new Cairo.Rectangle (0, 0, 800, 600));
                cr.Fill ();
            }

            //cr.MoveTo(x, y);
            string font = "sans";
            if (Util.IsWindows ()) {
                font = "MS Gothic";
            }
            if (Util.IsLinux ()) {
                font = "TakaoGothic";
            }
            if (Util.IsMac ()) {
                font = "Hiragino Kaku Gothic ProN";
            }

            cr.SelectFontFace(font, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
            cr.SetFontSize(size);

            Cairo.TextExtents extents = cr.TextExtents(text);
            string[] lines = text.Split ('\n');
            int min = size;
            for (int i = 0; i < lines.Length; i++) {
                string line = lines[i];
                for (int j = size; j > 8; j-=4) {
                    extents = cr.TextExtents(line);
                    if(extents.Width+extents.XBearing<800){
                        if(j<min) min = j;
                        break;
                    }
                    cr.SetFontSize(j);
                }
            }
            cr.SetFontSize(min);

            //string[] lines = text.Split ('\n');
            for (int i = 0; i < lines.Length; i++) {
                DrawText (cr, lines[i], x, y);
                y += (int)extents.Height;
                if (i > 5)
                    break;
            }

            Pixbuf buf = new Gdk.Pixbuf (surface.Data, true, 8, surface.Width, surface.Height, surface.Stride);
            return buf;

            //buf.Save ("aaa.png", "png");
            //surface.WriteToPng (file);
        }
开发者ID:niwakazoider,项目名称:unicast,代码行数:58,代码来源:TextWindow.cs

示例11: DrawOnHandPieces

        private void DrawOnHandPieces(Context cr, Position pos, bool BlackPlayer)
        {
            cr.Save();
            cr.Rectangle(0, 0, ON_HAND_AREA_WIDTH, 9 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            cr.Color = BorderColor;
            cr.FillPreserve();
            cr.Color = new Color(0.6, 0.5, 0.55);
            cr.LineWidth = 3;
            cr.Stroke();

            if (BlackPlayer)
            {
                cr.Translate(0, 8 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            }

            for (int i = 0; i < (int)PieceType.PIECE_TYPES_COUNT; i++)
            {
                int player_nr = BlackPlayer ? 0 : 1;
                if (pos.OnHandPieces[player_nr, i] != 0)
                {
                    //highlight selected piece
                    if (gi != null && gi.localPlayerMoveState != LocalPlayerMoveState.Wait
                        && gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
                        && gi.GetLocalPlayerMove().OnHandPiece != PieceType.NONE
                        && gi.GetLocalPlayerMove().OnHandPiece == (PieceType)i
                        && !((gi.CurPlayer == gi.BlackPlayer) ^ BlackPlayer))
                    {
                        cr.Rectangle(0, 0, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = new Color(0.8, 0.835, 0.4);
                        cr.Fill();
                    }

                    //draw piece
                    cr.Save();
                    if (!BlackPlayer)
                    {
                        cr.Rotate(180 * Math.PI / 180);
                        cr.Translate(-FIELD_SIZE, -FIELD_SIZE);
                    }
                    cr.Scale(FIELD_SIZE / PieceGraphics[i].Dimensions.Width, FIELD_SIZE / PieceGraphics[i].Dimensions.Width);
                    PieceGraphics[i].RenderCairo(cr);
                    cr.Restore();

                    //draw amount
                    cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
                    cr.SetFontSize(FIELD_SIZE / 3 * 0.9);
                    cr.Color = new Color(0, 0, 0);

                    String amount_str = "x " + pos.OnHandPieces[player_nr, i].ToString();
                    TextExtents extents = cr.TextExtents(amount_str);
                    double x = (FIELD_SIZE);
                    // - (extents.Width/2 + extents.XBearing);
                    double y = (FIELD_SIZE / 2) - (extents.Height / 2 + extents.YBearing);

                    cr.MoveTo(x, y);
                    cr.ShowText(amount_str);

                    double offset = BlackPlayer ? -FIELD_SIZE - PADDING : FIELD_SIZE + PADDING;
                    cr.Translate(0, offset);
                }
            }
            cr.Restore();
        }
开发者ID:Rootie,项目名称:KoushuShogi,代码行数:63,代码来源:ShogibanSVG.cs

示例12: DrawBoard

        private void DrawBoard(Context cr, Position pos)
        {
            Console.WriteLine("ShogibanSVG.DrawBoard");
            #region board border
            //Top
            cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            //Left
            cr.Rectangle(0, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
            //Bottom
            cr.Rectangle(0, Game.BOARD_SIZE * FIELD_SIZE + FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            //Right
            cr.Rectangle(9*FIELD_SIZE + FIELD_NAMING_SIZE, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
            cr.Color = BorderColor;
            cr.Fill();
            #endregion

            #region field namings
            cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
            cr.SetFontSize(FIELD_NAMING_SIZE * 0.9);
            cr.Color = new Color(0, 0, 0);

            for (int i = 0; i < VerticalNamings.Length; i++)
            {
                TextExtents extents = cr.TextExtents(VerticalNamings[i].ToString());
                double x = (FIELD_NAMING_SIZE/2) - (extents.Width/2 + extents.XBearing);
                double y = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Height/2 + extents.YBearing);

                cr.MoveTo(x, y);
                cr.ShowText(VerticalNamings[i].ToString());
                cr.MoveTo(x + 9*FIELD_SIZE + FIELD_NAMING_SIZE, y);
                cr.ShowText(VerticalNamings[i].ToString());
            }
            for (int i = 0; i < HorizontalNamings.Length; i++)
            {
                TextExtents extents = cr.TextExtents(HorizontalNamings[i].ToString());
                double x = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Width/2 + extents.XBearing);
                double y = (FIELD_NAMING_SIZE/2) - (extents.Height/2 + extents.YBearing);

                cr.MoveTo(x, y);
                cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
                cr.MoveTo(x, y + 9*FIELD_SIZE + FIELD_NAMING_SIZE);
                cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
            }
            #endregion

            #region board playfield
            //background
            cr.Translate(FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
            cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE, Game.BOARD_SIZE * FIELD_SIZE);
            cr.Color = BoardColor;
            cr.Fill();

            if (gi != null)
            {
                //highlight selected piece field
                if (gi.localPlayerMoveState != LocalPlayerMoveState.Wait
                    && gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
                    && CurMoveNr < 0)
                {
                    if (gi.GetLocalPlayerMove().OnHandPiece == PieceType.NONE)
                    {
                        cr.Rectangle((Game.BOARD_SIZE - gi.GetLocalPlayerMove().From.x - 1) * FIELD_SIZE, gi.GetLocalPlayerMove().From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = SelectedFieldColor;
                        cr.Fill();
                    }
                }

                //highlight last move
                if (gi.Moves.Count > 0 && CurMoveNr != 0)
                {
                    Move move;
                    if (CurMoveNr < 0)
                        move = gi.Moves[gi.Moves.Count-1].move;
                    else
                        move = gi.Moves[CurMoveNr - 1].move;

                    if (move.OnHandPiece == PieceType.NONE)
                    {
                        cr.Rectangle((Game.BOARD_SIZE - move.From.x - 1) * FIELD_SIZE, move.From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                    }
                    cr.Rectangle((Game.BOARD_SIZE - move.To.x - 1) * FIELD_SIZE, move.To.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
                    cr.Color = LastMoveFieldColor;
                    cr.Fill();
                }

                //highlight possible moves
                if (gi.localPlayerMoveState == LocalPlayerMoveState.PickDestination && CurMoveNr < 0)
                {
                    ValidMoves Moves;
                    Move LocalPlayerMove = gi.GetLocalPlayerMove();
                    if (LocalPlayerMove.OnHandPiece == PieceType.NONE)
                    {
                        Moves = pos.GetValidBoardMoves(LocalPlayerMove.From);
                    }
                    else
                    {
                        Moves = pos.GetValidOnHandMoves(LocalPlayerMove.OnHandPiece, gi.CurPlayer == gi.BlackPlayer);
                    }

                    foreach (BoardField Field in Moves)
//.........这里部分代码省略.........
开发者ID:Rootie,项目名称:KoushuShogi,代码行数:101,代码来源:ShogibanSVG.cs

示例13: RenderSkillCell

        private void RenderSkillCell(Context context, Gdk.Rectangle pix_rect, bool isSelected)
        {
            int osOffset = 0;
            int startX = pix_rect.Right - 64;

            if(ECM.Helper.CurrentPlatform == ECM.Helper.Platform.Windows)
                osOffset = 1;

            // Render Text
            context.Save();

            Color col = White;

            //if (!isSelected)
            //    col = Black;

            string s = string.Format("{0} ({1}x)", Text, SkillRank);
            TextExtents te = context.TextExtents(s);
            RenderText(context, s, pix_rect.X + 32, pix_rect.Y + 2, col);

            s = string.Format("Level {0}", SkillLevel);
            te = context.TextExtents(s);
            RenderText(context, s, startX - (te.Width + 6), pix_rect.Y + 2, col);

            s = ECM.Helper.GetDurationInWordsShort(TimeSpan.FromMinutes(SkillMinsToNext));
            te = context.TextExtents(s);
            RenderText(context, s, startX - (te.Width + 6), pix_rect.Y + te.Height + 6, col);

            s = string.Format("SP {0:0,0}/{1:0,0}", SkillCurrSP, SkillNextSP);
            context.SelectFontFace(m_FontDesc.Family, FontSlant.Normal, FontWeight.Bold);
            te = context.TextExtents(s);

            RenderText(context, s, pix_rect.X + 32, pix_rect.Y + te.Height + 6, col);

            context.Restore();

            // Render Progress bars
            context.Save();

            context.Color = Gray;
            context.Antialias = Antialias.None;
            context.LineWidth = 1;

            for (int i = 0; i < SkillLevel; i++)
            {
                context.Rectangle(startX + 2 + i * 9, pix_rect.Y + 3 + osOffset, 8, 6);
            }

            // Time Bar
            double fullWidth = 44;
            double dist = SkillNextSP - SkillLevlSP;
            double trav = SkillCurrSP - SkillLevlSP;
            double perc = 1;

            if(dist > 0)
                perc = Math.Max(0, trav / dist);

            context.Rectangle(startX + 2, pix_rect.Y + 17 + osOffset, fullWidth * perc, 2);

            context.Fill();

            context.Rectangle(startX, pix_rect.Y + 2, 47, 9);

            context.Rectangle(startX, pix_rect.Y + 16, 47, 5);

            context.Stroke();

            context.Restore();

            // Render Skillbook Icon
            context.Save();
            Gdk.CairoHelper.SetSourcePixbuf(context, new Gdk.Pixbuf(ECM.Core.SkillbookPNG), pix_rect.X, pix_rect.Y);

            context.Paint();
            context.Restore();
        }
开发者ID:SilkyPantsDan,项目名称:ECM,代码行数:76,代码来源:CellRendererCharSkill.cs

示例14: InternalRegenerateCloud

        /*
        [XmlIgnore]
        public FontFamily font;
        */
        public void InternalRegenerateCloud()
        {
            r = new Random();
            int id = 0;
            double minSize = Entries.Min(e => e.SizeValue);
            double maxSize = Entries.Max(e => e.SizeValue);
            double range = Math.Max(0.00001, maxSize - minSize);

            _source = new ImageSurface(Format.Argb32,ActualWidth,ActualHeight);
            pixelss = _source.Data;
            g = new Context(_source);
            g.Color = new Color(1.0,1.0,1.0);
            //g.Rectangle(0.0,0.0,ActualWidth,ActualHeight);
            g.Paint();

            g.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            g.SetFontSize(100.0);
            TextExtents te = g.TextExtents("x");
            double areaPerLetter = te.Width;

            strides = _source.Stride;
            int arraySize = (int)((ActualWidth / 4) + 2) * (int)((ActualHeight / 4) + 2);
            _mapping = new int[arraySize];
            for (int i = 0; i < arraySize; i++) _mapping[i] = -1;

            if(svgfn != null) {
                svgs = new SvgSurface(svgfn,ActualWidth,ActualHeight);
                svg = new Context(svgs);
                svg.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            }
            if(pdffn != null) {
                pdfs = new PdfSurface(pdffn,ActualWidth,ActualHeight);
                pdf = new Context(pdfs);
                pdf.SelectFontFace(fontname,FontSlant.Normal,FontWeight.Bold);
            }

            double fontMultiplier;

            if(CoverRatio > 0.0) {
                double totalsize = 0.0;
                MinFontSize = 24.0; // use big fonts for testing
                if(FontMaxRatio < 1.0 || FontMaxRatio > 500.0) FontMaxRatio = 6.0;
                MaxFontSize = FontMaxRatio*MinFontSize;
                fontMultiplier = (MaxFontSize - MinFontSize) / range;
                foreach(WordCloudEntry e in Entries) {
                    float fontsize = (float)(((e.SizeValue - minSize) * fontMultiplier) + MinFontSize);
                    g.SetFontSize(fontsize);
                    TextExtents te1 = g.TextExtents(e.Word);
                    totalsize += te1.Width*te1.Height;
                }
                double actualsize = ActualHeight*ActualWidth;
                double ratio1 = totalsize / actualsize; //this should be == CoverRatio
                //we assume that totalsize ~ MinFontSize^2 in this case
                MinFontSize = MinFontSize*Math.Sqrt(CoverRatio / ratio1);
                MaxFontSize = FontMaxRatio*MinFontSize;
                fontMultiplier = (MaxFontSize - MinFontSize) / range;
                LargestSizeWidthProportion = 0.9;
            }

            double targetWidth = Math.Max(ActualWidth, ActualHeight) * LargestSizeWidthProportion;
            WordCloudEntry od = Entries.OrderByDescending(e => (e.SizeValue - minSize) * e.Word.Length).First();
            double maxFontSize;
            if(MaxFontSize > 0.0 && CoverRatio <= 0.0) {
                maxFontSize = MaxFontSize;
                if(maxFontSize < MinFontSize) maxFontSize = MinFontSize*2.7;
            }
            else {
                g.SetFontSize(100.0);
                TextExtents te2 = g.TextExtents(od.Word);
                maxFontSize = 97.0*targetWidth / te2.Width;
                //maxFontSize = Math.Max(MinFontSize * 2.7, 100.0 / ((od.Word.Length * areaPerLetter) / targetWidth));
                if(maxFontSize > MinFontSize + 100) maxFontSize = MinFontSize + 100;
            }
            if(CoverRatio > 0.0) {
                if(maxFontSize < MaxFontSize) MaxFontSize = maxFontSize;
                fontMultiplier = (maxFontSize - MinFontSize) / range;
            }
            else fontMultiplier = (maxFontSize - MinFontSize) / range;

            var points = new[]
                             {
                                 new Point((int) (ActualWidth/2), (int) (ActualHeight/2)),
                                 new Point((int) (ActualWidth/4), (int) (ActualHeight/4)),
                                 new Point((int) (ActualWidth/4), (int) (3*ActualHeight/2)),
                                 new Point((int) (3*ActualWidth/4), (int) (ActualHeight/2)),
                                 new Point((int) (3*ActualWidth/4), (int) (3*ActualHeight/4))
                             };

            int currentPoint = 0;
            foreach (WordCloudEntry e in Entries.OrderByDescending(e => e.SizeValue))
            {
            again:
                double position = 0.0;
                Point centre = points[currentPoint];

                double angle = 0.0;
//.........这里部分代码省略.........
开发者ID:dkondor,项目名称:WordCloudCairo,代码行数:101,代码来源:Main.cs

示例15: text_align_center

		public void text_align_center(Context cr, int width, int height)
		{
			Normalize (cr, width, height);

			cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
			cr.SetFontSize(0.2);
			TextExtents extents = cr.TextExtents("cairo");
			double x = 0.5 -((extents.Width/2.0) + extents.XBearing);
			double y = 0.5 -((extents.Height/2.0) + extents.YBearing);

			cr.MoveTo(x, y);
			cr.ShowText("cairo");

			// draw helping lines
			cr.Color = new Color (1, 0.2, 0.2, 0.6);
			cr.Arc(x, y, 0.05, 0, 2*Math.PI);
			cr.Fill();
			cr.MoveTo(0.5, 0);
			cr.RelLineTo(0, 1);
			cr.MoveTo(0, 0.5);
			cr.RelLineTo(1, 0);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:23,代码来源:Snippets.cs


注:本文中的Cairo.Context.SelectFontFace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。