github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/creator/text_style.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 6 package creator 7 8 import ( 9 "github.com/unidoc/unidoc/pdf/model/fonts" 10 "github.com/unidoc/unidoc/pdf/model/textencoding" 11 ) 12 13 // TextStyle is a collection of properties that can be assigned to a chunk of text. 14 type TextStyle struct { 15 // The color of the text. 16 Color Color 17 18 // The font the text will use. 19 Font fonts.Font 20 21 // The size of the font. 22 FontSize float64 23 } 24 25 // NewTextStyle creates a new text style object which can be used with chunks 26 // of text. Uses default parameters: Helvetica, WinAnsiEncoding and wrap 27 // enabled with a wrap width of 100 points. 28 func NewTextStyle() TextStyle { 29 font := fonts.NewFontHelvetica() 30 font.SetEncoder(textencoding.NewWinAnsiTextEncoder()) 31 32 return TextStyle{ 33 Color: ColorRGBFrom8bit(0, 0, 0), 34 Font: font, 35 FontSize: 10, 36 } 37 } 38 39 // TextChunk represents a chunk of text along with a particular style. 40 type TextChunk struct { 41 Text string 42 Style TextStyle 43 }