Exemplo n.º 1
0
 def have_font(cls, name):
     font_id = ATSUFontID()
     name = name.encode('ascii', 'ignore')
     r = carbon.ATSUFindFontFromName(name, len(name), kFontFullName,
                                     kFontNoPlatformCode, kFontNoScriptCode,
                                     kFontNoLanguageCode, byref(font_id))
     return r != kATSUInvalidFontErr
Exemplo n.º 2
0
    def __init__(self, name, size, bold=False, italic=False, dpi=None):
        super(CarbonFont, self).__init__()

        if not name:
            name = 'Helvetica'

        if dpi is None:
            dpi = 96  # pyglet 1.1; in pyglet 1.0 this was 72.

        # If application is not DPI-aware, DPI is fixed at 72.  Scale
        # font size to emulate other DPI.  This will need to be fixed if issue
        # #87 is implemented.
        size = size * dpi / 72.

        name = name.encode('ascii', 'ignore')

        font_id = ATSUFontID()
        carbon.ATSUFindFontFromName(name, len(name), kFontFullName,
                                    kFontNoPlatformCode, kFontNoScriptCode,
                                    kFontNoLanguageCode, byref(font_id))

        attributes = {
            kATSUSizeTag: fixed(size),
            kATSUFontTag: font_id,
            kATSURGBAlphaColorTag: ATSURGBAlphaColor(1, 1, 1, 1),
            kATSUQDBoldfaceTag: c_byte(bold),
            kATSUQDItalicTag: c_byte(italic)
        }
        self.atsu_style = create_atsu_style(attributes)

        self.calculate_metrics()