Convert a Qt font to CSS style
9735
def qt_font_to_style(font, color):
    
    if font is None:
        font = "TypeWriter,10,-1,5,75,0,0,0,0,0"
    font_info = font.split(",")
    style = "font-family: {};font-size: {};".format(font_info[0], font_info[1])
    if font_info[4] == "75":
        style += "font-weight: bold;"
    if font_info[5] == "1":
        style += "font-style: italic;"

    if color is None:
        color = "000000"
    if len(color) == 9:
        style += "fill: #" + color[-6:] + ";"
        style += "fill-opacity: {};".format(round(1.0 / 255 * int(color[:3][-2:], base=16), 2))
    else:
        style += "fill: #" + color[-6:] + ";"
        style += "fill-opacity: {};".format(1.0)
    return style
182622
function style(title) {

    title
      .attr("font-size",function(t){
        return t.style.font.size
      })
      .attr("fill",function(t){
        return t.link ? vars.links.font.color : t.style.font.color
      })
      .attr("font-family",function(t){
        return t.link ? vars.links.font.family.value : t.style.font.family.value
      })
      .attr("font-weight",function(t){
        return t.link ? vars.links.font.weight : t.style.font.weight
      })
      .style("text-decoration",function(t){
        return t.link ? vars.links.font.decoration.value : t.style.font.decoration.value
      })
      .style("text-transform",function(t){
        return t.link ? vars.links.font.transform.value : t.style.font.transform.value
      })

  }
677773
def get_style(self, style):
        
        style_key = tuple(style.items())
        s = self.STYLE_FACTORY.get(style_key, None)
        if s is None:
            s = xlwt.XFStyle()
            for key, values in style.items():
                if key == "background":
                    p = xlwt.Pattern()
                    for attr, value in values:
                        p.__setattr__(attr, value)
                    s.pattern = p
                elif key == "format":
                    s.num_format_str = values
                elif key == "alignment":
                    a = xlwt.Alignment()
                    for attr, value in values:
                        a.__setattr__(attr, value)
                    s.alignment = a
                elif key == "border":
                    b = xlwt.Formatting.Borders()
                    for attr, value in values:
                        b.__setattr__(attr, value)
                    s.borders = b
                elif key == "font":
                    f = self.get_font(values)
                    s.font = f
            self.STYLE_FACTORY[style_key] = s
        return s
1094921
def font_attribute(styles={})
      return nil if styles.nil?
      value = styles[:font]
      return nil unless value && value.is_a?(UIFont)
      value
    end
855860
def import_fonts(style_less, fontname, font_subdir):
    

    ftype_dict = {'woff2': 'woff2',
                  'woff': 'woff',
                  'ttf': 'truetype',
                  'otf': 'opentype',
                  'svg': 'svg'}

    define_font = (
        "@font-face {{font-family: {fontname};\n\tfont-weight:"
        "{weight};\n\tfont-style: {style};\n\tsrc: local('{fontname}'),"
        "\n\turl('fonts{sepp}{fontfile}') format('{ftype}');}}\n")
    fontname = fontname.split(',')[0]
    fontpath = os.path.join(fonts_dir, font_subdir)
    for fontfile in os.listdir(fontpath):
        if '.txt' in fontfile or 'DS_' in fontfile:
            continue
        weight = 'normal'
        style = 'normal'
        if 'medium' in fontfile:
            weight = 'medium'
        elif 'ital' in fontfile:
            style = 'italic'
        ft = ftype_dict[fontfile.split('.')[-1]]
        style_less += define_font.format(
            fontname=fontname,
            weight=weight,
            style=style,
            sepp='/',
            fontfile=fontfile,
            ftype=ft)
        send_fonts_to_jupyter(os.path.join(fontpath, fontfile))

    return style_less
211478
def create_style_from_font(font):
    

    if font is None:
        return ''

    if type(font) is str:
        _font = font.split(' ')
    else:
        _font = font

    style = ''
    style += 'font-family: %s;\n' % _font[0]
    style += 'font-size: %spt;\n' % _font[1]
    font_items = ''
    for item in _font[2:]:
        if item == 'underline':
            style += 'text-decoration: underline;\n'
        else:
            font_items += item + ' '
    if font_items != '':
        style += 'font: %s;\n' % (font_items)
    return style
279757
def font(self, prefix, size):
        """"""
        font = QFont(self.fontname[prefix])
        font.setPixelSize(size)
        if prefix[-1] == 's':  # solid style
            font.setStyleName('Solid')
        return font
