Feature #1213

New modes of text rendering

Added by Michael 5 months ago. Updated 3 months ago.

Status:FeedbackStart date:2018-03-09
Priority:NormalDue date:
Assignee:Remko% Done:


Target version:Candidate for next minor release


In PostScript, there are three operations for working with paths - fill, stroke and clip. Using the charpath command, you can get a path for an arbitrary text. The figure font.eps shows the result of applying basic operations and their combinations to text contours. Variants 2-6 can be considered basic, since the rest can be obtained by overlaying them in various combinations. GMT supports variants 1 ([size],[family],-=[width],[line]), 4 ([size],[family],[fill]), and 7 ([size],[family],[fill]=[width],[line]). Variant 8 is also supported, but not documented ([size],[family],[fill]=~[width],[line]). Clipping is not supported in any way.

Variants 7 and 8 are implemented in GMT by overlapping 1 and 4 each other in different order. This works if the colors are opaque. In the case of transparent colors, there is a difference between 1+4 and 3+4, see the figure test.pdf.

I suggest implementing clipping support by adding, for example, the =+ and =- operators. Then variant 2 can look like [size],[family],-=-[width],[line], 3 - [size],[family],-=+[width],[line], and 3+4 as [size],[family],[fill]=+[width],[line].

I also suggest adding the modifier +e[i|n] to the -F option of the text module (similar to the +e modifier for the -A option of contour module), which will implement variants 5 and 6.

font.eps - Variants of text rendering (2.47 KB) Michael, 2018-03-09 16:44

test.eps - Source file for test.pdf (1.58 KB) Michael, 2018-03-09 16:45

test.pdf - Difference between two rendering variants in case of semitransparent fill (23.7 KB) Michael, 2018-03-09 16:45

new_font_modes.patch Magnifier (4.23 KB) Michael, 2018-03-15 03:01

filled_font1.sh Magnifier (567 Bytes) Michael, 2018-03-15 03:02

filled_font1.pdf (55.1 KB) Michael, 2018-03-15 03:02


#1 Updated by Michael 5 months ago

I added the =+ and =- functionality in the attached patch. The test script and its output are also attached. In the last two lines of the test output, you can see the new bug of the GMT.

#2 Updated by Paul 5 months ago

  • Status changed from New to Feedback
  • Target version set to Candidate for next minor release

Just wanted to acknowledge the receipt of this patch. Thanks, we will consider it but it is less urgent than a few other matters.

#3 Updated by Paul 3 months ago

  • Assignee set to Paul

We will be having a team discussion on what to do regarding your patch. I am not sure if all 8 modes are required, plus your patch only covers pstext plotting and not the pure PostScript that handles quoted lines. Will be in touch.

#4 Updated by Paul 3 months ago

  • Assignee changed from Paul to Remko

Michael, we have decided not to implement many of the more esoteric options. We have decided to keep/update 3 options:

  1. Filled (default, e.g. red), using way 4
  2. Outline font with no fill (e.g. -=green), using way 3 or 8
  3. Outline font with fill (e.g. red=green), using way 8

I am passing control of this issue to Remko. We will also seek to make those three mode work (and in the same way) for the quoted lines PostSCript macros.

#5 Updated by Michael 3 months ago

Do you plan to implement text clipping paths (variants 5 and 6)? They can be useful when creating logos or when drawing contrast text on a multicolored background.

#6 Updated by Remko 3 months ago

I would like to avoid introducing too many options (=-, =+, =~) that would eventually result in "user error".
So I'm aiming to implement the different ways for stoke-fill, fill-stroke, stroke-clip-fill depending on whether we have filled (standard), outline, outline-filled, outline-filled-transparently. I think this can all be done through only adding "=".
If it is then practical to also support the external and internal clipping, that I'll add that as an extra bonus. Maybe that could then be done with +e as you suggested.

Also available in: Atom PDF