changeset 1291:a6a80b78e811

del: font name not required in struct
author sam <sam@basx.dev>
date Sat, 03 Aug 2024 20:45:22 +0700
parents ad3c6cad7d19
children 5de466f5f087
files semicongine/text.nim semicongine/text/font.nim
diffstat 2 files changed, 2 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/text.nim	Thu Aug 01 00:06:54 2024 +0700
+++ b/semicongine/text.nim	Sat Aug 03 20:45:22 2024 +0700
@@ -10,7 +10,6 @@
     leftOffset*: float32
     advance*: float32
   FontObj* = object
-    name*: string
     glyphs*: Table[Rune, GlyphInfo]
     fontAtlas*: Image[Gray]
     maxHeight*: int
--- a/semicongine/text/font.nim	Thu Aug 01 00:06:54 2024 +0700
+++ b/semicongine/text/font.nim	Sat Aug 03 20:45:22 2024 +0700
@@ -23,10 +23,7 @@
   if stbtt_InitFont(addr fontinfo, indata.ToCPointer, 0) == 0:
     raise newException(Exception, "An error occured while loading font file")
 
-  result = Font(
-    name: name,
-    fontscale: float32(stbtt_ScaleForPixelHeight(addr fontinfo, cfloat(lineHeightPixels))),
-  )
+  result = Font(fontscale: float32(stbtt_ScaleForPixelHeight(addr fontinfo, cfloat(lineHeightPixels))))
 
   var ascent, descent, lineGap: cint
   stbtt_GetFontVMetrics(addr fontinfo, addr ascent, addr descent, addr lineGap)
@@ -113,16 +110,12 @@
 
 proc loadFont*(
   path: string,
-  name = "",
   lineHeightPixels = 80'f32,
   additional_codepoints: openArray[Rune] = [],
   charset = ASCII_CHARSET,
   package = DEFAULT_PACKAGE
 ): Font =
-  var thename = name
-  if thename == "":
-    thename = path.splitFile().name
-  loadResource_intern(path, package = package).readTrueType(thename, charset & additional_codepoints.toSeq, lineHeightPixels)
+  loadResource_intern(path, package = package).readTrueType(path.splitFile().name, charset & additional_codepoints.toSeq, lineHeightPixels)
 
 func textWidth*(text: seq[Rune], font: FontObj): float32 =
   var currentWidth = 0'f32