Difference between revisions of "HexText"

From Second Life Wiki
Jump to navigation Jump to search
 
(60 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== About ==
== About ==


HexText is an LSL script to display Unicode text on 8 faced prims within Second Life. Supported is included for Japanese/Chinese, as well as many other languages  and symbols. It is not all-inclusive There are some code pages that are missing. It does cover the majority of characters that avatars use in Unicode enhanced display names. Emojis that are outside of the first 256 Unicode code pages, are not included.
[[File:HexText_Sample_Display.png]]


There are two display scripts. One is optimized for general usage, the other is optimized for Japanese/Chinese.
HexText is an LSL script to display Unicode text on 8 faced prims within Second Life. Support is included for Japanese/Chinese, as well as many other languages  and symbols. It is not all-inclusive. There are some code pages that are missing. It does cover the majority of characters that avatars use in Unicode enhanced display names.


The primary font used is Google's Noto Monospace (Bold & Regular), supplemented with other open source or public domain fonts for code pages not covered by Noto.
The primary font used is Google's Noto Monospace (Bold & Regular), supplemented with other open source or public domain fonts for code pages not covered by Noto.


The character set is broken up into individual textures for each supported Unicode code page, each texture a 16 x 16 matrix of characters. To minimize texture memory usage, the majority of textures are rendered at 512 x 256 pixels (Kanji is rendered at 512 x 384 which gets reduced to 512 x 256 at upload.)
The character set is broken up into ~113 individual textures for each supported Unicode code page, covering roughly 28,000 characters. Each texture is a 16 x 16 matrix of characters. To minimize texture memory usage, the majority of textures are rendered at 512 x 256 pixels. Kanji is rendered at 512 x 384 which gets reduced to 512 x 256 at upload. As the textures are 512 x 256, it takes 8 of them to equal the amount of GPU texture memory used by a single 1024 x 1024 texture. I have found that unless you are displaying Kanji, it is rare to use more memory than 2 - 1024 x 1024 textures.


== Acknowledgments ==
== Acknowledgments ==


HexText uses a subset of the [[FURWARE_text/Reference]] command set. HexText does not support virtual text boxes or touch queries.
Thanks go to Ochi Wolfe for his excellent [[FURWARE_text]] display sytem and documentation. Without his, and his contributors efforts, HexText would have been significantly more difficult to create.
 
HexText is released under the MIT license.
 
HexText uses a subset of the [[FURWARE_text/Reference]] command set. HexText does not support virtual text boxes, inline styles or touch queries.
 
HexText can use displays set up by the [[FURWARE_text/Tutorial#Creating_displays]], however it can only use the 8 faced prim displays. HexText uses display prims with the same description format used by FURWARE text. HexText only supports a single display set per linkset, unlike FURWARE text that can handle multiple displays per linkset.  


The HexText texture set was created with [[FURWARE_text/TextureCreator]].
The HexText texture set was created with [[FURWARE_text/TextureCreator]].


HexText can use displays set up by the [[FURWARE_text#Texture_creator]], however it can only use the 8 faced prim displays. HexText uses display prims with the same description format used by FURWARE. HexText only supports a single display set per linkset, unlike FURWARE that can handle multiple displays per linkset.  
Use of both HexText and the FURWARE text scripts in the same linkset is not recommended.
 
Although it is technically possible to combine the FURWARE text engine, and HexText to create a Unicode display system with the features of both, I was concerned that it would not fit in a single script, and would therefore suffer performance issues.
 
== Setup ==
 
The following was taken from the FURWARE text manual, edited to remove limitations imposed by HexText. All credit for FURWARE text tools to Ochi Wolfe and his contributors. Hexadeci Mole is only responsible for the alternative HexText Unicode display script, textures and its documentation.
 
=== Creating displays ===
 
HexText uses displays created with the FURWARE text display creator available here: https://marketplace.secondlife.com/p/FURWARE-text/141379
 
You may (and should) use the "'''FURWARE display creator'''" to have a perfectly aligned grid of display prims automatically created for you. Every prim will be automatically assigned a special object name that is used internally by the text script so that it knows how to order them correctly, independently of the link order.
 
Creating a display is simple:
 
* Rez the display creator on a parcel where you have sufficient permissions.
* Touch the creator object. A dialog appears where you can set some parameters of the new display:
** A '''name''' for the display. You will use this name to identify which display you wish to manipulate when using multiple displays within one linkset.
** The number of '''rows and columns''' of the display (the columns are counted in prims here, not in characters).
** The number of '''faces per prim'''. There are mesh prims from 1 to 8 faces available. HexText can only use the 8 face display prims.
* When you're happy with the settings, click "Create" to start rezzing the prims. Link them to your creation as appropriate. (I would not recommend that any display prim be link #1 in a linkset)
 
=== Setup and initialization ===
 
When you have created your display and linked it together with your creation,  put '''a single copy''' of the HexText Script (listed below) into the linkset instead of the FURWARE text script. The script does '''not''' have to be in the root prim.
 
'''Important hint:'''
 
You may wish to send some initial commands to the text script as soon as its initialization is done. A reset of the text script may happen in a number of cases:
 
* The script was just put into the object.
* The object in which the script resides was shift-copied.
* The linkset has changed (then the script needs to search for display prims again).
* The script was reset manually (for instance using the "fw_reset" command).
 
In order to know when exactly the script is ready to take commands, it sends a link message to the whole set with the "id" parameter set to "fw_ready". It is '''good practice''' to watch for these messages and send your initialization commands when receiving this message. Your code could look something like this:
 
 
<source lang="lsl2">
link_message(integer sender, integer num, string str, key id) {
    if (id == "fw_ready") {
        // Set your default color, alignment, wrapping, trim, etc.
        llMessageLinked(sender, 0, "c=red;a=center;w=word", "fw_conf");
        // If your default display is not blank, send the default text
        llMessageLinked(sender, 0, "Default text", "fw_data");
 
        // ...
    }
}
</source>
 
=== LSL Script ===
 
Previously, there were 2 variations of the script. One that rendered Kanji characters on 2 prim faces, and another version that used 1 face for all characters. They have been combined, and one script can do both. In the combined version of the script, the '''k''' configuration option can be used to switch between 1 face and 2 face Kanji rendering.
 
Do not use the FURWARE text script in the same linkset that this script occupies.
 
* 2XKanji Script (LSL Mono): [[HexText/HexText_2XKanji]]


Use of both HexText and the FURWARE scripts in the same linkset is not recommended.
== Reference Manual ==


== Supported commands ==
Commands supported in HexText (a subset of the FURWARE text command set.)


=== Commands ===
=== Commands ===


The following commands can be issued from other scripts in your linkset to control HexText.
==== fw_data ====
==== fw_data ====
Display a string on the screen. The entire screen is overwritten with the text message. If you wish to only overwrite a portion of the display, consider fw_direct.


<source lang="lsl2">
<source lang="lsl2">
llMessageLinked(LINK_SET, 0, "Some text to draw.",   "fw_data");
llMessageLinked(LINK_SET, 0, "Some text to draw.", "fw_data");
</source>
</source>
==== fw_direct ====
This command is not supported by FURWARE text. It is unique to HexText to display text at specific display coordinates. It does not erase the display when called, instead, it overwrites existing characters in the display. Trim is ignored with fw_direct.
<source lang="lsl2">
llMessageLinked(LINK_SET, 0, "Some text to draw.", "fw_direct:10:2");
</source>
Display the string "Some text to draw." starting at the 11th column, 3rd row (Column/Row numbering starts at 0.)


==== fw_conf & fw_defaultconf ====
==== fw_conf & fw_defaultconf ====


Sets global style preferences. Unlike FURWARE, fw_conf is treated the same as fw_default_conf.
Sets the global style preference for the display. Unlike FURWARE text, fw_conf is treated the same as fw_defaultconf.


<source lang="lsl2">
<source lang="lsl2">
llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_conf");
llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_defaultconf");
llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_defaultconf");
llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_conf");
</source>
</source>
The three variants set the global style preferences for all boxes, all root-boxes and all non-root boxes.


==== fw_notify ====
==== fw_notify ====


Enable or disable link message notifications when the script has done rendering. Off by default.
Enable or disable link message notifications when the script has completed rendering. Off by default.


<source lang="lsl2">
<source lang="lsl2">
Line 49: Line 124:
</source>
</source>


When notifications are enabled, the text script will send a link message with "id" set to "fw_done" to the whole linkset to let you know when all pending rendering actions have been completed.
A link message will be sent to the linkset after rendering is complete with the key value of "fw_done"


==== fw_memory ====
==== fw_memory ====
Line 66: Line 141:
llMessageLinked(LINK_SET, 0, "", "fw_reset");
llMessageLinked(LINK_SET, 0, "", "fw_reset");
</source>
</source>
A link message will be sent to the linkset after reset is complete with the key value of "fw_ready"


=== Style settings ===
=== Style settings ===
Line 75: Line 152:
Multiple settings are separated by "''';'''", for example '''c=red; a=center; w=none'''.
Multiple settings are separated by "''';'''", for example '''c=red; a=center; w=none'''.


In the following table: ''Italic'' = Default
In the following table: '''Bold''' = Default


{|{{Prettytable}}
{|{{Prettytable}}
Line 101: Line 178:
|
|
| (predefined)
| (predefined)
| Predefined color, see table below
| Predefined color, see table below (default is White)
|-
|-
| Alignment
| Alignment
| a
| a
| ''left''
| '''left'''
| Alignment left
| Alignment left
|-
|-
Line 120: Line 197:
| Wrapping
| Wrapping
| w
| w
| ''word''
| '''word'''
| Wrap after words, if possible
| Wrap after words, if possible
|-
|-
Line 135: Line 212:
| Trimming
| Trimming
| t
| t
| ''on''
| '''on'''
| Trims whitespace from beginning and end of lines
| Trims whitespace from beginning and end of lines
|-
|-
Line 141: Line 218:
|
|
| off
| off
| Keeps whitespace (except with wrap=word)
| Keeps whitespace
|-
| 2X Kanji
| k
| on
| Use 2 prim faces for Kanji characters
|-
|
|
| '''off'''
| Use 1 prim face for all characters
|-
|-
| Force refresh
| Force refresh
Line 150: Line 237:
|
|
|
|
| ''off''
| '''off'''
| Disables forced refresh of all faces (enables optimizations)
| Disables forced refresh of all faces (enables optimizations)
|}
|}
Line 158: Line 245:
You may use the following names in place of color vectors in styles.
You may use the following names in place of color vectors in styles.


<table border="0" cellspacing="4" cellpadding="8" style="border:black solid 1px;">
<tr>
<td style="background:#FF0000; color:black; text-align:center;">red</td>
<td style="background:#00FF00; color:black; text-align:center;">green</td>
<td style="background:#0000FF; color:white; text-align:center;">blue</td>
<td style="background:#00FFFF; color:black; text-align:center;">cyan</td>
<td style="background:#FF00FF; color:black; text-align:center;">magenta</td>
<td style="background:#FFFF00; color:black; text-align:center;">yellow</td>
<td style="background:#FFFFFF; color:black; text-align:center;">white</td>
<td style="background:#C0C0C0; color:white; text-align:center;">silver</td>
</tr>
<tr>
<td style="background:#800000; color:white; text-align:center;">darkred</td>
<td style="background:#008000; color:white; text-align:center;">darkgreen</td>
<td style="background:#000080; color:white; text-align:center;">darkblue</td>
<td style="background:#008080; color:white; text-align:center;">darkcyan</td>
<td style="background:#800080; color:white; text-align:center;">darkmagenta</td>
<td style="background:#808000; color:white; text-align:center;">darkyellow</td>
<td style="background:#000000; color:white; text-align:center;">black</td>
<td style="background:#808080; color:white; text-align:center;">gray</td>
</tr>
</table>
== Version History ==
=== Version 1.0 ===
* Initial release.
=== Version 1.1 ===
* Switched to the easier to follow version of Strife's unicode decoder.
* Combined the General and 2XKanji versions of the script into a single script.
* Added the option of turning 2XKanji on and off with fw_conf.
* Memory optimizations to try and prevent stack-heap collisions with long paragraphs.
* Many small optimizations to improve rendering speed.


[[File:FURWARE_text_colors.png]]
== Bugs ==
Probably a lot. Let Hexadeci Mole know.

Latest revision as of 08:56, 26 December 2020

About

HexText Sample Display.png

HexText is an LSL script to display Unicode text on 8 faced prims within Second Life. Support is included for Japanese/Chinese, as well as many other languages and symbols. It is not all-inclusive. There are some code pages that are missing. It does cover the majority of characters that avatars use in Unicode enhanced display names.

The primary font used is Google's Noto Monospace (Bold & Regular), supplemented with other open source or public domain fonts for code pages not covered by Noto.

The character set is broken up into ~113 individual textures for each supported Unicode code page, covering roughly 28,000 characters. Each texture is a 16 x 16 matrix of characters. To minimize texture memory usage, the majority of textures are rendered at 512 x 256 pixels. Kanji is rendered at 512 x 384 which gets reduced to 512 x 256 at upload. As the textures are 512 x 256, it takes 8 of them to equal the amount of GPU texture memory used by a single 1024 x 1024 texture. I have found that unless you are displaying Kanji, it is rare to use more memory than 2 - 1024 x 1024 textures.

Acknowledgments

Thanks go to Ochi Wolfe for his excellent FURWARE_text display sytem and documentation. Without his, and his contributors efforts, HexText would have been significantly more difficult to create.

HexText is released under the MIT license.

HexText uses a subset of the FURWARE_text/Reference command set. HexText does not support virtual text boxes, inline styles or touch queries.

HexText can use displays set up by the FURWARE_text/Tutorial#Creating_displays, however it can only use the 8 faced prim displays. HexText uses display prims with the same description format used by FURWARE text. HexText only supports a single display set per linkset, unlike FURWARE text that can handle multiple displays per linkset.

The HexText texture set was created with FURWARE_text/TextureCreator.

Use of both HexText and the FURWARE text scripts in the same linkset is not recommended.

Although it is technically possible to combine the FURWARE text engine, and HexText to create a Unicode display system with the features of both, I was concerned that it would not fit in a single script, and would therefore suffer performance issues.

Setup

The following was taken from the FURWARE text manual, edited to remove limitations imposed by HexText. All credit for FURWARE text tools to Ochi Wolfe and his contributors. Hexadeci Mole is only responsible for the alternative HexText Unicode display script, textures and its documentation.

Creating displays

HexText uses displays created with the FURWARE text display creator available here: https://marketplace.secondlife.com/p/FURWARE-text/141379

You may (and should) use the "FURWARE display creator" to have a perfectly aligned grid of display prims automatically created for you. Every prim will be automatically assigned a special object name that is used internally by the text script so that it knows how to order them correctly, independently of the link order.

Creating a display is simple:

  • Rez the display creator on a parcel where you have sufficient permissions.
  • Touch the creator object. A dialog appears where you can set some parameters of the new display:
    • A name for the display. You will use this name to identify which display you wish to manipulate when using multiple displays within one linkset.
    • The number of rows and columns of the display (the columns are counted in prims here, not in characters).
    • The number of faces per prim. There are mesh prims from 1 to 8 faces available. HexText can only use the 8 face display prims.
  • When you're happy with the settings, click "Create" to start rezzing the prims. Link them to your creation as appropriate. (I would not recommend that any display prim be link #1 in a linkset)

Setup and initialization

When you have created your display and linked it together with your creation, put a single copy of the HexText Script (listed below) into the linkset instead of the FURWARE text script. The script does not have to be in the root prim.

Important hint:

You may wish to send some initial commands to the text script as soon as its initialization is done. A reset of the text script may happen in a number of cases:

  • The script was just put into the object.
  • The object in which the script resides was shift-copied.
  • The linkset has changed (then the script needs to search for display prims again).
  • The script was reset manually (for instance using the "fw_reset" command).

In order to know when exactly the script is ready to take commands, it sends a link message to the whole set with the "id" parameter set to "fw_ready". It is good practice to watch for these messages and send your initialization commands when receiving this message. Your code could look something like this:


link_message(integer sender, integer num, string str, key id) {
    if (id == "fw_ready") {
        // Set your default color, alignment, wrapping, trim, etc.
        llMessageLinked(sender, 0, "c=red;a=center;w=word", "fw_conf");
         // If your default display is not blank, send the default text
        llMessageLinked(sender, 0, "Default text", "fw_data");

        // ...
    }
}

LSL Script

Previously, there were 2 variations of the script. One that rendered Kanji characters on 2 prim faces, and another version that used 1 face for all characters. They have been combined, and one script can do both. In the combined version of the script, the k configuration option can be used to switch between 1 face and 2 face Kanji rendering.

Do not use the FURWARE text script in the same linkset that this script occupies.

Reference Manual

Commands supported in HexText (a subset of the FURWARE text command set.)

Commands

The following commands can be issued from other scripts in your linkset to control HexText.

fw_data

Display a string on the screen. The entire screen is overwritten with the text message. If you wish to only overwrite a portion of the display, consider fw_direct.

llMessageLinked(LINK_SET, 0, "Some text to draw.", "fw_data");

fw_direct

This command is not supported by FURWARE text. It is unique to HexText to display text at specific display coordinates. It does not erase the display when called, instead, it overwrites existing characters in the display. Trim is ignored with fw_direct.

llMessageLinked(LINK_SET, 0, "Some text to draw.", "fw_direct:10:2");

Display the string "Some text to draw." starting at the 11th column, 3rd row (Column/Row numbering starts at 0.)

fw_conf & fw_defaultconf

Sets the global style preference for the display. Unlike FURWARE text, fw_conf is treated the same as fw_defaultconf.

llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_conf");
llMessageLinked(LINK_SET, 0, "c=red; a=center", "fw_defaultconf");

fw_notify

Enable or disable link message notifications when the script has completed rendering. Off by default.

llMessageLinked(LINK_SET, 0, "on", "fw_notify");
llMessageLinked(LINK_SET, 0, "off", "fw_notify");

A link message will be sent to the linkset after rendering is complete with the key value of "fw_done"

fw_memory

Tells the owner how much memory is available.

llMessageLinked(LINK_SET, 0, "", "fw_memory");

fw_reset

Performs a full reset on the text script.

llMessageLinked(LINK_SET, 0, "", "fw_reset");

A link message will be sent to the linkset after reset is complete with the key value of "fw_ready"

Style settings

Text styles and format settings are specified using special strings. They are used for global settings ("fw_conf").

A single setting is given as a key=value pair, for example c=red.

Multiple settings are separated by ";", for example c=red; a=center; w=none.

In the following table: Bold = Default

Setting Key Values Description
Font color c R,G,B Font color as red, green, blue (each in range 0.0-1.0)
R,G,B,A Font color as red, green, blue, alpha (each in range 0.0-1.0)
rand Random color (with alpha = 1)
(predefined) Predefined color, see table below (default is White)
Alignment a left Alignment left
center Alignment centered
right Alignment right
Wrapping w word Wrap after words, if possible
char Wrap at any position
none No wrapping; cuts overlong lines
Trimming t on Trims whitespace from beginning and end of lines
off Keeps whitespace
2X Kanji k on Use 2 prim faces for Kanji characters
off Use 1 prim face for all characters
Force refresh force on Enables forced refresh of all faces (disables optimizations!)
off Disables forced refresh of all faces (enables optimizations)

Predefined colors

You may use the following names in place of color vectors in styles.

red green blue cyan magenta yellow white silver
darkred darkgreen darkblue darkcyan darkmagenta darkyellow black gray

Version History

Version 1.0

  • Initial release.

Version 1.1

  • Switched to the easier to follow version of Strife's unicode decoder.
  • Combined the General and 2XKanji versions of the script into a single script.
  • Added the option of turning 2XKanji on and off with fw_conf.
  • Memory optimizations to try and prevent stack-heap collisions with long paragraphs.
  • Many small optimizations to improve rendering speed.

Bugs

Probably a lot. Let Hexadeci Mole know.