Skip to content
ExamplesOpen editor ↗

kgaoloMokwalo

→ textWrap()

Chooses whether text breaks between words or between letters.

kgaoloMokwalo(style) | kgaoloMokwalo()

LEFOKO (the default) breaks only at spaces — words are kept whole. If a single word is longer than the box, it runs outside it.

TLHAKA breaks wherever it must to keep the text inside the box, even if that splits a word in the middle.

It only does anything when the box has a width. thalaMokwalo(words, x, y) wraps nothing; thalaMokwalo(words, x, y, 200) wraps.

TLHAKA is a letter — a letter of the alphabet. The break happens at any character, not only at letters; the name takes the word a learner already knows rather than letshwao, which is also the name of char.

NameTypeDescription
mokgwa (optional)seeloLEFOKO or TLHAKA.
The same text, two kinds of break
tiro setaLoeto() {
  thalaKanefase(400, 300);
  bokamorago(240);
  bogoloJwaMokwalo(18);
  sebakaSaMela(22);

  metlha mafoko = 'Ngwana yo o sa lleng o swela tharing';

  tlogelaGoTlatsa();
  mothaloMmala(200, 200, 210);
  thalaKhutlonne(30, 30, 150, 110);
  thalaKhutlonne(30, 170, 150, 110);

  tlogelaMothalo();
  tlatsaMmala(30, 40, 60);

  kgaoloMokwalo(LEFOKO);
  thalaMokwalo(mafoko, 34, 50, 142);

  kgaoloMokwalo(TLHAKA);
  thalaMokwalo(mafoko, 34, 190, 142);

  tlhalosa('Mabokoso a mabedi a a nang le seane se le sengwe: la godimo le kgaogantswe kwa mafokong, la tlase kwa ditlhakeng.');
}

thalaMokwalo, sebakaSaMela, LEFOKO, TLHAKA