當前位置: 首頁>>代碼示例>>Golang>>正文


Golang MagickWand.QueryFontMetrics方法代碼示例

本文整理匯總了Golang中github.com/gographics/imagick/imagick.MagickWand.QueryFontMetrics方法的典型用法代碼示例。如果您正苦於以下問題:Golang MagickWand.QueryFontMetrics方法的具體用法?Golang MagickWand.QueryFontMetrics怎麽用?Golang MagickWand.QueryFontMetrics使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/gographics/imagick/imagick.MagickWand的用法示例。


在下文中一共展示了MagickWand.QueryFontMetrics方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: draw_setfont

// Set up the drawingwand "dw" for the given font name, font size, and colour.
// If the font or size changes sx get the new width of a space
// (the magickwand is required if it is necessary to query the font metrics)
func draw_setfont(mw *imagick.MagickWand, dw *imagick.DrawingWand, font string, size float64, colour string, sx *float64) {
	sflag := false

	if len(font) > 0 {
		dw.SetFont(font)
		sflag = true
	}

	if len(colour) > 0 {
		pw := imagick.NewPixelWand()
		pw.SetColor(colour)
		dw.SetFillColor(pw)
		pw.Destroy()
		sflag = true
	}

	if size > 0 {
		dw.SetFontSize(size)
	}

	// If either the font or the fontsize (or both) have changed
	// we need to get the size of a space again
	if sflag {
		fm := mw.QueryFontMetrics(dw, " ")
		*sx = fm.TextWidth
	}
}
開發者ID:jabong,項目名稱:imagick,代碼行數:30,代碼來源:main.go

示例2: draw_metrics

// The easiest (?) way to handle vertical text placement is
// not to use gravity at all because then you know that all the text is
// placed relative to ImageMagick's (0,0) coordinate which is the top left of
// the screen and the baseline will be y=0.
func draw_metrics(mw *imagick.MagickWand, dw *imagick.DrawingWand, dx *float64, dy, sx float64, text string) {
	mw.AnnotateImage(dw, *dx, dy, 0, text)
	mw.DrawImage(dw)

	// get the font metrics
	fm := mw.QueryFontMetrics(dw, text)
	if fm != nil {
		// Adjust the new x coordinate
		*dx += fm.TextWidth + sx
	}
}
開發者ID:jabong,項目名稱:imagick,代碼行數:15,代碼來源:main.go

示例3: drawMetrics

func drawMetrics(mw *imagick.MagickWand, dw *imagick.DrawingWand, dx *float64, text string) {
	rotation := float64(random(-30, 30))
	mw.AnnotateImage(dw, *dx, 35, rotation, text)
	mw.DrawImage(dw)
	// get the font metrics
	fm := mw.QueryFontMetrics(dw, text)
	if fm != nil {
		// Adjust the new x coordinate
		*dx += fm.TextWidth + 2
	}
}
開發者ID:npk,項目名稱:captcha,代碼行數:11,代碼來源:image.go


注:本文中的github.com/gographics/imagick/imagick.MagickWand.QueryFontMetrics方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。