| Deutsch English Français Italiano |
|
<m5WdnT5nxKH9a4_6nZ2dnZfqn_udnZ2d@earthlink.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 18 Oct 2024 23:59:28 +0000
Subject: Re: The joy of Typography
Newsgroups: alt.folklore.computers,comp.os.linux.misc
References: <vd8doi$15q07$1@dont-email.me>
<kMedne0I3JBuxmL7nZ2dnZfqnPgLyJ2d@earthlink.com>
<slrnvgdhcc.2nfc6.candycanearter07@candydeb.host.invalid>
<ve6pfp$2p1hd$8@dont-email.me> <ve8612$33lq0$3@dont-email.me>
<ve9vga$3cbkr$4@dont-email.me> <mIdOO.204988$1m96.63811@fx15.iad>
<vec4l3$3q4ms$5@dont-email.me> <criOO.380449$WOde.297877@fx09.iad>
<20241014080601.00007478@gmail.com> <ln5gklF755tU4@mid.individual.net>
<38fb5a91-5d00-be42-4bfe-2a05232a82c1@example.net>
<ln7tooFijhpU2@mid.individual.net> <vemfq7$1qobu$5@dont-email.me>
<venqec$24hhj$2@dont-email.me>
<1420907830.750803935.503389.peter_flass-yahoo.com@news.eternal-september.org>
<veqh7f$19v5v$1@paganini.bofh.team> <20241017090224.000072ce@gmail.com>
<20241017203051.3143245f5330ac675cc1c166@127.0.0.1>
<WUqdndxzb5qBRoz6nZ2dnZfqnPGdnZ2d@earthlink.com>
<lne6rsFh72qU1@mid.individual.net> <vessel$35pc2$1@dont-email.me>
<x-CcneTnt5bXYoz6nZ2dnZfqnPWdnZ2d@earthlink.com>
<e0yQO.266441$v8v2.12196@fx18.iad> <veuj5h$3fkh5$3@dont-email.me>
From: 186282ud0s3 <186283@ud0s4.net>
Date: Fri, 18 Oct 2024 19:59:27 -0400
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
MIME-Version: 1.0
In-Reply-To: <veuj5h$3fkh5$3@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <m5WdnT5nxKH9a4_6nZ2dnZfqn_udnZ2d@earthlink.com>
Lines: 55
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 99.101.150.97
X-Trace: sv3-FXjJUOg9GqR9xetVaSslgjFnbiSU6X2eH0bQ4Z/1SOTDQ1B1fMJpAU5EDAJV0qS7yy2d57yReXjNyJ/!Ax/x1UzqDW1ezF9ZXprJdlKaCW1zw1Y55EQnO9N+PCAq07ZG6e8asfwzZ/L/Onv9O6M/jqw/o3zi!bOSeZKzwdqwTfWv+QE7d
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Bytes: 4315
On 10/18/24 5:15 PM, Lawrence D'Oliveiro wrote:
> On Fri, 18 Oct 2024 18:44:26 GMT, Charlie Gibbs wrote:
>
>> I wrote some routines to generate my columnar reports in PDF.
>> On the whole it worked fairly well, but I never found a way to
>> right-justify a field. Then it became a pain in the ass.
>
> You mean “right-align”, not “right-justify”. Here’s a routine that
> does alignment of text within a given line width, based on the current
> point, using the current font settings. It can do left-align,
> right-align, centre-align and anything in-between.
>
> def align_text(g, text_lines, line_width, align) :
> "renders the sequence of text_lines horizontally-aligned within line_width according" \
> " to align: 0 for left-aligned, 0.5 for centred, 1.0 for right-aligned; in-between" \
> " values also allowed. Returns the bounds of the rendered text."
> font_extents = g.font_extents
> bounds = Rect.empty
> for line in text_lines :
> save_pos = g.current_point
> extents = g.text_extents(line)
> if align != 0 :
> text_width = extents.width
> g.rel_move_to(((line_width - text_width) * align, 0))
> #end if
> bounds |= Rect(extents.x_bearing, extents.y_bearing, extents.width, extents.height) + g.current_point
> g.show_text(line)
> g.move_to(save_pos + Vector(0, font_extents.height))
> #end for
> return \
> bounds
> #end align_text
>
> That comes from the “text_align_justify” example in this repo
> <https://gitlab.com/ldo/qahirah_examples>.
>
Looks like it will work just fine.
Wanting to confine text
to a relatively
small bounded box
is not unusual at
all. Much easier
with fixed-point
fonts however.
But still, the FORTRAN "format" statement was
created with teletypes/pin-printers/terminals
in mind.
I wonder how much CPU goes into nothing but
displaying nice-looking proportional fonts
these days ?