Mercurial > games > semicongine
changeset 341:6cc16b62e497
did: small font improvments
author | Sam <sam@basx.dev> |
---|---|
date | Fri, 08 Sep 2023 00:34:24 +0700 |
parents | 01ccd1393e7f |
children | 8c67f67b62fb |
files | src/semicongine/renderer.nim src/semicongine/text.nim tests/test_font.nim |
diffstat | 3 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine/renderer.nim Fri Sep 08 00:05:19 2023 +0700 +++ b/src/semicongine/renderer.nim Fri Sep 08 00:34:24 2023 +0700 @@ -66,7 +66,9 @@ if scene.usesMaterial(materialName): for input in pipeline.inputs: if found.contains(input.name): - assert input == found[input.name], &"{input} != {found[input.name]}" + assert input.name == found[input.name].name, &"{input.name} != {found[input.name].name}" + assert input.theType == found[input.name].theType, &"{input.theType} != {found[input.name].theType}" + assert input.arrayCount == found[input.name].arrayCount, &"{input.arrayCount} != {found[input.name].arrayCount}" else: result.add input found[input.name] = input
--- a/src/semicongine/text.nim Fri Sep 08 00:05:19 2023 +0700 +++ b/src/semicongine/text.nim Fri Sep 08 00:34:24 2023 +0700 @@ -82,8 +82,10 @@ proc `text=`*(textbox: var Textbox, text: seq[Rune]) = textbox.text = text textbox.updateMesh() +proc `text=`*(textbox: var Textbox, text: string) = + `text=`(textbox, text.toRunes) -proc initTextbox*(maxLen: int, font: Font, text=toRunes("")): Textbox = +proc initTextbox*(maxLen: int, font: Font, text="".toRunes): Textbox = var positions = newSeq[Vec3f](int(maxLen * 4)) indices: seq[array[3, uint16]] @@ -103,3 +105,6 @@ ) result.updateMesh() + +proc initTextbox*(maxLen: int, font: Font, text=""): Textbox = + initTextbox(maxLen=maxLen, font=font, text=text.toRunes)
--- a/tests/test_font.nim Fri Sep 08 00:05:19 2023 +0700 +++ b/tests/test_font.nim Fri Sep 08 00:34:24 2023 +0700 @@ -6,7 +6,7 @@ proc main() = var font = loadFont("DejaVuSans.ttf", color=newVec4f(1, 0.5, 0.5, 1), resolution=20) - var textbox = initTextbox(32, font, "".toRunes) + var textbox = initTextbox(32, font, "") var scene = Scene(name: "main") scene.add textbox textbox.mesh.transform = scale(0.01, 0.01)