Proportional-spaced fonts with accent marks
[1/9] from: louisaturk:eudoramail at: 5-May-2002 0:03
Hi rebols,
I am working to create an interlinear Greek-English book from a Greek
book. I plan to use 3 scripts to do this. The first script simply puts a
duplicate paragraph under each paragraph in the book. The second script
searches through the resulting file for each Greek word and does 2 things:
(1) in the bottom line, it replaces that Greek word with the appropriate
English word, and (2) adjusts the spacing of the top line (if necessary) so
that the top Greek words stay over the proper English word. The third
script will break the top and bottom lines in the proper places, and (if I
can figure out how to do it) justify the lines while keeping the Greek and
English words properly aligned.
The first script is trivial provided rebol can process fonts with accent
marks. Can it? The third script I will worry about later.
The second script would be rather simple if I could use fixed-space Greek
letters without accent marks, but I at least need the accent marks. This
is why I have been interested in Unicode, but, Rebol doesn't yet support
Unicode, and I am needing to get on with the project. Also, I am beginning
to think unicode isn't the answer anyway. Perhaps I just need to learn a
little more about fonts so that I can use the proportional-spaced Greek
font with accent marks that the Greek book file was created with. This
would make the finished interlinear much more compact and nicer looking.
The problem is how to line up the words when the letters vary in width and
sometimes are an extra byte long because of the accent information.
Can someone tell me how to do this, or point me to a book or article
somewhere that explains it? Is it extremely difficult?
Is rebol suitable for this project? If not, what language would be
best? I can program in C if I have to, but programming in C is so slow for
me, and I haven't used C for a long time. I would really prefer to use
rebol.
Are there any not-so-obvious problems any of you see that I might encounter
while doing this project?
Thanks,
Louis
[2/9] from: louisaturk:eudoramail at: 5-May-2002 2:18
At 12:03 AM 5/5/2002 -0500, I wrote:
>Hi rebols,
>I am working to create an interlinear Greek-English book from a Greek
<<quoted lines omitted: 7>>
>can figure out how to do it) justify the lines while keeping the Greek and
>English words properly aligned.
For what it is worth, I forgot to say that I plan to print the resultant
file to pdf format using the Notabene Lingua Workstation word
processor. But I am wondering if perhaps pdf-maker.r would be an easier
solution? Again, any guidance from you pros will be appreciated.
Louis
[3/9] from: carl::cybercraft::co::nz at: 5-May-2002 22:10
Hi Louis,
On 05-May-02, Dr. Louis A. Turk wrote:
> Hi rebols,
> I am working to create an interlinear Greek-English book from a
<<quoted lines omitted: 10>>
> The first script is trivial provided rebol can process fonts with
> accent marks. Can it?
Some with accent marks yes, though whether they cover the full Greek
alphabet I wouldn't know. Anyway, the following prints out each
character of your default font from the space character to character
255...
for n 32 255 1 [prin to-char n]
> The third script I will worry about later.
> The second script would be rather simple if I could use fixed-space
<<quoted lines omitted: 9>>
> width and sometimes are an extra byte long because of the accent
> information.
Is this for printing out or for displaying on screen? If for printing
out you could perhaps have a tab for every word in each matched line
and line them up that way, though as I almost never send stuff to a
printer these days others will have to tell you how to do this, if
it's feasable.
As to on screen, there's a 'size-text word in View that returns the
size of text in a face. Using that on each word in your text for
lining them up is one posible way to do it. Here's an example...
rebol []
line1: ["Let's" "see" "if" "we" "can" "line" "up" "words..."]
line2: []
foreach word line1 [
new-word: copy ""
foreach letter word [
append new-word to-char to-integer letter + 128
]
if 3 > random 4 [append new-word "x"]
append line2 new-word
]
line-tabs: [0]
for n 1 8 1 [
layout [origin 1x1 word1: text line1/:n font [size: 16]]
layout [origin 1x1 word2: text line2/:n font [size: 18]]
word-w: max first size-text word1 first size-text word2
append line-tabs 6 + word-w + last line-tabs
]
view layout [
origin 0x0
space 0x0
tabs line-tabs
across
style tex text font [size: 16]
tex line1/1 tab tex line1/2 tab tex line1/3
tab tex line1/4 tab tex line1/5 tab tex line1/6
tab tex line1/7 tab tex line1/8
return
style tex text font [size: 18]
tex line2/1 tab tex line2/2 tab tex line2/3
tab tex line2/4 tab tex line2/5 tab tex line2/6
tab tex line2/7 tab tex line2/8
]
That creates two blocks of words, with the second one being the words
converted to the Randomalians language. (: They're then compared for
length to get the longest of each matching pair and these values are
then used as tabs in the layout. They line them up for me - I hope
you get the same results! (Was quite fun working this out:)
My biggest worry with this approach is you'll be making an awful lot
of faces, (one per word in your book), just to get their length.
However, if this is for on-screen display you'll only have to do it
once as you'll be able to store the tab spacing along with the
paragraphs to your book.
I hope this is of some help. It sounds an interesting project.
> Can someone tell me how to do this, or point me to a book or article
> somewhere that explains it? Is it extremely difficult?
<<quoted lines omitted: 4>>
> Are there any not-so-obvious problems any of you see that I might
> encounter while doing this project?
PS: Just seen your second post mentioning it is to be printed out. (:
But anyway, lining up tabs like I've done in View may be the way to
go for printing it out too. But someone else will have to tell you
how to get the widths of the words for printing them - unless
multiplying the tabs by a constant value would be accurate enough to
convert their pixel-width to the printer tabs...
--
Carl Read
[4/9] from: rotenca:telvia:it at: 5-May-2002 14:47
Hi Carl,
> My biggest worry with this approach is you'll be making an awful lot
> of faces, (one per word in your book), just to get their length.
You can always use the same faces:
layout [
word1: text no-wrap font-size 16
word2: text no-wrap font-size 18
]
for n 1 8 1 [
word1/text: line1/:n
word2/text: line2/:n
word-w: max first size-text word1 first size-text word2
append line-tabs 6 + word-w + last line-tabs
]
--------
Ciao
Romano
[5/9] from: greggirwin:mindspring at: 5-May-2002 9:11
Hi Louis,
<< I am working to create an interlinear Greek-English book from a Greek
book. >>
like most non-trivial tasks, just take it a step at a time. The scripts may
end up being small, but you don't want to try figuring all the elements out
with them intertwined. You have 3 clear tasks laid out, so see if you can
get each of those working and then integrate them.
The first task will be straight-forward. The other two strike me as having a
soft
element to them (i.e. some empirical heuristics) which will govern
how they behave. That makes them a little more involved. Not that the coding
will be harder, but you have other design elements to consider.
--Gregg
[6/9] from: carl:cybercraft at: 6-May-2002 19:30
Thanks Romano - that's nice. I didn't realise text faces were quite
that dynamic as I'm used to having to set aside space for them in a
layout to stop them being trimed when they're viewed.
On 06-May-02, Romano Paolo Tenca wrote:
> Hi Carl,
>> My biggest worry with this approach is you'll be making an awful
<<quoted lines omitted: 11>>
> append line-tabs 6 + word-w + last line-tabs
> ]
--
Carl Read
[7/9] from: louisaturk:eudoramail at: 7-May-2002 3:47
Hi Carl, Romano, and Greg,
Many thanks for the help! You guys never cease to amaze me.
I'm having to do some traveling, so can't program for a few days. I have
more questions, but I want to play around with your code before asking
them. Also, almost all my code so far has used Core only, so I need to
study View a little (a lot! :>))
One question, however, I will ask now. Can Rebol manipulate unicode
characters provided it doesn't have to print them to screen or paper? Or
is this just not possible at all yet?
Also, would pdf-maker.r be of any help in this project?
Thanks again,
Louis
At 07:30 PM 5/6/2002 +1200, you wrote:
[8/9] from: carl:cybercraft at: 7-May-2002 22:17
On 07-May-02, Dr. Louis A. Turk wrote:
> One question, however, I will ask now. Can Rebol manipulate unicode
> characters provided it doesn't have to print them to screen or
> paper? Or is this just not possible at all yet?
I know next to nothing about unicode, but assuming you're just dealing
with the Greek unicode characters, you could perhaps have a
lookup-table of the two (or more?) bytes that represent each of the
characters. You could then single out the characters from a
binary-string of unicode by using that lookup-table (or parse-rules)
to do what you wish with them.
And if you could grab each character's image from somewhere you could
print them to screen (as images - not text) too...
--
Carl Read
[9/9] from: greggirwin:mindspring at: 7-May-2002 10:07
Hi Louis,
<< Can Rebol manipulate unicode characters provided it doesn't have to print
them to screen or paper? Or is this just not possible at all yet? >>
Probably only as binary data, which might not be much fun.
<< Also, would pdf-maker.r be of any help in this project? >>
I would say so. I'm not sure about adding fonts, as I haven't done that, but
writing out PDF is a good, portable solution.
--Gregg
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted