From owner-svn-src-all@freebsd.org Sun Mar 24 19:41:46 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B690315348F1; Sun, 24 Mar 2019 19:41:46 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 557B793CC3; Sun, 24 Mar 2019 19:41:46 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F5AE24D22; Sun, 24 Mar 2019 19:41:46 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2OJfkoA040630; Sun, 24 Mar 2019 19:41:46 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2OJfkLm040629; Sun, 24 Mar 2019 19:41:46 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201903241941.x2OJfkLm040629@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Sun, 24 Mar 2019 19:41:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345483 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 345483 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 557B793CC3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2019 19:41:47 -0000 Author: bde Date: Sun Mar 24 19:41:45 2019 New Revision: 345483 URL: https://svnweb.freebsd.org/changeset/base/345483 Log: Add support for arbitrary font widths. Only multiples of 8 were supported. Since the font format is undocumented, it is unclear how non-multiples of 8 should be padded to bytes in the font file. Use the same representation as bdf text format (big- endian, with padding in the lower bits). Modified: head/lib/libvgl/text.c Modified: head/lib/libvgl/text.c ============================================================================== --- head/lib/libvgl/text.c Sun Mar 24 19:29:30 2019 (r345482) +++ head/lib/libvgl/text.c Sun Mar 24 19:41:45 2019 (r345483) @@ -66,7 +66,7 @@ FILE *fd; VGLTextFont->BitmapArray = (byte*)malloc(256*((VGLTextFont->Width + 7)/8)*VGLTextFont->Height); fread(VGLTextFont->BitmapArray, 1, - (256*VGLTextFont->Width* VGLTextFont->Height), fd); + (256*((VGLTextFont->Width + 7)/8)*VGLTextFont->Height), fd); fclose(fd); } return 0; @@ -76,44 +76,48 @@ void VGLBitmapPutChar(VGLBitmap *Object, int x, int y, byte ch, byte fgcol, byte bgcol, int fill, int dir) { - int lin, bit; + int b, Bpc, Bpl, lin, bit, topbit; + Bpl = (VGLTextFont->Width + 7) / 8; + Bpc = Bpl * VGLTextFont->Height; + topbit = VGLTextFont->Width - 1; for(lin = 0; lin < VGLTextFont->Height; lin++) { for(bit = 0; bit < VGLTextFont->Width; bit++) { - if (VGLTextFont->BitmapArray[((ch*VGLTextFont->Height)+lin)]&(1<Width & 7); + if (VGLTextFont->BitmapArray[(ch*Bpc)+(lin*Bpl)+(b/8)]&(1<<(b%8))) switch (dir) { case 0: - VGLSetXY(Object, (x+7-bit), (y+lin), fgcol); + VGLSetXY(Object, (x+topbit-bit), (y+lin), fgcol); break; case 1: - VGLSetXY(Object, (x+lin), (y-7+bit), fgcol); + VGLSetXY(Object, (x+lin), (y-topbit+bit), fgcol); break; case 2: - VGLSetXY(Object, (x-7+bit), (y-lin), fgcol); + VGLSetXY(Object, (x-topbit+bit), (y-lin), fgcol); break; case 3: - VGLSetXY(Object, (x-lin), (y+7-bit), fgcol); + VGLSetXY(Object, (x-lin), (y+topbit-bit), fgcol); break; case 4: - VGLSetXY(Object, (x+lin+7-bit), (y+lin+bit), fgcol); + VGLSetXY(Object, (x+lin+topbit-bit), (y+lin+bit), fgcol); break; } else if (fill) switch (dir) { case 0: - VGLSetXY(Object, (x+7-bit), (y+lin), bgcol); + VGLSetXY(Object, (x+topbit-bit), (y+lin), bgcol); break; case 1: - VGLSetXY(Object, (x+lin), (y-7+bit), bgcol); + VGLSetXY(Object, (x+lin), (y-topbit+bit), bgcol); break; case 2: - VGLSetXY(Object, (x-7+bit), (y-lin), bgcol); + VGLSetXY(Object, (x-topbit+bit), (y-lin), bgcol); break; case 3: - VGLSetXY(Object, (x-lin), (y+7-bit), bgcol); + VGLSetXY(Object, (x-lin), (y+topbit-bit), bgcol); break; case 4: - VGLSetXY(Object, (x+lin+7-bit), (y+lin+bit), bgcol); + VGLSetXY(Object, (x+lin+topbit-bit), (y+lin+bit), bgcol); break; } }