Origin Scripting Language
  • Basics
    • Syntax
    • Types
    • The Execution Loop
    • Defining Variables
      • Clone Objects (=)
      • References To Objects/Variables (@=)
    • Assignment Operators
    • Local Scoping
    • Typed Variables
  • Operators
    • Mathematical Usage
      • Addition Operator (+)
      • Subtraction Operator (-)
      • Divide Operator (/)
      • Multiply Operator (*)
      • To The Power Of (^)
      • Modulo Operator (%)
    • Text Usage
    • String Concatenation Operator (+)
    • Array Operations
    • Comparative Operators
    • Logical Operators
    • Bitwise operators
    • Pipe Operator (|>)
    • Nullish Coalescing Operator (??)
  • Program Flow
    • If Statements
      • if truthy (
      • ) else if truthy (
      • ) else (
      • )
    • Switch Case
    • Iteration
    • While And Until
    • Dynamic OSL Execution
  • Arrays And Objects
    • Making Arrays Or Objects
    • Modifying An Array
    • Clone Objects And References
    • Object Operations
    • Object Property Shorthand
  • Environment
    • The Window System
    • Mouse Cursor
    • Camera
    • Sound System
    • Input Simulation
    • Running Other Languages
    • Notifications
    • Send Data Between Windows
    • Interfacing With Rightclick
    • Permissions
    • Files
      • What is a file? (in ofsf)
      • Creating Directories
      • open("file_path")
      • fileGet(int)
      • listFiles()
  • Storage
    • Save DB
    • Local DB
  • Custom Syntax
    • Commands
    • Methods
    • Functions
    • Inline
    • Lambda
    • Spread Operator
    • Typed Parameters
    • Classes
    • Promises
  • External
    • Make An Iframe App
  • Commands
    • Debugging
      • log "hello world"
      • warn "you should change this"
      • error "something went wrong"
      • void expression
    • Rendering
      • Basics
        • Color Commands
        • Color Picker
        • Modifiers
      • Draw Cursor
        • goto x y
        • set_x x
        • set_y y
        • change_x x
        • change_y y
        • change x y
        • loc a b c d
      • Elements
        • Canvas
        • Rectangle
        • Triangle
        • Icon
        • Text
        • Image
        • Input
        • Pen
        • Hitbox
        • Bar
        • Slider
      • ICN (Icon System)
        • Drawing Commands
        • Dynamic Icons
      • Clipping And Scrolling (frames)
      • 3D Rendering
  • Functions
    • Math
      • Math()
      • random(low,high)
      • min(num1,num2)
      • max(num1,num2)
      • lcm(num1,num2)
      • gcd(num1,num2)
      • sum(num1,..)
      • average(num1,..)
      • dist(x1,y1,x2,y2)
      • degtorad(angle)
      • radtodeg(angle)
      • noise(x, y, z)
      • octaveNoise(x, y, z, octaves, persistence)
    • Types
      • typeof(value)
      • symbol(name)
    • Encoding
      • encodeURIComponent(string)
      • decodeURIComponent(string)
      • btoa/atob(string)
    • function()
    • formatFileSize(bytes)
    • getGamepads()
    • import(path)
    • ouidNew()
    • parseFilePath(path)
  • Global Variables
    • Overview
    • System Information
    • User Information
    • Date and Time
    • Input State
    • Display and UI
    • Network
    • File System
  • Methods
    • Strings
      • .padStart(num,val)
      • .padEnd(num,val)
      • .startsWith(val)
      • .endsWith(val)
      • .wrapText(characters)
      • .trimText(characters)
      • .split(characters)
      • .count(val)
      • .replace(old,new)
      • .replaceFirst(old,new)
      • .oslTokenise()
      • .strip()
      • .toOrdArray()
      • .match(pattern)
      • Encoding
        • .encodeBin()
        • .decodeBin()
        • .encodeHex()
        • .decodeHex()
        • .encodeUTF16()
        • .decodeUTF16()
        • .encrypt(password)
        • .decrypt(password)
        • .ord()
        • .chr()
      • Hashing
        • .hashMD5()
        • .hashSHA1()
        • .hashSHA256()
        • .hashSHA512()
      • Case
        • .toLower()
        • .toUpper()
        • .toMixed()
        • .toTitle()
    • Keyboard
      • .isKeyDown()
      • .onKeyDown()
    • Utilities
      • .len
      • .not
      • .ask()
      • .reverse()
      • .first()
      • .last()
      • .append(val)
      • .prepend(val)
      • .insert(location,val)
      • .delete(location)
      • .concat(val)
      • .trim(idx1,idx2)
      • .left(num)
      • .right(num)
      • .contains(val)
      • .index(val)
    • Maths
      • .abs()
      • .invabs()
      • .log()
      • .ln()
      • .isPrime()
      • .sqrt()
      • .sign()
      • .chance()
      • .clamp(low,high)
      • .toBase(base)
      • Rounding
        • .round(places)
        • .ceiling()
        • .floor()
      • Trigonometry
        • .sin
        • .cos
        • .tan
        • .asin()
        • .acos()
        • .atan()
        • .radSin()
        • .radCos()
    • Iframes
      • .iframeNew()
      • .iframeGoto()
      • .iframeResize()
      • .iframeRedirect()
      • .iframeShow()
      • .iframeHide()
      • .iframeClose()
    • JSON
      • Arrays
        • .pop()
        • .shift()
        • .randomOf()
        • .sort(direction)
        • .sortBy(key,direction)
        • .swap(idx1,idx2)
        • .fill(value)
        • .join(characters)
        • .map(callback)
        • .filter(callback)
        • .some(callback)
        • .every(callback)
      • Objects
        • .getKeys(keys)
        • .getValues()
      • .JsonStringify()
      • .JsonParse()
      • .JsonFormat()
      • .JsonClean()
    • Types
      • .getType()
      • .isType(type)
      • .toNum()
      • .toBool()
      • .toStr()
    • Functions
      • .bind(context)
    • Networking
      • .httpGet()
      • .http(method,data,headers)
      • .getAsync()
      • .roturConnect()
      • .roturSend(msg,target)
      • Websockets
        • .newWebsocket()
        • .wsSend(msg)
        • .wsClose()
        • .wsOpen()
        • .wsHasnew()
        • .wsGetnext()
        • .wsGetcount()
    • Timestamp
      • .timestamp("convert-date")
      • .timestamp("component")
Powered by GitBook
On this page
  • Command:
  • Parameters:
  • size:
  • text-to-draw:
  • Description:
  • Example:
  • Explanation:
  • Centering text
  • Centering Text
  • Using the Font System
  • Changing Line Height
  • Changing Character Spacing
  • Selecting a Font
  • Loading a Font from a URL
  • Reverting to Default Font
  • Practical Examples

Was this helpful?

Edit on GitHub
  1. Commands
  2. Rendering
  3. Elements

Text

Command:

text "text-to-draw" size

Parameters:

size:

Specifies the size of the text to be rendered.

text-to-draw:

The text string that needs to be displayed.

Description:

The text command displays the given text at the current cursor position, applying the specified size for rendering.

Example:

text "Hello, World!" 16
// Renders the text "Hello, World!" at the current draw cursor position with a font size of 16

Explanation:

In this example, the text "Hello, World!" is rendered at the current draw cursor position with a font size of 16. The text command allows for direct rendering of text strings on the screen.

Additionally, the text command can be used to set the font for subsequent text rendering by providing the URL or file path of a text file containing font data along with the setfont parameter. This command provides a simple and effective way to display text within the UI, allowing for customization of text appearance and font selection when needed.

Centering text

Centering Text

The centext command works similarly to the text command, but with the added functionality of centering the text on the draw cursor position. This command is beneficial for aligning text centrally within the UI component or screen area, ensuring a balanced and aesthetically pleasing visual arrangement. Like the text command, it allows for customization of font size and style.

centext "hello world" 10

Using the Font System

Changing Line Height

The line height can be adjusted using the configtext command with the lineheight parameter. The default line height is 23.

Example:

configtext "lineheight" 23
// Sets the line height to 23

Changing Character Spacing

The space between characters can be adjusted as a multiple of the size of the text using the configtext command with the spacing parameter.

Example:

configtext "spacing" 1
// Sets the spacing between characters to 1 times the size of the text

Selecting a Font

To select a font to use, use the configtext command with the usefont parameter and specify the font name.

Example:

configtext "usefont" "Llama"
// Selects the "Llama" font for text rendering

Loading a Font from a URL

To load a font from a URL, use the configtext command with the importfont parameter, specifying the font name and URL.

Example:

configtext "importfont" "CustomFont" "https://example.com/fonts/customfont.ojff"
// Loads the "CustomFont" from the specified URL

Reverting to Default Font

To revert to the default font, use the configtext command with the usedefault parameter.

Example:

configtext "usedefault"
// Reverts to the default font

Practical Examples

Rendering Text with Custom Font Size

To render text with a custom font size of 20:

text "Welcome to the system!" 20
// Renders the text "Welcome to the system!" with a font size of 20

Adjusting Line Height and Character Spacing

To set the line height to 30 and character spacing to 1.5 times the size of the text:

configtext "lineheight" 1.5
configtext "spacing" 1.5
// Sets the line height to 1.5x normal and character spacing to 1.5x the size of the text

Using a Custom Font

To use a custom font named "Roboto":

configtext "usefont" "Llama"
// Selects the "Llama" font for text rendering

Loading and Using a Font from a URL

To load a font from a URL and use it for rendering text:

configtext "importfont" "CoolFont" "https://example.com/fonts/coolfont.ojff"
configtext "usefont" "CoolFont"
// Loads the "CoolFont" from the specified URL and selects it for text rendering
PreviousIconNextImage

Last updated 10 days ago

Was this helpful?