From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/64994 Path: news.gmane.org!not-for-mail From: Peter Rolf Newsgroups: gmane.comp.tex.context Subject: kerning info (mkiv) Date: Fri, 07 Jan 2011 14:48:32 +0100 Message-ID: <4D2719B0.1090103@gmx.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040900000800090006080901" X-Trace: dough.gmane.org 1294408132 939 80.91.229.12 (7 Jan 2011 13:48:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 Jan 2011 13:48:52 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Jan 07 14:48:46 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PbCgO-0002mj-LR for gctc-ntg-context-518@m.gmane.org; Fri, 07 Jan 2011 14:48:44 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 14896CA9EE; Fri, 7 Jan 2011 14:48:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id NYorEnbANqak; Fri, 7 Jan 2011 14:48:41 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 01796CA99E; Fri, 7 Jan 2011 14:48:40 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 126BACA99E for ; Fri, 7 Jan 2011 14:48:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Rgi0l53UBN6b for ; Fri, 7 Jan 2011 14:48:38 +0100 (CET) Original-Received: from filter2-til.mf.surf.net (filter2-til.mf.surf.net [194.171.167.218]) by balder.ntg.nl (Postfix) with ESMTP id 07FCACA998 for ; Fri, 7 Jan 2011 14:48:38 +0100 (CET) Original-Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.23]) by filter2-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with SMTP id p07DmaaH008161 for ; Fri, 7 Jan 2011 14:48:37 +0100 Original-Received: (qmail invoked by alias); 07 Jan 2011 13:48:36 -0000 Original-Received: from ip-109-90-9-94.unitymediagroup.de (EHLO [192.168.178.3]) [109.90.9.94] by mail.gmx.net (mp027) with SMTP; 07 Jan 2011 14:48:36 +0100 X-Authenticated: #24293357 X-Provags-ID: V01U2FsdGVkX19tDykLI4Rtd//XBBRGft+uO2Ad6qYCEEd7VppP5h 8HXpNeKCj++Rr7 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Mnenhy/0.8.3 Thunderbird/3.1.7 X-Enigmail-Version: 1.1.1 X-Y-GMX-Trusted: 0 X-Bayes-Prob: 0.5 (Score 0, tokens from: ) X-CanIt-Geo: ip=213.165.64.23; country=DE; latitude=51.0000; longitude=9.0000; http://maps.google.com/maps?q=51.0000,9.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0bDQBMBqn - fcf461b2b644 - 20110107 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.218 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:64994 Archived-At: This is a multi-part message in MIME format. --------------040900000800090006080901 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, for a text background graphic I need the character box sizes of a given string. I managed to collect the needed info (width, height, depth, kerns), but there is still some flaw in the kerning part. For example: "VATo" is printed out (in the shell) as V 12 11 0 *kerning -85721.088 A 10 11 0 *kerning -64487.424 T 10 11 0 *kerning -64487.424 o 7 7 0 The character stands in the first column, followed by width, height and depth (in pixel). The "*kerning" line shows the kerning value (in sp) of the neighbouring character pair. No problem here. But "A much longer Test graphic VATo" A 12 11 0 5 0 0 m 13 7 0 *kerning -21233.664 u 8 7 0 c 7 7 0 *kerning -21233.664 h 8 11 0 5 0 0 l 4 11 0 o 7 7 0 n 9 7 0 g 8 7 3 e 7 7 0 r 6 7 0 5 0 0 T 11 11 0 e 7 7 0 s 6 7 0 t 6 10 0 5 0 0 g 8 7 3 r 6 7 0 a 8 7 0 p 9 7 3 h 8 11 0 i 4 10 0 c 7 7 0 5 0 0 V 12 11 0 A 12 11 0 T 11 11 0 o 7 7 0 sees no kerning for "VATo" (although the text is printed with the correct kerning). What am I missing? Example code is attached. Peter --------------040900000800090006080901 Content-Type: text/x-lua; name="box.lua" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="box.lua" -- http://lua-users.org/wiki/SimpleRound local function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end local function topixel(n) local dimenfactor = 1/49336 return n*dimenfactor end function foo_box(text) local s = text local tfmdata = fonts.ids[font.current()] if tfmdata then local characters = tfmdata.characters local char = { } local lastchar local u,width,height,depth,kerns for i= 1,string.len(s) do u = utf.byte(string.sub(s,i,i)) if not char[u] then width = characters[u].width or 0 height = characters[u].height or 0 depth = characters[u].depth or 0 if lastchar then kerns = characters[lastchar].kerns if kerns then kern= kerns[u] or 0 if not(kern==0) then print("*kerning",kern) end end else kern = 0 end char[u] = { w = round(topixel((width+kern))), h = round(topixel(height)), d = round(topixel(depth)) } end lastchar = u print(string.sub(s,i,i),char[u].w,char[u].h,char[u].d) end end end --------------040900000800090006080901 Content-Type: text/plain; name="box.tex" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="box.tex" XHJlZ2lzdGVyY3R4bHVhZmlsZXtib3h9ezAuMX0NCg0KXHN0YXJ0dGV4dA0KDQpcY3R4bHVh e2Zvb19ib3goIkEgbXVjaCBsb25nZXIgVGVzdCBncmFwaGljIFZBVG8iKX0NCg0KXGN0eGx1 YXtmb29fYm94KCJWQVRvIil9DQpcc3RvcHRleHQNCg== --------------040900000800090006080901 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --------------040900000800090006080901--