×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On 18-Mar-2015 17:42 -0500, James H. H. Lampert wrote:
<<SNIP>> determine the set-width of a
character string, in the font in which it is presented.
There are numerous fields that have too little space on the page to
accommodate the full field length, in which I'm applying variable
horizontal scaling, based on the RPG %LEN(%TRIM()) of the field.
They'd work a lot better if I could calculate the horizontal scaling
from the actual set-width.
One of those fields, in addition, is one where it would be nice if,
for values that take up less than the available space even without
horizontal scaling, I could accurately center the value (which of
course can't be done without knowing the set-width.
Surely I'm not the first one in this position?
FWiW, I recall very clearly that there was at least one prior topic
[maybe a language-specific forum] here discussing how one might
determine the width of a given string using a proportional font. I
recall mostly, because there was a second discussion within a year or
two for which I had thought to direct the author to the prior topic that
had offered information about obtaining the width information for a
string [from an effective API call], but upon re-reading the original
discussion I could not find any such implication... as if perhaps I had
imagined the possibility :-( or perhaps I had followed up on some
tidbits offered whereupon I stumbled-on but did not post any followup
reply about what I had found.?.? I feel somewhat less daft for having
thought that there was an API, after finding a comment in a reply to
"Vern... I had a vague recollection of an API that would retrieve the
font widths also." from
<
http://archive.midrange.com/midrange-l/201309/msg00235.html>
<
https://www.google.com/search?q=%22width%22+%22font%22+%22variable%22+site%3Aarchive.midrange.com>
<
http://archive.midrange.com/midrange-l/201309/msg00221.html>
Centering with proportional font
<
http://archive.midrange.com/midrange-l/200308/msg00857.html>
center/line wrap w/variable width fonts
AFP Variable Width Font Text Alignment -- RPG400-L (unanswered)
<
http://archive.midrange.com/rpg400-l/200605/msg00071.html>
Print overlay -- RPG400-L
From that search, another topic that may be of interest, if changing
the font to achieve desired results:
<
http://archive.midrange.com/midrange-l/200907/msg00853.html>
Within the thread of the first message linked above [under the web
search] are the following two messages which look at least somewhat
promising with regard to an API-like approach:
<
http://archive.midrange.com/midrange-l/201309/msg00253.html>
"... QGYOLAFP might be the API you were thinking of to interrogate font
widths. Never used it myself, but format HPCS0100 might be the one.
<
http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Fapis%2Fqgyolafp.htm>"
<
http://archive.midrange.com/midrange-l/201309/msg00236.html>
"...
Looking at the Java
documentation the getLayout method of TextMeasurer returns a TextLayout
object. And TextLayout has a getBounds method that returns a Rectangle2D.
<
http://docs.oracle.com/javame/config/cdc/opt-pkgs/api/agui/jsr209/java/awt/font/TextLayout.html>
<
http://docs.oracle.com/javame/config/cdc/opt-pkgs/api/agui/jsr209/java/awt/font/TextMeasurer.html>"
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.