Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Solved
    • Unsolved
    • Search
    1. Home
    2. Hugo Jourdan
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Hugo Jourdan

    @Hugo Jourdan

    2
    Reputation
    23
    Posts
    12
    Profile views
    2
    Followers
    0
    Following
    Joined 3 May 2021, 14:52 Last Online 8 Jul 2024, 10:18

    Hugo Jourdan Follow

    Best posts made by Hugo Jourdan

    • RE: DrawBot Auto-completion Snippet

      I just updated the repo with separated snippets for SublimeText.

      posted in Code snippets
      Hugo Jourdan
      Hugo Jourdan
      16 Nov 2022, 15:13
    • Rounded Rectangle

      Snippet do draw rectangle with rounded corner:

      def rectRounded(x,y,w,h,radius):
          path = BezierPath()
          sR=0.5*radius
          w=w-radius
          h=h-radius
          path.rect(x,y+sR,w+radius,h)
          path.rect(x+sR,y,w,h+radius)
          path.oval(x,y,radius,radius)
          path.oval(x+w,y,radius,radius)
          path.oval(x,y+h,radius,radius)
          path.oval(x+w,y+h,radius,radius)
          path.removeOverlap()
          drawPath(path)
      

      It is possible to manually add it in drawBot module ?

      posted in Code snippets
      Hugo Jourdan
      Hugo Jourdan
      7 May 2022, 15:14

    Latest posts made by Hugo Jourdan

    • Drawbot and PIL

      Hi,

      Is it possible to convert a Drawbot drawing to a PIL format without saving it as an image and then opening/converting it with PIL?

      Currently, I'm trying to process all glyphs from a font file with PIL, and I'm using Drawbot to generate images to process with PIL.

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      8 Jul 2024, 09:05
    • RE: Auto-Resize FormattedString

      I hadn't thought about this solution!
      Thanks, @frederik!

      newPage("A4Landscape")
      
      box_w, box_h = width()-100, height()-100
      box_x, box_y = 50, 50
      
      txt = FormattedString()
      
      txt.fontSize(90)
      txt.align("center")
      txt.append("LOOOOOOOOOOOOOOONG STRING\n"*30)
      
      txt_w = textSize(txt)[0]
      txt_h = textSize(txt)[1]
      
      width_ratio = box_w/txt_w 
      height_ratio = box_h/txt_h
      
      sf = min(width_ratio , height_ratio, 1)
      
      scale(sf)
      textBox(txt, (box_x/sf, box_y/sf, box_w/sf, box_h/sf))
      
      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      10 Aug 2023, 13:17
    • Auto-Resize FormattedString

      Hi,

      I'm looking for a solution to find the maximum value of FontSize that can be set to allow a FormattedString() to occupy all the available space in a TextBox.

      For TextBox using a simple string, I have already coded this snippet that returns the maximum fontSize value:

      def get_max_fontSize_textBox(font, text, box, align=None, fS=200):
      	font(FONT)
      	fontSize(fS)
      	hyphenation(False)
      	overflow = textOverflow(text, box, align)
      	while overflow:
      		font(FONT)
      		fS -= 1
      		fontSize(fS)
      		overflow = textOverflow(text, box, align)
      return fS
      

      I would like to achieve exactly the same thing, but using FormattedString() instead of a str.

      The problem is how to build again the FormattedString() in the while overflow loop.

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      9 Aug 2023, 15:10
    • Snippet : drawOnCurvePoints

      This snippet allow to draw points of a BezierPath ignoring quadratic added nodes when exporting a font.

      def drawOnCurvePoints(bezierPath, size):
          for c in bezierPath:
              for p in c.points:
                  i = c.points.index(p)
                  try:
                      nextPoint = c.points[i+1]
                  except:
                      nextPoint = c.points[0]
                  previousPoint = c.points[i-1]
      
                  if nextPoint in bezierPath.onCurvePoints and previousPoint in bezierPath.onCurvePoints :
                      oval(p[0]-size/2,p[1]-size/2, size ,size)
              
                  if nextPoint[0] == p[0] and p in bezierPath.onCurvePoints:
                      oval(p[0]-size/2,p[1]-size/2, size ,size)
                  
                  if previousPoint[0] == p[0] and p in bezierPath.onCurvePoints:
                      oval(p[0]-size/2,p[1]-size/2, size ,size)
                  
                  if nextPoint[1] == p[1] and p in bezierPath.onCurvePoints:
                      oval(p[0]-size/2,p[1]-size/2, size ,size)
                  
                  if previousPoint[1] == p[1] and p in bezierPath.onCurvePoints:
                      oval(p[0]-size/2,p[1]-size/2, size ,size)
      
      posted in Code snippets
      Hugo Jourdan
      Hugo Jourdan
      12 Jan 2023, 10:58
    • listNamedInstances is broken ?

      Hi,

      I tried to use

      listNamedInstances(fontPath)
      

      It seem to list the first instance (depending if variable font contain italic).

      I test it with several Google Font and some of mine mine and the problem persists.

      I check with FontTableViewer and all instances are present in [name] and [fvar] table.

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      13 Dec 2022, 15:10
    • RE: Mute DrawBot warning ?

      I'm looking to not print :

      *** DrawBot warning: [...] ***
      
      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      4 Dec 2022, 11:40
    • Mute DrawBot warning ?

      Hi,

      There is a way to not show DrawBot warning ?

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      1 Dec 2022, 11:18
    • RE: BezierPath offset problem.

      @frederik Thanks for this clarification !

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      1 Dec 2022, 11:16
    • BezierPath offset problem.

      Hi,
      I would like to translate a BezierPath, without changing it's bounds.

      Here is code where you can see my problem.

      newPage(2000,2000)
      
      # Grey Rectangle
      path0 = BezierPath()
      path0.rect(1000,10,200,1990)
      with savedState():
          fill(0, 0.1)
          drawPath(path0)
      
      # Green Rectangle
      path1 = BezierPath()
      path1.text("1", fontSize=200)
      with savedState():
          fill(0,1,0)
          rect(*path1.bounds())
      drawPath(path1)
      
      # Red Rectangle
      path2 = BezierPath()
      path2.text("2", fontSize=200, offset=(200,300))
      with savedState():
          fill(1,0,0)
          rect(*path2.bounds())
      drawPath(path2)
      
      # Yellow Rectangle
      path3 = BezierPath()
      path3.text("3", fontSize=200)
      path3.translate(100,800)
      with savedState():
          fill(1,1,0)
          rect(*path3.bounds())
      drawPath(path3)
      
      # Magenta Rectangle
      translate(900,800)
      path4 = BezierPath()
      path4.text("4", fontSize=200)
      with savedState():
          fill(1,0,1)
          rect(*path4.bounds())
      drawPath(path4)
      

      I tested 3 solution:

      • use offset in path.text
        ❌ Change BezierPath bounds

      • use path.translate
        ❌ Change BezierPath bounds

      • use translate
        ✅ Don't change BezierPath bounds

      But this is annoying, because I don't want to translate all my canvas just for that.

      So what is the solution ?

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
      24 Nov 2022, 11:17
    Drawing With Python