parameters: (self, settings)
docstring: Attached to the `terminal:get_font` WebSocket action; sends the client
          CSS that includes a complete set of fonts associated with
          *settings["font_family"]*.  Optionally, the following additional
          *settings* may be provided:
  
              :font_size:
  
                  Assigns the 'font-size' property according to the given value.
docstring_summary: Attached to the `terminal:get_font` WebSocket action; sends the client
          CSS that includes a complete set of fonts associated with
          *settings["font_family"]*.  Optionally, the following additional
          *settings* may be provided:
docstring_tokens: Attached to the terminal : get_font WebSocket action ; sends the client CSS that includes a complete set of fonts associated with * settings [ font_family ] * . Optionally the following additional * settings * may be provided :
function: def get_font(self, settings):
          """
          Attached to the `terminal:get_font` WebSocket action; sends the client
          CSS that includes a complete set of fonts associated with
          *settings["font_family"]*.  Optionally, the following additional
          *settings* may be provided:
  
              :font_size:
  
                  Assigns the 'font-size' property according to the given value.
          """
          font_family = settings['font_family']
          font_size = settings.get('font_size', '90%')
          filename = 'font.css'
          font_css_path = resource_filename(
              'gateone.applications.terminal', '/templates/%s' % filename)
          if font_family == 'monospace':
              # User wants the browser to control the font; real simple:
              rendered_path = self.render_style(
                  font_css_path,
                  force=True,
                  font_family=font_family,
                  font_size=font_size)
              self.send_css(
                  rendered_path, element_id="terminal_font", filename=filename)
              return
          from .woff_info import woff_info
          fonts = resource_listdir(
              'gateone.applications.terminal', '/static/fonts')
          woffs = {}
          for font in fonts:
              if not font.endswith('.woff'):
                  continue
              font_path = resource_filename(
                  'gateone.applications.terminal', '/static/fonts/%s' % font)
              font_info = woff_info(font_path)
              if "Font Family" not in font_info:
                  self.ws.logger.error(_(
                      "Bad font in fonts dir (missing Font Family in name "
                      "table): %s" % font))
                  continue # Bad font
              if font_info["Font Family"] == font_family:
                  font_dict = {
                      "subfamily": font_info["Font Subfamily"],
                      "font_style": "normal", # Overwritten below (if warranted)
                      "font_weight": "normal", # Ditto
                      "locals": "",
                      "url": (
                          "{server_url}terminal/static/fonts/{font}".format(
                              server_url=self.ws.base_url,
                              font=font)
                      )
                  }
                  if "Full Name" in font_info:
                      font_dict["locals"] += (
                          "local('{0}')".format(font_info["Full Name"]))
                  if "Postscript Name" in font_info:
                      font_dict["locals"] += (
                          ", local('{0}')".format(font_info["Postscript Name"]))
                  if 'italic' in font_info["Font Subfamily"].lower():
                      font_dict["font_style"] = "italic"
                  if 'oblique' in font_info["Font Subfamily"].lower():
                      font_dict["font_style"] = "oblique"
                  if 'bold' in font_info["Font Subfamily"].lower():
                      font_dict["font_weight"] = "bold"
                  woffs.update({font: font_dict})
          # NOTE: Not using render_and_send_css() because the source CSS file will
          # never change but the output will.
          rendered_path = self.render_style(
              font_css_path,
              force=True,
              woffs=woffs,
              font_family=font_family,
              font_size=font_size)
          self.send_css(
              rendered_path, element_id="terminal_font", filename=filename)
function_tokens: def get_font ( self , settings ) : font_family = settings [ 'font_family' ] font_size = settings . get ( 'font_size' , '90%' ) filename = 'font.css' font_css_path = resource_filename ( 'gateone.applications.terminal' , '/templates/%s' % filename ) if font_family == 'monospace' : # User wants the browser to control the font; real simple: rendered_path = self . render_style ( font_css_path , force = True , font_family = font_family , font_size = font_size ) self . send_css ( rendered_path , element_id = "terminal_font" , filename = filename ) return from . woff_info import woff_info fonts = resource_listdir ( 'gateone.applications.terminal' , '/static/fonts' ) woffs = { } for font in fonts : if not font . endswith ( '.woff' ) : continue font_path = resource_filename ( 'gateone.applications.terminal' , '/static/fonts/%s' % font ) font_info = woff_info ( font_path ) if "Font Family" not in font_info : self . ws . logger . error ( _ ( "Bad font in fonts dir (missing Font Family in name " "table): %s" % font ) ) continue # Bad font if font_info [ "Font Family" ] == font_family : font_dict = { "subfamily" : font_info [ "Font Subfamily" ] , "font_style" : "normal" , # Overwritten below (if warranted) "font_weight" : "normal" , # Ditto "locals" : "" , "url" : ( "{server_url}terminal/static/fonts/{font}" . format ( server_url = self . ws . base_url , font = font ) ) } if "Full Name" in font_info : font_dict [ "locals" ] += ( "local('{0}')" . format ( font_info [ "Full Name" ] ) ) if "Postscript Name" in font_info : font_dict [ "locals" ] += ( ", local('{0}')" . format ( font_info [ "Postscript Name" ] ) ) if 'italic' in font_info [ "Font Subfamily" ] . lower ( ) : font_dict [ "font_style" ] = "italic" if 'oblique' in font_info [ "Font Subfamily" ] . lower ( ) : font_dict [ "font_style" ] = "oblique" if 'bold' in font_info [ "Font Subfamily" ] . lower ( ) : font_dict [ "font_weight" ] = "bold" woffs . update ( { font : font_dict } ) # NOTE: Not using render_and_send_css() because the source CSS file will # never change but the output will. rendered_path = self . render_style ( font_css_path , force = True , woffs = woffs , font_family = font_family , font_size = font_size ) self . send_css ( rendered_path , element_id = "terminal_font" , filename = filename )