Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::ebooks::rtf2xml::field_strings::FieldStrings::__symbol_func (   self,
  field_name,
  name,
  line 
) [private]

Requires:
    field_name --first name in the string.
    name -- the changed name according to the dictionary.
    line -- the string to parse.
Returns:
    A string containing font size, font style, and a hexidecimal value.
Logic:
    The SYMBOL field is one of Microsoft's many quirky ways of
    entering text. The string that results from this method looks like
    this:
SYMBOL 97 \\f "Symbol" \\s 12
    The first word merely tells us that we have encountered a SYMBOL
    field.
    The next value is the Microsoft decimal value. Change this to
    hexidecimal.
    The pattern '\\f "some font' tells us the font.
    The pattern '\\s some size'  tells us the font size.
    Extract all of this information. Store this information in a
    string, and make this string the last item in a list. The first
    item in the list is the simple word 'symbol', which tells me that
    I don't really have  field, but UTF-8 data.

Definition at line 751 of file field_strings.py.

00751                                                    :
        """
        Requires:
            field_name --first name in the string.
            name -- the changed name according to the dictionary.
            line -- the string to parse.
        Returns:
            A string containing font size, font style, and a hexidecimal value.
        Logic:
            The SYMBOL field is one of Microsoft's many quirky ways of
            entering text. The string that results from this method looks like
            this:
                SYMBOL 97 \\f "Symbol" \\s 12
            The first word merely tells us that we have encountered a SYMBOL
            field.
            The next value is the Microsoft decimal value. Change this to
            hexidecimal.
            The pattern '\\f "some font' tells us the font.
            The pattern '\\s some size'  tells us the font size.
            Extract all of this information. Store this information in a
            string, and make this string the last item in a list. The first
            item in the list is the simple word 'symbol', which tells me that
            I don't really have  field, but UTF-8 data.
        """
        num = ''
        font = ''
        font_size = ''
        changed_line = ''
        search_obj = re.search(self.__symbol_num_exp, line)
        if search_obj:
            num = search_obj.group(1)
            num = int(num)
            num = '%X' % num
        search_obj = re.search(self.__symbol_font_exp, line)
        if search_obj:
            font = search_obj.group(1)
            changed_line += 'cw<ci<font-style<nu<%s\n' % font
        search_obj = re.search(self.__symbol_size_exp, line)
        if search_obj:
            font_size = search_obj.group(1)
            font_size = int(font_size)
            font_size = '%.2f' % font_size
            changed_line += 'cw<ci<font-size_<nu<%s\n' % font_size
        changed_line += 'tx<hx<__________<\'%s\n' % num
        return ['Symbol', None, changed_line]
        return ['Symbol', None, changed_line]


Generated by  Doxygen 1.6.0   Back to index