X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1372384090; bh=ksKg4DfCELMT/2585Pk9DJ87v8zHeAEJw7OzvPiT/bw=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=zA6368sQFdccDm+Dxvsw358AlmhhDb6Gru2iSJtK0Lztt4UMtQFjG1C0FHtCnwI4pr8e5lPAA0FqJQVXBLaXVFy3xvvnJpsFtJMHY5UD/x8gw2LRyFsjI3gAk0yrxOA9A5EWPnoNODSNneMbJvY1D6HUwwKoc07WLCNcv+Y9DiE= X-Yahoo-Newman-Id: 809354 DOT 13684 DOT bm AT smtp104 DOT sbc DOT mail DOT gq1 DOT yahoo DOT com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: hwCdlr0VM1lpw_DEDPUVvztGHgHxTtVLaGMaBf2Dfs2qBqD _iil2pbHrTqLmcrDFbsGaWDeVS_kClFQc65x2gpRm6epMjF5jabl98hy1yVL t22CAaZuQcc9QPhktzZJTHhIau31.RUa13HQNPn6Ggg.BFpuFnH5nML5ypIi weU1V_oxTXikpugQRRf99WhTuV_8k.ebvPMkeeKbxOW0NepD8XDKX7WucZss 8HpGx4dPoRLY3hweoHq9qYKktGGebg1B_YnM3Edwok0Rkm43N4BRZeGZ3weh CJY4SbMdcGnD4V0ZykUKMfSNGrlYnh0.4j1mcOO_w71HxbtXpO8kjSlhXQcE DvuA4J4alnxQIyq.pbEkIK7UBM.5yeaKljlxhNZyGQeOAIiQ_FX72CkMJnYo JJWPRIsfjX3n6OP92ty.I4fGWqXOXJkA20yFuH.cHBKq8SEp6Kk1o_.aTEcH r73dC44Ov6gxxWlVnam5iQRijUZElNPlk58gFEea4zjkv65NAcgUOCJ59MzB Kq9qjwo5A9dGkkJf1w9UBGlBeEdyCzcTJ9AtoxysThQCCfw6JFSPwBBpKJ6Z b_wGsnQmpDuasl7akeyWUdhhrMvZyXBWwJwVmrtDdH8sA6E0.1scfUxS70lG i5NqdtcxKkLKJF2a0EeXYbt7eaEo3GrIX9tyoOjYVDkB2I9Ahg1SYeOF62JO 1r8Q8iWPz121BEuS63Ag- X-Yahoo-SMTP: b8jVkbOswBAqZ4BhECp7nxPJUfTGEnEGv_G4qgQeZMeAbA-- X-Rocket-Received: from [192.168.1.66] (ehennes AT 71 DOT 138 DOT 169 DOT 160 with plain) by smtp104.sbc.mail.gq1.yahoo.com with SMTP; 27 Jun 2013 18:48:10 -0700 PDT Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: [geda-user] gschem cairo text measure From: Edward Hennessy In-Reply-To: <51CCD179.7010903@sonic.net> Date: Thu, 27 Jun 2013 18:48:10 -0700 Message-Id: <1E0F5AC4-88AB-4CCF-ABE3-439DBE79B907@sbcglobal.net> References: <51CCD179 DOT 7010903 AT sonic DOT net> To: geda-user AT delorie DOT com X-Mailer: Apple Mail (2.1508) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id r5S1mEc5022199 Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Jun 27, 2013, at 4:57 PM, Dave Curtis wrote: > I'm working on a symbol generator, and trying to match up text width measurement with gschem. I've dug into the gschem code a little, and gschem seems to use Cairo these days. I'm not very familiar with Cairo, but I've managed to come up with something that appears to work, but it relies heavily on a magic number that I arrived at empirically. > > What is the correct way to match up text measurement? > > Here is what I have: > > class FontInfo(object): > _gschemScalingConstant = 10000.0/555.0 # Magic number > def __init__(self): > blah blah blah > def measure(self, aString): > "Returns the layout length of aString in gschem distance." > if self._csf == None: > self._build_csf() > width = self._csf.text_extents(aString)[2] # item 2 of extents is Cairo 'width' > return width > def _build_csf(self): > "Builds and caches a Cairo Scaled Font." > fontFace = cr.ToyFontFace(self.name) # default is Arial > identityMatrix = cr.Matrix() > fontOptions = cr.FontOptions() # get defaults > scaling = self.size * self._gschemScalingConstant # 'size' is gschem font size from 'T' line > scalingMatrix = cr.Matrix(xx = scaling, yy = scaling) > self._csf = cr.ScaledFont(fontFace, scalingMatrix, > identityMatrix, fontOptions) > > Peter Clifton's name is all over the Cairo commits, but I see he hasn't posted to the list for about a week, so I'm guessing he's on holiday. Any help appreciated. > > -dave > Dave, When I worked on text rendering, I wound up with a couple magic numbers too: http://git.geda-project.org/gparts/tree/src/schgui-cairo-text.c I looked through the code and could not find the magic constant to make the text match up with the legacy renderer. Cheers, Ed