Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2007
    Posts
    348

    Unanswered: two fonts in one field

    I have a field with a name in it. The challenge is that one section of the string needs to be in a different font than the other section. The folks who have roman numerals need the numerals in a different font. It is my understanding that I can't have two fonts in that field, so I used a query to strip off the part I want to be in a different font (it's always at the end). Now I have it in a different field so I can apply a different font. However, we could have all kinds of different lengths of names and I want the roman numerals to mimic being in the same field and the name is centered on the form.
    What can I do programmatically, to move the roman numeral field around and keep the impression of one string of text?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Not possible.

    Is this on a form, report or query?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2007
    Posts
    348
    I used a query to strip the roman numerals off but the output is through a report. I may have jumbled my terms above, sorry.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    No probs.

    You can't mix fonts in a single text box. If you need to do this you will need to spoof it somehow with two textboxes. I would try to do this as simply as you can if possible - it is very hard to judge the width of a non-fixed-font string in code.

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2007
    Posts
    348
    Thanks Pootle. I'm trying to work through that now. I seem to be stumbling over my attempts to setfocus. So far I have:

    Private Sub Report_Open(Cancel As Integer)
    Dim GradLeft As Integer
    Dim GradWidth As Integer
    Dim PostLeft As Integer

    GradName.SetFocus
    GradName.SizeToFit
    GradLeft = Me.Left
    GradWidth = Me.Width

    PostLeft = GradLeft + GradWidth
    CreateControl "DisplayNames", acTextBox, acDetail, "GradName", "PostScript", PostLeft
    PostScript.SetFocus
    PostScript.SizeToFit
    End Sub
    I'm I get an error on each of my "setfocus" events. I haven't worked out why yet.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You can't set focus in a report (obvious if you think about it )
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Feb 2007
    Posts
    348
    I have spent way to much time on this but I thought I would post the best solution I could come to:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim LetterCount As Integer
    Dim Twip As Integer
    Dim BorderWidth As Integer
    Dim GradLeft As Integer
    Dim GradTop As Integer
    Dim GradWidth As Integer
    Dim GradHeight As Integer

    Twip = 1440
    BorderWidth = 1 * Twip
    LetterCount = Len(GradName.Value)

    GradLeft = 1
    GradTop = 0
    GradWidth = LetterCount * 0.05 * Twip ' 0.05 is what I estimated one letter
    'in the font I was using, to be. This will vary
    GradHeight = 0.166 * Twip ' 0.166 is the height of the field in inchs
    GradName.Move GradLeft, GradTop, GradWidth, GradHeight
    PostScript.Move GradName.Left + GradName.Width
    End Sub
    It's not great, it's not really even good.
    This particular version forgot about the whole issue of needing to be centered, that would be an easy enough fix, I think. It would actually make it look a little better because it would distribute the extra white space to both sides of the name.
    What I found, and what most of you already know, is that you can't SizeToFit in the format event, only before. So you have to guesstimate the width of a letter.
    In my sample data, my name is short (Mike Amos)but doesn't have a lot of narrow letters in it. I used a friend of mine for another sample, he has a really long name with "III" at the end. Since his first name is William, there was a lot of deadspace around his name.
    The above code may look like it has a lot of wasted variables in it and it does. I was having trouble getting the textbox on the page where I wanted it. To make it easier I broke it up into individual variables. You might not need to do that for your own experiences. Also the the Twips thing was killing me.

    So that's me sharing my lesson. If you have something to add, feel free.
    To all the Americans, happy Independence Day. To everyone else. Have a good fourth, too bad you have to work. :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •