Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Solved
    • Unsolved
    • Search
    1. Home
    2. mït
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by mït

    • RE: Different fonts in a text box

      Hello, @gferreira!

      I had thought about working word for word ... I didn’t know if it was a good idea ... but it’s really interesting what you coded! I wouldn't have found it alone! thanks!

      I guess this way the text would never be justified ... but it will be very useful for me!

      thanks!

      posted in General Discussion
      mït
      mït
    • RE: Different fonts in a text box

      Thanks you, @frederik!

      I didn't know about textBoxCharacterBounds!
      So far I have not been able to get all its potential because it does not seem to return whole lines.

      print(textBoxCharacterBounds(txt, (x, y, w, h),'justified')[0])
      

      This code does not return only the first line, but a bit more..so I can't confirm the line where I can find a word...but I'll continue exploring!

      Thanks again!

      posted in General Discussion
      mït
      mït
    • RE: Different fonts in a text box

      Hello, @gferreira!

      You have opened me a new world of possibilities! Thank you!

      In fact, I have some more doubts that I had considered with impossible solution after searching and trying for days and days but now I dare to ask you... (please, tell if I should mark someway that this topic is solved and if I should open a new one...or if they are too many questions!)

      • Is there any way to find out the page number where a piece of text (or a word, or a title ...) can be found? I mean, how to get that the title 'Some title here' is in page number 2, for instance.

      • Is there any way to find out the line number (in reference to the text box) where a piece of text can be found? I mean, for example, if the piece of text "gravida in mi., is in the line 1 of 20 of the textbox (that means that is in the first line of a page...

      Believe me if I say that I've been "playing" a lot with the size of the text (T.size()[1]) and the size of the textbox that I've defined, and pagecount and pages ... I guess everything would be based on mathematical calculations (text size, textbox size ...) but I can't find out if it is possible...

      Thank you very much, again!

      posted in General Discussion
      mït
      mït
    • RE: Different fonts in a text box

      Yes, this helps me a lot @gferreira!

      Although it was more or less the idea I had in mind, you've clarified me it so well (and you've clean my code)!

      Nevertheless, my question was the begining of my intention (I dos nit explain you)...I mean...if I have a big text, and I need to define that part of this text is like a title1, another part is like normal text, after could come a title2, again a normal text (maybe with some words in bold or italic), maybe another title like title2, again normal text and so on...is there a clean way to format the text a posteriori?

      Or maybe I should look for another solution outside Drawbot?

      I'd like avoid using a text editor because I'd like to add Drawbot drawing properties to the document...

      Thanks a lot again!

      posted in General Discussion
      mït
      mït
    • Different fonts in a text box

      Hello, everyone!

      Do you have any suggestion about the best way to change a font type inside a textbox?

      I mean, imagine I have a text from a variable and I'd like to put part of it in bold or italic, for instance.

      size('A4')
      t = '''
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus justo in finibus condimentum. Proin vitae mauris ac nibh elementum consectetur. Aenean justo mi, cursus vel placerat vitae, gravida in mi.
      '''
      t2 = FormattedString(t, font="Arial", fontSize = 20)
      while len(t2):
          newPage()
          font("Arial", 20)
          fill(0)
          t2 = textBox(t2, (10, 10, width() - 20, height() - 20))
      

      Is it possible, for example, to put "sit amet" in arial-bold or "condimentum" in arial-italic?

      Thank you!

      posted in General Discussion
      mït
      mït