parameters: (self, font)
return_statement: return font
docstring: Return a tkFont instance based on the pid-style FONT
docstring_summary: Return a tkFont instance based on the pid-style FONT
docstring_tokens: Return a tkFont instance based on the pid - style FONT
function: def piddleToTkFont(self, font):
      """Return a tkFont instance based on the pid-style FONT"""
      if font is None:
        return ''
  
      #default 12 pt, "Times", non-bold, non-italic
      size = 12
      family = "Times"
      weight = "normal"
      slant = "roman"
      underline = "false"
  
      if font.face:
        # check if the user specified a generic face type
        # like serif or monospaced. check is case-insensitive.
        f = font.face.lower()
        if f in self.__alt_faces:
          family = self.__alt_faces[f]
        else:
          family = font.face
  
      size = font.size or 12
  
      if font.bold:
        weight = "bold"
      if font.italic:
        slant = "italic"
      if font.underline:
        underline = 'true'
  
      # ugh... is there a better way to do this?
      key = (family, size, weight, slant, underline)
  
      # check if we've already seen this font.
      if key in self.font_cache:
        # yep, don't bother creating a new one. just fetch it.
        font = self.font_cache[key]
      else:
        # nope, let's create a new tk font.
        # this way we will return info about the actual font
        # selected by Tk, which may be different than what we ask
        # for if it's not available.
        font = tkFont.Font(self.master, family=family, size=size, weight=weight, slant=slant,
                           underline=underline)
        self.font_cache[(family, size, weight, slant, underline)] = font
  
      return font
function_tokens: def piddleToTkFont ( self , font ) : if font is None : return '' #default 12 pt, "Times", non-bold, non-italic size = 12 family = "Times" weight = "normal" slant = "roman" underline = "false" if font . face : # check if the user specified a generic face type # like serif or monospaced. check is case-insensitive. f = font . face . lower ( ) if f in self . __alt_faces : family = self . __alt_faces [ f ] else : family = font . face size = font . size or 12 if font . bold : weight = "bold" if font . italic : slant = "italic" if font . underline : underline = 'true' # ugh... is there a better way to do this? key = ( family , size , weight , slant , underline ) # check if we've already seen this font. if key in self . font_cache : # yep, don't bother creating a new one. just fetch it. font = self . font_cache [ key ] else : # nope, let's create a new tk font. # this way we will return info about the actual font # selected by Tk, which may be different than what we ask # for if it's not available. font = tkFont . Font ( self . master , family = family , size = size , weight = weight , slant = slant , underline = underline ) self . font_cache [ ( family , size , weight , slant , underline ) ] = font return font