1011619
function getBundledCSS() {
    return streamqueue.obj(
        gulp.src(paths.dev.vendor + 'font-awesome/css/font-awesome.css')
            .pipe(modifyCssUrls({
                modify: function (url, filePath) {
                    return url.replace('../fonts/', '/fonts/font-awesome/');
                }
            })),
        gulp.src(paths.dev.vendor + 'bootstrap/dist/css/bootstrap.css')
            .pipe(modifyCssUrls({
                modify: function (url, filePath) {
                    return url.replace('../fonts/', '/fonts/bootstrap/');
                }
            })),
        gulp.src(paths.dev.vendor + 'nattreid-file-manager/assets/fileManager.css')
            .pipe(modifyCssUrls({
                modify: function (url, filePath) {
                    return url.replace('/images/', '/images/fileManager/');
                }
            })),
        gulp.src([
            paths.dev.vendor + 'jquery-ui-dist/jquery-ui.theme.css',
            paths.dev.vendor + 'bootstrap/dist/css/bootstrap-theme.css',
            paths.dev.vendor + 'bootstrap-daterangepicker/daterangepicker.css',
            paths.dev.vendor + 'nprogress/nprogress.css',
            // datagrid
            paths.dev.vendor + 'ublaboo-datagrid/assets/dist/datagrid.css',
            paths.dev.vendor + 'ublaboo-datagrid/assets/dist/datagrid-spinners.css',
            paths.dev.vendor + 'happy/dist/happy.css',
            paths.dev.vendor + 'bootstrap-datepicker/dist/css/bootstrap-datepicker3.css',
            paths.dev.vendor + 'bootstrap-select/dist/css/bootstrap-select.css',
            // spectrum
            paths.dev.vendor + 'spectrum-colorpicker/spectrum.css',
            // plugins
            paths.dev.vendor + 'nattreid-form/assets/form.css',
            paths.dev.vendor + 'nattreid-modal/assets/modal.min.css',
            // cms
            paths.dev.css + '*.css'
        ])
    );
}
892265
def set_font(self, font):
        """"""
        self.setFont(font)
        self.set_pythonshell_font(font)
        cursor = self.textCursor()
        cursor.select(QTextCursor.Document)
        charformat = QTextCharFormat()
        charformat.setFontFamily(font.family())
        charformat.setFontPointSize(font.pointSize())
        cursor.mergeCharFormat(charformat)
1251719
function(raw) {
      var css = { };
      var lookups = 'left top right bottom width height x y min-width min-height max-width max-height';

      angular.forEach(raw, function(value,key) {
        if (angular.isUndefined(value)) return;

        if (lookups.indexOf(key) >= 0) {
          css[key] = value + 'px';
        } else {
          switch (key) {
            case 'transition':
              convertToVendor(key, $mdConstant.CSS.TRANSITION, value);
              break;
            case 'transform':
              convertToVendor(key, $mdConstant.CSS.TRANSFORM, value);
              break;
            case 'transformOrigin':
              convertToVendor(key, $mdConstant.CSS.TRANSFORM_ORIGIN, value);
              break;
            case 'font-size':
              css['font-size'] = value; // font sizes aren't always in px
              break;
          }
        }
      });

      return css;

      function convertToVendor(key, vendor, value) {
        angular.forEach(vendor.split(' '), function (key) {
          css[key] = value;
        });
      }
    }
550481
def _update_font_style(self, font_style):
        

        toggle_state = font_style & wx.FONTSTYLE_ITALIC == wx.FONTSTYLE_ITALIC

        self.ToggleTool(wx.FONTFLAG_ITALIC, toggle_state)
545179
function guessFontStyle(basename) {
  return basename
    .split('-')
    .slice(1)
    .map(item => item.toLowerCase())
    .reduce((prev, item) => {
      if (fontStyleKeywords.indexOf(item) >= 0) {
        return `font-style:${item};`
      }

      return prev
    }, '')
}
894353
def _init_style(self):
        
        self._background = QtGui.QColor('white')
        self._foreground = QtGui.QColor('black')
        self._whitespaces_foreground = QtGui.QColor('light gray')
        app = QtWidgets.QApplication.instance()
        self._sel_background = app.palette().highlight().color()
        self._sel_foreground = app.palette().highlightedText().color()
        self._font_size = 10
        self.font_name = ""
711736
def _compose_style(self):
        """"""
        valid_styles = (
            'color', 'width', 'filter', 'strokeWidth', 'strokeColor',
        )
        self.styling = '\n'.join(
            '{prop}: {style}'.format(prop=s, style=getattr(self, s))
            for s in valid_styles
            if getattr(self, s) is not None
        )
531800
def update(self):
        
        font = self.editor.font()
        for decoration in self._decorations:
            try:
                decoration.format.setFont(
                        font, QTextCharFormat.FontPropertiesSpecifiedOnly)
            except (TypeError, AttributeError):  # Qt < 5.3
                decoration.format.setFontFamily(font.family())
                decoration.format.setFontPointSize(font.pointSize())
        self.editor.setExtraSelections(self._decorations)
1034717
def get_format(**kwargs):
    

    settings = foundations.data_structures.Structure(**{"format": QTextCharFormat(),
                                                        "background_color": None,
                                                        "color": None,
                                                        "font_weight": None,
                                                        "font_point_size": None,
                                                        "italic": False})
    settings.update(kwargs)

    format = QTextCharFormat(settings.format)

    settings.background_color and format.setBackground(settings.background_color)
    settings.color and format.setForeground(settings.color)
    settings.font_weight and format.setFontWeight(settings.font_weight)
    settings.font_point_size and format.setFontPointSize(settings.font_point_size)
    settings.italic and format.setFontItalic(True)

    return format
463063
def load_stylesheet(pyside=True):
    
    # Smart import of the rc file
    if pyside:
        import qdarkstyle.pyside_style_rc
    else:
        import qdarkstyle.pyqt_style_rc

    # Load the stylesheet content from resources
    if not pyside:
        from PyQt4.QtCore import QFile, QTextStream
    else:
        from PySide.QtCore import QFile, QTextStream

    f = QFile(":qdarkstyle/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet