Date: Tue, 14 Jun 2011 00:34:39 +0800
Reply-To: Murphy Choy <goladin@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Murphy Choy <goladin@GMAIL.COM>
Subject: Re: Can one determine pixel length of a string?
In-Reply-To: <BANLkTim_YSKHz38uUvmCWstkPZ99a-xDGQ@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Not sure whether this might be useful.
http://en.wikipedia.org/wiki/Point_%28typography%29
http://hsivonen.iki.fi/units/
http://answers.yahoo.com/question/index?qid=20070723201114AAzsYjC
On Tue, Jun 14, 2011 at 12:07 AM, Joe Matise <snoopy369@gmail.com> wrote:
> I played around with excel a bit, and don't seem to find an easily used
> method for that in excel. WIDTHX doesn't exist, and I don't see a way to
> find that out. In addition, it seems that due to font kerning you don't
> even get identical results from the same character in two different
> strings...
>
> I suppose you could try windows API calls to determine font length (you
> have
> to first call SETCURRENTFONT, then GetCharABCWidths), or if 'close enough'
> was good enough you could FCMP your own function using the input method
> above pretty easily - but you would have to determine the font's character
> by character width first.
>
> I have no experience calling Windows APIs in SAS, but from what I've read
> in
> the past it's possible... this page:
> http://support.microsoft.com/kb/94646
> has more information on the API elements itself (though it dates back to
> Windows 3.1, it seems to be current).
>
> -Joe
>
> On Mon, Jun 13, 2011 at 10:57 AM, Arthur Tabachneck <art297@rogers.com
> >wrote:
>
> > Joe,
> >
> > You are probably right, but I still want to find a solution I can
> automate.
> > One often finds table looking data on the web. For example, the
> following
> > text, if converted to the Arial 12 bold font with which it was actually
> > displayed, it will appear like well formatted table:
> >
> > Ethnic Category Mean Household Income
> > White alone $65,317
> > Black $40,685
> > Hispanic or Latino $45,871
> > Asian alone $76,747
> >
> > If one copies the table from the web, pastes it into word, prints the
> > document to a file using Adobe Acrobat, and then uses Acrobat's table
> > select
> > tool to copy the resulting table, it can be imported into SAS with no
> > problem.
> >
> > I'm just looking for a more direct approach,
> > Art
> >
> > On Mon, 13 Jun 2011 10:19:53 -0500, Joe Matise <snoopy369@GMAIL.COM>
> > wrote:
> >
> > >The problem is SAS doesn't necessarily know what font something is
> > intended
> > >to be displayed in. In VB(A), the program is looking at a character
> that
> > is
> > >currently being displayed (specifically, it contains font information as
> > >part of the cell/etc. object). SAS doesn't have any awareness of the
> font
> > >something is displayed in, other than the font SAS intends to use to
> print
> > >out results in, right?
> > >
> > >I'm not sure if there is a WIDTH(character, font) function, which would
> > >probably be the closest to what you'd want. I imagine you could
> trivially
> > >create one via an informat, though. Figure out what font they used when
> > >they defined the columns, either download a list of widths of characters
> > or
> > >use said WIDTHX function in excel and create a simple table with all 128
> > >basic characters (or however many you may potentially need) in excel and
> > >import that into SAS, then you have your informat ready to go... then I
> > >guess you read in character by character and keep a running total of the
> > >font length :)
> > >
> > >-Joe
> > >
> > >On Mon, Jun 13, 2011 at 10:13 AM, Arthur Tabachneck
> > <art297@rogers.com>wrote:
> > >
> > >> Joe,
> > >>
> > >> Yes, I'm sure it does. I'm looking for a SAS equivalent to VB's
> > WIDTH(x$)
> > >> function which determines the width in pixels of any text string (x$)
> in
> > >> the
> > >> current font.
> > >>
> > >> Art
> > >> ------
> > >> On Mon, 13 Jun 2011 10:03:53 -0500, Joe Matise <snoopy369@GMAIL.COM>
> > >> wrote:
> > >>
> > >> >Doesn't that rather depend on the font being used to display the
> text?
> > >> >
> > >> >-Joe
> > >> >
> > >> >On Mon, Jun 13, 2011 at 10:02 AM, Arthur Tabachneck
> > >> <art297@rogers.com>wrote:
> > >> >
> > >> >> In trying to import some table-looking files, I discovered that the
> > >> columns
> > >> >> are only fixed length in terms of how many pixels wide each column
> > >> consumes
> > >> >> on
> > >> >> one's monitor. Is there a way to capture that in SAS such that one
> > >> could
> > >> >> say
> > >> >> that a field is between, say, pixel 1 and pixel 300?
> > >> >>
> > >> >> Art
> > >> >>
> > >>
> >
>
--
Regards,
Murphy Choy
Certified Advanced Programmer for SAS V9
Certified Basic Programmer for SAS V9
DataShaping Certified SAS Professional
|