<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.secondlife.com/w/index.php?action=history&amp;feed=atom&amp;title=XyText-UTF8_Gimp_Texture_Creation</id>
	<title>XyText-UTF8 Gimp Texture Creation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.secondlife.com/w/index.php?action=history&amp;feed=atom&amp;title=XyText-UTF8_Gimp_Texture_Creation"/>
	<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=XyText-UTF8_Gimp_Texture_Creation&amp;action=history"/>
	<updated>2026-05-10T07:00:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.secondlife.com/w/index.php?title=XyText-UTF8_Gimp_Texture_Creation&amp;diff=933392&amp;oldid=prev</id>
		<title>Salahzar Stenvaag: Created page with &#039;== A primer on UTF-8 encoding (for our needs with lsl and xytext handling) ==  Just a quick view of the UTF-8 encoding used by SecondLife. It is a very complete and smart way of ...&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.secondlife.com/w/index.php?title=XyText-UTF8_Gimp_Texture_Creation&amp;diff=933392&amp;oldid=prev"/>
		<updated>2010-05-31T10:23:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;== A primer on UTF-8 encoding (for our needs with lsl and xytext handling) ==  Just a quick view of the UTF-8 encoding used by SecondLife. It is a very complete and smart way of ...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A primer on UTF-8 encoding (for our needs with lsl and xytext handling) ==&lt;br /&gt;
