Update to use the new font

This commit is contained in:
gamax92 2016-03-09 14:05:43 -07:00
parent 14c6d00b4d
commit bcb7a1ad6a
5 changed files with 15 additions and 15 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
src/lua
src/loot
src/unifont.hex
src/font.hex
src/tmpfs
log.txt

View File

@ -1,6 +1,6 @@
ASSETS=https://github.com/MightyPirates/OpenComputers/trunk/src/main/resources/assets/opencomputers
all: src/lua src/loot src/unifont.hex
all: src/lua src/loot src/font.hex
src/lua:
svn export $(ASSETS)/lua src/lua
@ -8,10 +8,10 @@ src/lua:
src/loot:
svn export $(ASSETS)/loot src/loot
src/unifont.hex:
svn export $(ASSETS)/unifont.hex src/unifont.hex
src/font.hex:
svn export $(ASSETS)/font.hex src/font.hex
clean:
rm -rf src/lua
rm -rf src/loot
rm -f src/unifont.hex
rm -f src/font.hex

View File

@ -44,7 +44,7 @@ luarocks-5.2 install luasec
luarocks-5.2 install --server=http://luarocks.org/dev luaffi
# OpenComputer's lua source code is not provided, if you have svn then use the provided Makefile
# If you hate svn, manually download assets/loot, assets/lua, and assets/unifont.hex into src/
# If you hate svn, manually download assets/loot, assets/lua, and assets/font.hex into src/
```
**Windows**

View File

@ -172,7 +172,7 @@ end
local char8 = ffi.new("uint32_t[?]", 8*16)
local char16 = ffi.new("uint32_t[?]", 16*16)
local function _renderChar(ochar)
char = unifont[ochar]
char = font[ochar]
local size,pchar = #char/16
if size == 2 then
pchar = char8
@ -197,7 +197,7 @@ local function _renderChar(ochar)
end
local function renderChar(char,x,y,fg,bg)
if unifont[char] == nil then
if font[char] == nil then
char = 63
end
if not charCache[char] then
@ -205,7 +205,7 @@ local function renderChar(char,x,y,fg,bg)
end
local br, bg, bb = extract(bg)
SDL.setRenderDrawColor(renderer, br, bg, bb, 255)
local dest = ffi.new("SDL_Rect",{x=x,y=y,w=#unifont[char]/4,h=16})
local dest = ffi.new("SDL_Rect",{x=x,y=y,w=#font[char]/4,h=16})
SDL.renderFillRect(renderer, dest)
if char~=32 then
SDL.setTextureColorMod(charCache[char], extract(fg))

View File

@ -274,15 +274,15 @@ setmetatable(env,{
end,
})
-- load unifont
unifont = {}
for line in elsa.filesystem.lines("unifont.hex") do
-- load font
font = {}
for line in elsa.filesystem.lines("font.hex") do
local a,b = line:match("(.+):(.*)")
unifont[tonumber(a,16)] = b
font[tonumber(a,16)] = b
end
function getCharWidth(char)
if unifont[char] ~= nil then
return #unifont[char] / 32
if font[char] ~= nil then
return #font[char] / 32
end
return 1
end