# HG changeset patch # User sam # Date 1722692722 -25200 # Node ID a6a80b78e811ead155a5ce37fbd7c924ef246bdb # Parent ad3c6cad7d190b915723550db996c937124ae467 del: font name not required in struct diff -r ad3c6cad7d19 -r a6a80b78e811 semicongine/text.nim --- 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 diff -r ad3c6cad7d19 -r a6a80b78e811 semicongine/text/font.nim --- 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