Navigation

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

    Posts made by Hugo Jourdan

    • 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
    • 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
    • RE: Mute DrawBot warning ?

      I'm looking to not print :

      *** DrawBot warning: [...] ***
      
      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • Mute DrawBot warning ?

      Hi,

      There is a way to not show DrawBot warning ?

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • RE: BezierPath offset problem.

      @frederik Thanks for this clarification !

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • 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
    • RE: DrawBot Auto-completion Snippet

      I just updated the repo with separated snippets for SublimeText.

      posted in Code snippets
      Hugo Jourdan
      Hugo Jourdan
    • DrawBot Auto-completion Snippet

      Hi,

      I recently uploaded snippets to add DrawBot auto-completion in VSCode, Atom and SublimeText.

      You can access them from my GitHub Repo:
      https://github.com/HugoJourdan/Drawbot-TextEditor-Snippets

      posted in Code snippets
      Hugo Jourdan
      Hugo Jourdan
    • Python Update ?

      It is possible to manually update Python version in drawBot ?
      I'm facing a situation where I can't use a module inside drawBot because it uses Python 3.10

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • 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
    • RE: Using tkinter in DrawBot

      I didn't know that option, thanks a lot frederik !

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • Using tkinter in DrawBot

      Hi,

      I would like to ask users to select a folder and get his path. Here with my code, a window opens to choose the file but nothing happen after. Like if the script stop after the 3rd line.

      from tkinter import Tk
      from tkinter.filedialog import askdirectory
      path = askdirectory(title='Select Folder') # shows dialog box and return the path
      print(path)  
      

      No error message appears.
      I put the complete tkinter module in the folder which contain the script.

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • How to draw all glyphs from .ttf ?

      There is a way to draw all glyphs from a .ttf in a textBox? Including all OpenType glyphs (like .ss01, .tf, .sc ...)

      With listFontGlyphNames(), if I put the list in a textBox I get all names, but not drawings.

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • How to set x,y position for a BezierPath ?

      Hi,

      I'm working on a script for Glyphs to build a Character set with Drawbot Extension. I'm using the Glyph API to extract the BezierPath of my letters.

      I would like to set the x,y position of the Path without using translate

      Here is my code :

      from GlyphsApp import *
      
      f = Glyphs.font # frontmost font
      m = f.selectedFontMaster # active master
      
      paperSize = 'A4Landscape'
      
      newPage(paperSize) 
      scale (0.2, 0.2)
      path = f.glyphs["A"].layers[m.id].completeBezierPath
      drawPath(path) 
      
      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • RE: Tracking for txt variable doest'n work

      Thanks for your help!
      I don't know what was wrong in my code, but if yours everything is working !

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan
    • Tracking for txt variable doest'n work

      Hi,

      I started to write a Drawbot script to build automatic proofing files for my fonts.

      I would like to change the tracking of a textBox, but there is a problem.
      When I use a variable as txt, tracking doesn't work (example bellow)

      textBox(FormattedString(txt=Text_sample, fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
      

      But If I replace the variable Text_sample by a real text with '', it's work.

      textBox(FormattedString(txt='Test', fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
      

      How can I apply tracking to a textBox ?
      Or If it's not possible does it exist an alternative ?

      Thanks !

      posted in General Discussion
      Hugo Jourdan
      Hugo Jourdan