how to draw italic text

298 views
Skip to first unread message

sleepy

unread,
May 20, 2016, 5:39:43 AM5/20/16
to golang-nuts
I need to draw some italic text on an image, and found packages https://github.com/golang/image/ and https://github.com/golang/freetype/truetype
but I cannot find an example to draw text in italic style, the documentation of freetype is too much for me.

could anyone help me with this, thanks very much.

Ain

unread,
May 20, 2016, 9:33:06 AM5/20/16
to golang-nuts

On Friday, May 20, 2016 at 12:39:43 PM UTC+3, sleepy wrote:
I need to draw some italic text on an image, and found packages https://github.com/golang/image/ and https://github.com/golang/freetype/truetype
but I cannot find an example to draw text in italic style, the documentation of freetype is too much for me.
 
As far as I understand you just have to use ttf which contains the italic font. Ie, in Windows, in your Fonts directory you have files like
arial.ttf
arialbd.ttf
ariali.ttf
These all are Arial fonts but respectively regular, bold and italic styles.


HTH
ain

Egon

unread,
May 20, 2016, 9:43:45 AM5/20/16
to golang-nuts
https://play.golang.org/p/tSfsvuOex_ (set the font path appropriately)

Nigel Tao

unread,
May 21, 2016, 8:03:56 PM5/21/16
to Egon, golang-nuts
On Fri, May 20, 2016 at 11:43 PM, Egon <egon...@gmail.com> wrote:
> https://play.golang.org/p/tSfsvuOex_ (set the font path appropriately)

const fontpath = "c:\\Windows\\Fonts\\ariali.ttf "

Watch out for the trailing space in that string literal.

You could also avoid the double-backslashes by using a `backtick
string`. https://golang.org/ref/spec#String_literals

sleepy

unread,
May 23, 2016, 9:06:46 PM5/23/16
to golang-nuts
thanks all for your reply.

but I need to draw some Chinese characters, which don't have italic font.


在 2016年5月20日星期五 UTC+8下午5:39:43,sleepy写道:
Reply all
Reply to author
Forward
0 new messages