Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minimal demonstration of wrapping problem with Chinese text
# Generated by OpenSesame 2.9.6 (Hesitant Heisenberg)
# Tue Aug 04 21:11:15 2015 (nt)
# <http://www.cogsci.nl/opensesame>
set background "black"
set bidi "no"
set canvas_backend "legacy"
set compensation "0"
set coordinates "relative"
set description "Default description"
set font_bold "no"
set font_family "chinese-japanese-korean"
set font_italic "no"
set font_size "40"
set foreground "white"
set height "768"
set keyboard_backend "legacy"
set mouse_backend "legacy"
set sampler_backend "legacy"
set start "experiment"
set subject_nr "0"
set subject_parity "even"
set synth_backend "legacy"
set title "Minimal Chinese Wrapping Demo"
set width "1024"
define sequence Chinese
run setTextZh "always"
run show "always"
define sequence English
run setTextEn "always"
run show "always"
define sequence experiment
run English "always"
run Chinese "always"
define inline_script setTextEn
set _prepare ""
set _run "longText = u'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'"
define inline_script setTextZh
set _prepare ""
___run__
# Taken from http://china.chinadaily.com.cn/2015-08/04/content_21500773.htm
longText = u'U+4E2DU+56FDU+7ECFU+6D4EU+73B0U+5B9EU+4E2DU+FF0CU+4E00U+4E9BU+770BU+4F3CU+77DBU+76FEU+7684U+5E02U+573AU+73B0U+8C61U+FF0CU+8BA9U+5B8FU+89C2U+8C03U+63A7U+7684U+51B3U+65ADU+66F4U+52A0U+8270U+96BEU+FF1AU+8D27U+5E01U+201CU+6C60U+5B50U+201DU+91CCU+7684U+6C34U+4E0DU+5C11U+FF0CU+4F46U+5F88U+591AU+5C0FU+5FAEU+4F01U+4E1AU+56E0U+4E3AU+878DU+8D44U+96BEU+3001U+878DU+8D44U+8D35U+800CU+201CU+55F7U+55F7U+558AU+6E34U+201DU+FF1BU+94A2U+94C1U+3001U+6C34U+6CE5U+3001U+5E73U+677FU+73BBU+7483U+7B49U+8FC7U+5269U+4EA7U+80FDU+4EE4U+4EBAU+5934U+75DBU+FF0CU+4F46U+5F88U+591AU+5730U+533AU+3001U+57CEU+5E02U+7684U+516CU+5171U+8BBEU+65BDU+548CU+516CU+5171U+670DU+52A1U+FF0CU+8FD8U+6709U+5F88U+5927U+63D0U+5347U+7A7AU+95F4U+3002'
__end__
define inline_script show
set _prepare ""
___run__
from openexp.canvas import canvas
from openexp.mouse import mouse
myCanvas = canvas(exp)
myMouse = mouse(exp)
# Let's put our text in the top-left corner, left-aligned with 100px margins
layout = {
'x': 100,
'y': 100,
'center': False,
'max_width': (myCanvas.xcenter() * 2) - 200
}
# Paint the canvas
myCanvas.clear()
myCanvas.text(longText, **layout)
myCanvas.show()
# Wait for click
myMouse.get_click()
__end__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment