qt5base-lts/tests/baseline/painting/scripts/text.qps
Eskil Abrahamsen Blomfeldt 58907dfa81 Try to match variant-selector font to preceding character
Variant-selectors are special unicode symbols which are used to
modify glyph selection for the preceding character. For instance,
a regular symbol could be turned into a color emoji using VS16,
the emoji variation selector. In order for this to work, however,
the font that handles the selector has to handle the full pair of
characters, so that it can apply the correct substitution rules.

One specific example of this was on macOS, where an airplane
symbol + VS16 would match the symbol to the default UI font but
the VS16 to the emoji font. Since there string provided for the
emoji font did not have any preceding character for VS16, we just
ignored it.

To improve on this, we now detect variation selectors that have
been matched to different font engines than the preceding
character. When such a case occurs, we check if the selector font
also supports the preceding character, and if it does, we keep
the pair together and use the same font for both.

[ChangeLog][QtGui][Text] Fix some cases where a variation-selector
character would be ignored in font selection and the correct
variant of a character would thus not be selected.

Task-number: QTBUG-108799
Change-Id: I9f427e0520e652ee2f24a4f7dc3c1957251e06bd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-12 19:25:45 +01:00

200 lines
4.4 KiB
Plaintext

# Version: 1
drawText -5 5 "Text that is drawn outside the bounds..."
translate 20 20
begin_block text_drawing
save
setFont "sansserif" 10 normal
drawText 0 20 "sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawText 0 40 "sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawText 0 60 "sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawText 0 80 "sansserif 10pt, bold italic"
translate 0 100
setPen #7fff0000
setFont "sansserif" 10 normal
drawText 0 20 "alpha sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawText 0 40 "alpha sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawText 0 60 "alpha sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawText 0 80 "alpha sansserif 10pt, bold italic"
translate 0 100
setPen black
save
scale 0.9 0.9
setFont "sansserif" 10 normal
drawText 0 20 "scaled sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawText 0 40 "scaled sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawText 0 60 "scaled sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawText 0 80 "scaled sansserif 10pt, bold italic"
restore
translate 200 200
setPen black
save
scale -1 -1
setFont "sansserif" 10 normal
drawStaticText 0 20 "flipped sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawStaticText 0 40 "flipped sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawStaticText 0 60 "flipped sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawStaticText 0 80 "flipped sansserif 10pt, bold italic"
restore
translate -200 20
setPen black
save
translate 200 90
rotate 185
setFont "sansserif" 10 normal
drawText 0 20 "rotated sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawText 0 40 "rotated sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawText 0 60 "rotated sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawText 0 80 "rotated sansserif 10pt, bold italic"
restore
translate 0 100
gradient_appendStop 0 red
gradient_appendStop 0.5 #00ff00
gradient_appendStop 1 blue
gradient_setLinear 0 0 200 0
setPen brush
setFont "sansserif" 10 normal
drawText 0 0 "gradient sansserif 10pt, normal"
setFont "sansserif" 12 normal
drawText 0 20 "gradient sansserif 12pt, normal"
setFont "sansserif" 12 bold
drawText 0 40 "gradient sansserif 12pt, bold"
setFont "sansserif" 10 bold italic
drawText 0 60 "gradient sansserif 10pt, bold italic"
restore
end_block
translate 250 0
drawText 25 640 "clipped to rectangle"
save
setPen #3f000000
setBrush nobrush
drawRect 20 0 100 620
setClipRect 20 0 100 620
setPen black
repeat_block text_drawing
restore
translate 150 0
drawText 25 640 "clipped to path"
save
path_moveTo clip 20 0
path_cubicTo clip 0 200 40 400 20 400
path_lineTo clip 30 620
path_lineTo clip 30 0
path_lineTo clip 40 0
path_lineTo clip 40 620
path_lineTo clip 120 620
path_lineTo clip 120 0
path_lineTo clip 20 0
setPen #3f000000
setBrush nobrush
drawPath clip
setClipPath clip
setPen black
repeat_block text_drawing
restore
translate 150 0
save
setPen black
setFont "sansserif" 10 normal
drawText 0 20 "testing glyph cache textures"
# Important that this gradient doesn't match any earlier
# gradients, so that it's not cached from before.
gradient_clearStops
gradient_appendStop 0 blue
gradient_appendStop 0.5 #00ff00
gradient_appendStop 1 red
gradient_setLinear 0 0 100 0
setPen nopen
drawRect 0 30 100 20
setPen black
drawText 0 70 "testing glyph cache textures"
restore
translate 0 75
save
setPen black
setFont "sansserif" 16 normal
drawText 0 40 "e😃m😇o😍j😜i😸!✈️"
restore
translate 0 75
save
setPen black
setFont "sansserif" 12 normal normal default underline
drawText 0 20 "Underlined text drawing"
restore
translate 0 35
save
setPen black
setFont "sansserif" 12 normal normal default normal strikeout
drawText 0 20 "Struck out text drawing"
restore
translate 0 35
save
setPen black
setFont "sansserif" 12 normal normal default normal normal overline
drawText 0 20 "Overlined text drawing"
restore
translate 0 35
save
setPen black
setFont "sansserif" 12 normal normal default underline strikeout overline
drawText 0 20 "All the effects text drawing"
restore