Documentation
¶
Index ¶
- Variables
- func TextWrap(dc *gg.Context, s string, w float64) []string
- type Colors
- type Config
- type HyperlinkSegment
- type ImageSegment
- type ListSegment
- type RichText
- func (r *RichText) Align()
- func (t *RichText) AppendMarkdown(content string)
- func (r *RichText) AppendSegment(rs ...RichTextSegment)
- func (r *RichText) Clear()
- func (r *RichText) Cut()
- func (r *RichText) Draw()
- func (r *RichText) Expansion()
- func (t *RichText) ParseMarkdown(content string)
- func (r *RichText) SetFontSize(t TextStyle)
- type RichTextSegment
- type SeparatorSegment
- type TextSegment
- type TextStyle
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //默认文本 TextStyleDefault = TextStyle{Inline: true, Size: 40} //换行文本 TextStyleEnter = TextStyle{Inline: false, Size: 40} //用于组件间距 TextStyleParagraph = TextStyle{Inline: false, Size: 20} //四级标题 TextStyleHead = TextStyle{Inline: false, Bold: true, Size: 60} //三级标题 TextStyleSubHead = TextStyle{Inline: false, Bold: true, Size: 50} //用于List的序号样式 TextStyleList = TextStyle{Inline: true, Size: 40} //用于link TextStyleLink = TextStyle{Inline: true} //用于code代码块`abc` TextStyleCode = TextStyle{Inline: true, Size: 40, Base: true} //用于code代码段“`abc\ndef“` TextStyleCodeBlock = TextStyle{Inline: false, Size: 35, Block: true, Base: true} //引用 //TextStyleNote.Color = cfg.Colors.NoteColor TextStyleNote = TextStyle{Inline: false, Size: 35} //strong TextStyleStrong = TextStyle{Inline: true, Bold: true} //Italic TextStyleItalic = TextStyle{Inline: true, Italic: true} )
Functions ¶
Types ¶
type HyperlinkSegment ¶
type HyperlinkSegment struct {
Style TextStyle
Text string
URL *url.URL
// contains filtered or unexported fields
}
func (*HyperlinkSegment) Draw ¶
func (h *HyperlinkSegment) Draw()
func (*HyperlinkSegment) Inline ¶
func (h *HyperlinkSegment) Inline() bool
func (*HyperlinkSegment) SetParent ¶
func (h *HyperlinkSegment) SetParent(r *RichText)
type ImageSegment ¶
type ImageSegment struct {
Path string //支持的有相对路径,绝对路径,网络路径,base64
Title string
Data []byte //也可以不写path构建
Image image.Image //也可以直接传入图片
Width int
Height int
// contains filtered or unexported fields
}
func (*ImageSegment) Draw ¶
func (i *ImageSegment) Draw()
func (*ImageSegment) InitImage ¶
func (i *ImageSegment) InitImage()
func (*ImageSegment) Inline ¶
func (i *ImageSegment) Inline() bool
func (*ImageSegment) SetParent ¶
func (i *ImageSegment) SetParent(r *RichText)
type ListSegment ¶
type ListSegment struct {
Items []RichTextSegment
Ordered bool
// contains filtered or unexported fields
}
func (*ListSegment) Draw ¶
func (l *ListSegment) Draw()
func (ListSegment) Inline ¶
func (ListSegment) Inline() bool
func (*ListSegment) SetParent ¶
func (l *ListSegment) SetParent(r *RichText)
type RichText ¶
type RichText struct {
Segments []RichTextSegment
Size float64 //用于保存当前字体大小
Cov *gg.Context
gg.Point //用于定位画笔
Config
}
RichText 表示富文本
func NewRichText ¶
func NewRichTextFromMarkdown ¶
func (*RichText) AppendMarkdown ¶
func (*RichText) AppendSegment ¶
func (r *RichText) AppendSegment(rs ...RichTextSegment)
func (*RichText) ParseMarkdown ¶
func (*RichText) SetFontSize ¶
type RichTextSegment ¶
传参接口
type SeparatorSegment ¶
type SeparatorSegment struct {
// contains filtered or unexported fields
}
func (*SeparatorSegment) Draw ¶
func (s *SeparatorSegment) Draw()
func (SeparatorSegment) Inline ¶
func (SeparatorSegment) Inline() bool
func (*SeparatorSegment) SetParent ¶
func (s *SeparatorSegment) SetParent(r *RichText)
type TextSegment ¶
type TextSegment struct {
Style TextStyle //文本样式
Text string
// contains filtered or unexported fields
}
TextSegment 表示文本片段,实现RichTextSegment
func (*TextSegment) SetParent ¶
func (t *TextSegment) SetParent(r *RichText)
Click to show internal directories.
Click to hide internal directories.