&lt;br /&gt;
Just a quick view of the UTF-8 encoding used by SecondLife. It is a very complete and smart way of representing special characters.&lt;br /&gt;
&lt;br /&gt;
With normal characters such as &amp;#039;A&amp;#039;, UTF-8 is perfectly equivalent to ASCII encoding and both will use 1 byte (hexadecimal 41). For special or International characters, then UTF-8 is offering a unique translation which can be more than one byte.&lt;br /&gt;
&lt;br /&gt;
For instance if you take the char &amp;#039;ç&amp;#039;, this will translate (according to http://www.isthisthingon.org/unicode/index.php) in utf8 to: C3A7 (two bytes).&lt;br /&gt;
&lt;br /&gt;
You can also know this writing the following simple lsl script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
default&lt;br /&gt;
{    &lt;br /&gt;
    touch_start(integer total_number)&lt;br /&gt;
    {&lt;br /&gt;
        llSay(0, llEscapeURL(&amp;quot;ç&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
which is giving in chat&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[15:20]  Object: %C3%A7&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining the list of UTF8 characters to render and producing with GIMP ==&lt;br /&gt;
&lt;br /&gt;
I used the following trick to extend standard XyText font texture to accomodate new characters:&lt;br /&gt;
* Put 20 rows of characters instead of the 10 of xytext (we use a 512x1024 texture so we have the SAME quality as of XyText fonts!!!&lt;br /&gt;
This allows for 100 more characters added to the usual 100 base characters.&lt;br /&gt;
&lt;br /&gt;
So if you want to adapt this XyText-UTF8 engine to some other language you MUST find the UTF8 encoding for 100 chars you want to use and set up a python fu generating the texture.&lt;br /&gt;
&lt;br /&gt;
The extra 100 characters are defined by a vector of up to 100 elements encoded with UTF8 coding. I use the following python-fu script for gimp to produce a compatible texture for my boards: (you have to put it under .gimp/plug-ins and obviously enable python-fu for your gim.. This tested with gimp 2.4 and gimp 2.6).&lt;br /&gt;
&lt;br /&gt;
This script will appear under Filters-&amp;gt;XyText1CharE and when pressed you are asked for&lt;br /&gt;
* font to use (use a non proportional font like Monospace Bold Italic, which I feel it gives one of the best results)&lt;br /&gt;
* Color to use leave white default&lt;br /&gt;
* Font Size (best result with 42 points)&lt;br /&gt;
* limit font generation not used&lt;br /&gt;
&lt;br /&gt;
This sample produces Portuguese fonts. Note the use of a decode array, which mimics the same list used by subsequent lsl scripts in secondlife.&lt;br /&gt;
&lt;br /&gt;
It will show you the image with transparent background which you can save in .tga format and upload to secondlife (or opensim),&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
from gimpfu import *&lt;br /&gt;
&lt;br /&gt;
def python_log_init():&lt;br /&gt;
    fileHandle = open( &amp;#039;python.log&amp;#039;, &amp;#039;w&amp;#039;)&lt;br /&gt;
    fileHandle.close()&lt;br /&gt;
    &lt;br /&gt;
def python_log(s):&lt;br /&gt;
    fileHandle = open ( &amp;#039;python.log&amp;#039;, &amp;#039;a&amp;#039; )&lt;br /&gt;
    fileHandle.write(str(s)+&amp;quot;\n&amp;quot;)&lt;br /&gt;
    fileHandle.close() &lt;br /&gt;
&lt;br /&gt;
def python_xytext(font,color,size,limit):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;Print the arguments on standard output&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  python_log_init()&lt;br /&gt;
  python_log(&amp;quot;font: %s color: &amp;lt;%d,%d,%d&amp;gt; size: %d limit: %d&amp;quot; % ( font, color[0], color[1], color[2], size, limit ))&lt;br /&gt;
  chars = &amp;quot; !\&amp;quot;#$%&amp;amp;&amp;#039;()*+,-./0123456789:;&amp;lt;=&amp;gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~     &amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  decode=  [&amp;quot;\xC3\x87&amp;quot;, &amp;quot;\xC3\xBC&amp;quot;, &amp;quot;\xC3\xA9&amp;quot;, &amp;quot;\xC3\xA2&amp;quot;, &amp;quot;\xC3\xA4&amp;quot;, &amp;quot;\xC3\xA0&amp;quot;, &amp;quot;\xC3\xA5&amp;quot;, &amp;quot;\xC3\xA7&amp;quot;, &amp;quot;\xC3\xAA&amp;quot;, &amp;quot;\xC3\xAB&amp;quot; ]  &lt;br /&gt;
  decode+=[&amp;quot;\xC3\xA8&amp;quot;, &amp;quot;\xC3\xAF&amp;quot;, &amp;quot;\xC3\xAE&amp;quot;, &amp;quot;\xC3\xAC&amp;quot;, &amp;quot;\xC3\x84&amp;quot;, &amp;quot;\xC3\x85&amp;quot;, &amp;quot;\xC3\x89&amp;quot;, &amp;quot;\xC3\xA6&amp;quot;, &amp;quot;\xC3\xAE&amp;quot;, &amp;quot;\xE2\x96\xB6&amp;quot; ]&lt;br /&gt;
  decode+=[&amp;quot;\xC3\xB6&amp;quot;, &amp;quot;\xC3\xB2&amp;quot;, &amp;quot;\xC3\xBB&amp;quot;, &amp;quot;\xC3\xB9&amp;quot;, &amp;quot;\xC3\xBF&amp;quot;, &amp;quot;\xC3\x96&amp;quot;, &amp;quot;\xC3\x9C&amp;quot;, &amp;quot;\xC2\xA2&amp;quot;, &amp;quot;\xC2\xA3&amp;quot;, &amp;quot;\xC2\xA5&amp;quot;]&lt;br /&gt;
  decode+=[&amp;quot;\xC3\x82&amp;quot;, &amp;quot;\xC2\xA9&amp;quot;, &amp;quot;\xC3\xA1&amp;quot;, &amp;quot;\xC3\xAD&amp;quot;, &amp;quot;\xC3\xB3&amp;quot;, &amp;quot;\xC3\xBA&amp;quot;, &amp;quot;\xC3\xB1&amp;quot;, &amp;quot;\xC3\x91&amp;quot;, &amp;quot;\xC2\xAA&amp;quot;, &amp;quot;\xC2\xBA&amp;quot;]&lt;br /&gt;
  decode+=[&amp;quot;\xC2\xBF&amp;quot;, &amp;quot;\xC3\x94&amp;quot;, &amp;quot;\xC2\xAC&amp;quot;, &amp;quot;\xC2\xBD&amp;quot;, &amp;quot;\xC2\xBC&amp;quot;, &amp;quot;\xC2\xA1&amp;quot;, &amp;quot;\xC2\xAB&amp;quot;, &amp;quot;\xC2\xBB&amp;quot;, &amp;quot;\xCE\xB1&amp;quot;, &amp;quot;\xC3\x9F&amp;quot;]&lt;br /&gt;
  decode+=[&amp;quot;\xCE\x93&amp;quot;, &amp;quot;\xCF\x80&amp;quot;, &amp;quot;\xCE\xA3&amp;quot;, &amp;quot;\xCF\x83&amp;quot;, &amp;quot;\xC2\xB5&amp;quot;, &amp;quot;\xCF\x84&amp;quot;, &amp;quot;\xCE\xA6&amp;quot;, &amp;quot;\xCE\x98&amp;quot;, &amp;quot;\xCE\xA9&amp;quot;, &amp;quot;\xCE\xB4&amp;quot;]&lt;br /&gt;
  decode+=[&amp;quot;\xC5\xAC&amp;quot;, &amp;quot;\xC5\xAD&amp;quot;, &amp;quot;\xCE\xB5&amp;quot;, &amp;quot;\xE2\x88\xA9&amp;quot;, &amp;quot;\xE2\x89\xA1&amp;quot;, &amp;quot;\xC2\xB1&amp;quot;, &amp;quot;\xE2\x89\xA5&amp;quot;, &amp;quot;\xE2\x89\xA4&amp;quot;, &amp;quot; &amp;quot;, &amp;quot; &amp;quot;]&lt;br /&gt;
   &lt;br /&gt;
  decode+=[&amp;quot;\xC3\x81&amp;quot;, &amp;quot;\xC3\x80&amp;quot;, &amp;quot;\xC3\xA3&amp;quot;, &amp;quot;\xC3\x83&amp;quot;, &amp;quot;\xC3\x8A&amp;quot;, &amp;quot;\xC3\x8D&amp;quot;, &amp;quot;\xC3\x93&amp;quot;, &amp;quot;\xC3\xB5&amp;quot;, &amp;quot;\xC3\x95&amp;quot;, &amp;quot;\xC3\xB4&amp;quot; ];&lt;br /&gt;
 &lt;br /&gt;
  &lt;br /&gt;
  width=512&lt;br /&gt;
  height=1024&lt;br /&gt;
  img = gimp.Image(width, height, RGB)&lt;br /&gt;
  layer = gimp.Layer(img, &amp;quot;my font&amp;quot;, width, height, RGB_IMAGE, 100, NORMAL_MODE)&lt;br /&gt;
  img.add_layer(layer, 0)&lt;br /&gt;
  layer.add_alpha()&lt;br /&gt;
  gimp.set_foreground(color)&lt;br /&gt;
  pdb.gimp_selection_all(img)&lt;br /&gt;
  pdb.gimp_edit_clear(layer)&lt;br /&gt;
  pdb.gimp_selection_none(img)&lt;br /&gt;
  &lt;br /&gt;
  index=0&lt;br /&gt;
  extra=-1&lt;br /&gt;
  #pdb.gimp_text_fontname(img,layer,50,50,&amp;quot;\xC3\x87&amp;quot;,0,TRUE,size,PIXELS,font)&lt;br /&gt;
  try:&lt;br /&gt;
    for row in range(20):&lt;br /&gt;
       for col in range(10):&lt;br /&gt;
&lt;br /&gt;
          if extra&amp;lt;0:&lt;br /&gt;
             try:&lt;br /&gt;
                el=chars[index]&lt;br /&gt;
                index=index+1&lt;br /&gt;
             except:&lt;br /&gt;
                extra=0&lt;br /&gt;
          &lt;br /&gt;
          if extra&amp;gt;-1:&lt;br /&gt;
             el=decode[extra]&lt;br /&gt;
             extra=extra+1&lt;br /&gt;
          &lt;br /&gt;
             &lt;br /&gt;
&lt;br /&gt;
          python_log(str(row)+&amp;quot;,&amp;quot;+str(col)+&amp;quot;:  &amp;quot;+el)&lt;br /&gt;
                 &lt;br /&gt;
          y=col*51.2+12&lt;br /&gt;
          x=row*51.2+5&lt;br /&gt;
          pdb.gimp_text_fontname(img,layer,y,x,el,0,TRUE,size,PIXELS,font)&lt;br /&gt;
          &lt;br /&gt;
  except:&lt;br /&gt;
     pass&lt;br /&gt;
  &lt;br /&gt;
  # Now ready to display this image&lt;br /&gt;
  img.merge_visible_layers(0)&lt;br /&gt;
  gimp.Display(img)&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
register(&lt;br /&gt;
  &amp;quot;xytext&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;,&lt;br /&gt;
  &amp;quot;&amp;lt;Toolbox&amp;gt;/Xtns/_XyText1CharE&amp;quot;, &amp;quot;&amp;quot;,&lt;br /&gt;
  [&lt;br /&gt;
  (PF_FONT, &amp;quot;font&amp;quot;, &amp;quot;Font to use&amp;quot;, &amp;quot;Arial&amp;quot;),&lt;br /&gt;
  (PF_COLOR,&amp;quot;color&amp;quot;,&amp;quot;Color to use&amp;quot;, (255,255,255) ),&lt;br /&gt;
  (PF_INT,    &amp;quot;size&amp;quot;, &amp;quot;Font size&amp;quot;, 45          ),&lt;br /&gt;
  (PF_INT,  &amp;quot;limit&amp;quot;, &amp;quot;limit font generation &amp;quot;, 180          ),&lt;br /&gt;
 &lt;br /&gt;
  ],&lt;br /&gt;
  [],&lt;br /&gt;
  python_xytext&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
here the image produced: &lt;br /&gt;
[[Image: Portuguese-xytextutf8.jpg]]&lt;/div&gt;</summary>
		<author><name>Salahzar Stenvaag</name></author>
	</entry>
</feed>