mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
wasm: support vendor:stb/truetype and vendor:fontstash
This commit is contained in:
Vendored
+3
-17
@@ -1,14 +1,14 @@
|
||||
//+build windows, linux, darwin
|
||||
//+vet !using-param
|
||||
package fontstash
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
import "core:log"
|
||||
import "core:os"
|
||||
import "core:mem"
|
||||
import "core:math"
|
||||
import "core:strings"
|
||||
import "core:slice"
|
||||
|
||||
import stbtt "vendor:stb/truetype"
|
||||
|
||||
// This is a port from Fontstash into odin - specialized for nanovg
|
||||
@@ -321,20 +321,6 @@ __AtlasAddWhiteRect :: proc(ctx: ^FontContext, w, h: int) -> bool {
|
||||
return true
|
||||
}
|
||||
|
||||
AddFontPath :: proc(
|
||||
ctx: ^FontContext,
|
||||
name: string,
|
||||
path: string,
|
||||
) -> int {
|
||||
data, ok := os.read_entire_file(path)
|
||||
|
||||
if !ok {
|
||||
log.panicf("FONT: failed to read font at %s", path)
|
||||
}
|
||||
|
||||
return AddFontMem(ctx, name, data, true)
|
||||
}
|
||||
|
||||
// push a font to the font stack
|
||||
// optionally init with ascii characters at a wanted size
|
||||
AddFontMem :: proc(
|
||||
@@ -1192,4 +1178,4 @@ EndState :: proc(using ctx: ^FontContext) {
|
||||
}
|
||||
__dirtyRectReset(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
//+build !js
|
||||
package fontstash
|
||||
|
||||
import "core:log"
|
||||
import "core:os"
|
||||
|
||||
AddFontPath :: proc(
|
||||
ctx: ^FontContext,
|
||||
name: string,
|
||||
path: string,
|
||||
) -> int {
|
||||
data, ok := os.read_entire_file(path)
|
||||
|
||||
if !ok {
|
||||
log.panicf("FONT: failed to read font at %s", path)
|
||||
}
|
||||
|
||||
return AddFontMem(ctx, name, data, true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user