From 0c17e10ba31b91f34333e07e979e189d34bba481 Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Sun, 23 Sep 2018 17:58:18 +0300 Subject: [PATCH] Add TextStyle structure --- pdf/creator/text_style.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pdf/creator/text_style.go diff --git a/pdf/creator/text_style.go b/pdf/creator/text_style.go new file mode 100644 index 00000000..02819782 --- /dev/null +++ b/pdf/creator/text_style.go @@ -0,0 +1,39 @@ +/* + * This file is subject to the terms and conditions defined in + * file 'LICENSE.md', which is part of this source code package. + */ + +package creator + +import ( + "github.com/unidoc/unidoc/pdf/model/fonts" + "github.com/unidoc/unidoc/pdf/model/textencoding" +) + +// TextStyle is a collection of properties that can be assigned to a chunk of text. +type TextStyle struct { + // The color of the text. + Color Color + + // The font the text will use. + Font fonts.Font + + // The size of the font. + FontSize float64 +} + +func NewTextStyle() TextStyle { + font := fonts.NewFontHelvetica() + font.SetEncoder(textencoding.NewWinAnsiTextEncoder()) + + return TextStyle{ + Color: ColorRGBFrom8bit(0, 0, 0), + Font: font, + FontSize: 10, + } +} + +type TextChunk struct { + Text string + Style TextStyle +}