mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
Add TextStyle text rendering mode property
This commit is contained in:
parent
3121645d50
commit
b86acf161f
@ -41,6 +41,39 @@ const (
|
|||||||
TextAlignmentJustify
|
TextAlignmentJustify
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TextRenderingMode determines whether showing text shall cause glyph
|
||||||
|
// outlines to be stroked, filled, used as a clipping boundary, or some
|
||||||
|
// combination of the three.
|
||||||
|
// See section 9.3 "Text State Parameters and Operators" and
|
||||||
|
// Table 106 (pp. 254-255 PDF32000_2008).
|
||||||
|
type TextRenderingMode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TextRenderingModeFill (default) - Fill text.
|
||||||
|
TextRenderingModeFill TextRenderingMode = iota
|
||||||
|
|
||||||
|
// TextRenderingModeStroke - Stroke text.
|
||||||
|
TextRenderingModeStroke
|
||||||
|
|
||||||
|
// TextRenderingModeFillStroke - Fill, then stroke text.
|
||||||
|
TextRenderingModeFillStroke
|
||||||
|
|
||||||
|
// TextRenderingModeInvisible - Neither fill nor stroke text (invisible).
|
||||||
|
TextRenderingModeInvisible
|
||||||
|
|
||||||
|
// TextRenderingModeFillClip - Fill text and add to path for clipping.
|
||||||
|
TextRenderingModeFillClip
|
||||||
|
|
||||||
|
// TextRenderingModeStrokeClip - Stroke text and add to path for clipping.
|
||||||
|
TextRenderingModeStrokeClip
|
||||||
|
|
||||||
|
// TextRenderingModeFillStrokeClip - Fill, then stroke text and add to path for clipping.
|
||||||
|
TextRenderingModeFillStrokeClip
|
||||||
|
|
||||||
|
// TextRenderingModeClip - Add text to path for clipping.
|
||||||
|
TextRenderingModeClip
|
||||||
|
)
|
||||||
|
|
||||||
// Relative and absolute positioning types.
|
// Relative and absolute positioning types.
|
||||||
type positioning int
|
type positioning int
|
||||||
|
|
||||||
|
@ -656,6 +656,9 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
|||||||
fontName := defaultFontName
|
fontName := defaultFontName
|
||||||
fontSize := defaultFontSize
|
fontSize := defaultFontSize
|
||||||
|
|
||||||
|
// Set chunk rendering mode.
|
||||||
|
cc.Add_Tr(int64(style.RenderingMode))
|
||||||
|
|
||||||
if p.alignment != TextAlignmentJustify || isLastLine {
|
if p.alignment != TextAlignmentJustify || isLastLine {
|
||||||
spaceMetrics, found := style.Font.GetRuneMetrics(' ')
|
spaceMetrics, found := style.Font.GetRuneMetrics(' ')
|
||||||
if !found {
|
if !found {
|
||||||
@ -744,6 +747,9 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
currX += chunkWidth
|
currX += chunkWidth
|
||||||
|
|
||||||
|
// Reset rendering mode.
|
||||||
|
cc.Add_Tr(int64(TextRenderingModeFill))
|
||||||
}
|
}
|
||||||
|
|
||||||
currY -= height
|
currY -= height
|
||||||
|
@ -19,6 +19,9 @@ type TextStyle struct {
|
|||||||
|
|
||||||
// The size of the font.
|
// The size of the font.
|
||||||
FontSize float64
|
FontSize float64
|
||||||
|
|
||||||
|
// The rendering mode.
|
||||||
|
RenderingMode TextRenderingMode
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTextStyle creates a new text style object using the specified font.
|
// newTextStyle creates a new text style object using the specified font.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user