🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17440

need a sample which demonstrates changing font mid paragraph

#17440
From: maxhodges
Date: Thu, 12 Jun 2003 09:41
71 lines
3550 bytes
I'm generating a my pages entirely from a database using VB. In one
table that I generate, I use one font for an entry word, and another
font for the definition e.g.

1. TEXT IN ARIAL definition in times
2. TEXT2 IN ARIAL definition2 in times

I haven't been able to figure out how to do this in a more
straightforward manner. Can someone give me any tips? This code is
working, but it seems convoluted. I need to generate a different
table, that switched fonts several times (in order to insert some
windings) so a more direct and efficient solution would be greatly
appreciate. Here is what I have now. Notice that I create a table with
a row count of 7--I only need 6 rows, but if I set rowcount = 6, I
only get 5 rows (bug in indesign?):


            ' Draw textframe/table for compound defs
            tf = oPage.TextFrames.Add
            a(0) = 1.125
            a(1) = 0.25
            a(2) = a(0) + 1.1875
            a(3) = a(1) + 3
            tf.GeometricBounds = a
            Dim BackCompoundString As String

            For index = 0 To 5
                BackCompoundString = BackCompoundString & index + 1 &
"." & Me.Compounds(index).Hiragana & " " &
Me.Compounds(index).Definition & vbCr
            Next

            Debug.WriteLine(BackCompoundString)

            tf.TextContents = BackCompoundString
            For paraIndex = 0 To 5
                oPara = tf.Paragraphs.Item(paraIndex + 1)
                startPos = oPara.Characters.Item(1)
                endPos =
oPara.Characters.Item(Len(Me.Compounds(paraIndex).Hiragana) + 3)
                myChars = oPara.Characters.ItemByRange(startPos,
endPos).item(1)
                myChars.characterstyle =
oDocument.CharStyles.item("Definition Japanese")

                startPos =
oPara.Characters.Item(Len(Me.Compounds(paraIndex).Hiragana) + 3 + 1)
                endPos = oPara.Characters.Item(-1)
                myChars = oPara.Characters.ItemByRange(startPos,
endPos).item(1)
                myChars.characterstyle =
oDocument.CharStyles.item("Definition English")

                'oPara.AppliedFont = oFont
                oPara.PointSize = 10
                oPara.Justification = InDesign.idJustification.idLeft
            Next paraIndex
            tbl = tf.ParentStory.Tables.Add
            With tbl
                .ColumnCount = 1
                .RowCount = 7
            End With
            Call AdjustTableStroke(tbl, 0)
            For Each oCell In tbl.Cells
                With oCell
                    .TopInset = 0.0417
                    .BottomInset = 0.0417
                End With
            Next
            tf.Locked = True
            tf = Nothing
Technical Details
Message-ID: <6758a233.0306120141.75d21e32@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,d33b09b5910ee58d,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-06-12 02:41:56 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: maxhodges@hotmail.com (maxhodges)
Newsgroups: adobe.scripting.indesign
Subject: need a sample which demonstrates changing font mid paragraph
Date: 12 Jun 2003 02:41:55 -0700
Organization: http://groups.google.com/
Lines: 71
Message-ID: <6758a233.0306120141.75d21e32@posting.google.com>
NNTP-Posting-Host: 66.69.151.122
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1055410915 8801 127.0.0.1 (12 Jun 2003 09:41:55 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 12 Jun 2003 09:41:55 GMT