This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Meoco's profile picture

Font control?

Started by Meoco, 14 April 2012 - 03:50 AM
Meoco #1
Posted 14 April 2012 - 05:50 AM
Hey, this may be a sort of dumb question, but I haven't been able to find a solid answer anywhere: How do you (can you?) control font size and color within a program?
Luanub #2
Posted 14 April 2012 - 05:55 AM
I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
kamnxt #3
Posted 14 April 2012 - 09:16 AM
I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
You can control monitor font size by using:

monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor
monitor.setTextScale(5) -- Change this to a number from 1 to 5
monitor.setCursorPos(1,1)
monitor.write("BIG!")
haskell911 #4
Posted 08 July 2012 - 12:23 PM
I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
You can control monitor font size by using:

monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor
monitor.setTextScale(5) -- Change this to a number from 1 to 5
monitor.setCursorPos(1,1)
monitor.write("BIG!")
how to center and add more lines of words plz respond
nobody1717 #5
Posted 29 December 2012 - 02:57 PM
I don't think this is possible in a CC terminal. The only text you can control to my knowledge is the text on a monitor.
You can control monitor font size by using:

monitor = peripheral.wrap("side") -- Side must be the side where you have a monitor
monitor.setTextScale(5) -- Change this to a number from 1 to 5
monitor.setCursorPos(1,1)
monitor.write("BIG!")
how to center and add more lines of words plz respond
do you mean how to make the text centered? to do that, just use term.setCursorPos(x,y) you will have to figure what the x and y are.
remiX #6
Posted 29 December 2012 - 10:27 PM
monitorSide = "left"
mon = peripheral.wrap(monitorSide)
mX, mY = mon.getSize()

function monWriteCen(text, y)
    mon.setCursorPos((#text-mX)/2, y)
    mon.write(text)
end

--[[
    To change the size of text on monitors (only works
    on monitors), you use setTextScale(scale) where scale
    rangers from 0.5 - 5, increments of 0.5. Changing it
    where ever will change the text of the WHOLE monitor,
    meaning you cannot have separate parts with different
    sizes.
--]]

monitor.setTextScale(1.5) -- Set the text size to 1.5

monWriteCen("This is centered on the 3rd line!", 3) -- Custom function to center text on a specefic line.

--[[
    Remember:
    Do not make the text too long or else it will
    be cut off!
--]]

diegodan1893 #7
Posted 30 December 2012 - 12:29 AM
You can change the color in gold computers with term.setTextColor(colors.red) and term.setBackgroundColor(colors.white)
k9aaron888 #8
Posted 19 April 2013 - 04:53 AM
How do you write a sentence on a monitor? I need to know for my map.
Skampi #9
Posted 19 April 2013 - 05:44 AM
How do you write a sentence on a monitor? I need to know for my map.
You can simply do that by:

m = peripheral.wrap("side") --Picking the monitor as the peripheral m
m.setCursorPos(x, y) --replace x and y with the place you want to start at
m.write("Hello, this is a sentence") --replace everything you want wihin the " "

Helpful enough? :)/>
theoriginalbit #10
Posted 19 April 2013 - 06:09 AM
How do you write a sentence on a monitor? I need to know for my map.
You can simply do that by:

m = peripheral.wrap("side") --Picking the monitor as the peripheral m
m.setCursorPos(x, y) --replace x and y with the place you want to start at
m.write("Hello, this is a sentence") --replace everything you want wihin the " "

Helpful enough? :)/>
However doing it this way does not wrap characters and you cannot use characters such as '\n'
To do this you need to redirect the terminal so that the write (and inherently print) can do word wrapping for you, this is how to do it

m = peripheral.wrap("side") --Picking the monitor as the peripheral m
term.redirect(m) -- set the term object to the monitor
term.setCursorPos(x, y) -- this no longer interacts with the terminal, but instead the monitor
write("Hello, this is a sentence\n") -- this will be written to the monitor (with word wrapping) and append an new line, if we were using m.write it would put a ? in place of the new line.
print("Hello again") -- this will print the text to the monitor with wrapping and move to a new line
term.restore() -- restores the term api back to the main terminal
Skampi #11
Posted 19 April 2013 - 06:18 AM
How do you write a sentence on a monitor? I need to know for my map.
You can simply do that by:

m = peripheral.wrap("side") --Picking the monitor as the peripheral m
m.setCursorPos(x, y) --replace x and y with the place you want to start at
m.write("Hello, this is a sentence") --replace everything you want wihin the " "

Helpful enough? :)/>
However doing it this way does not wrap characters and you cannot use characters such as '\n'
To do this you need to redirect the terminal so that the write (and inherently print) can do word wrapping for you, this is how to do it

m = peripheral.wrap("side") --Picking the monitor as the peripheral m
term.redirect(m) -- set the term object to the monitor
term.setCursorPos(x, y) -- this no longer interacts with the terminal, but instead the monitor
write("Hello, this is a sentence\n") -- this will be written to the monitor (with word wrapping) and append an new line, if we were using m.write it would put a ? in place of the new line.
print("Hello again") -- this will print the text to the monitor with wrapping and move to a new line
term.restore() -- restores the term api back to the main terminal

Okay, good to know. :)/>