Exemple #1
0
static void mac_updatelicence(WindowPtr window)
{
    Handle h;
    int len;
    long fondsize;
    Rect textrect;

    SetPort((GrafPtr)GetWindowPort(window));
    BeginUpdate(window);
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    h = Get1Resource('TEXT', wLicence);
    len = GetResourceSizeOnDisk(h);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(window), &textrect);
#else
    textrect = window->portRect;
#endif
    if (h != NULL) {
	HLock(h);
	TETextBox(*h, len, &textrect, teFlushDefault);
	HUnlock(h);
    }
    EndUpdate(window);
}
Exemple #2
0
static PyObject *ResObj_GetResourceSizeOnDisk(ResourceObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    long _rv;
#ifndef GetResourceSizeOnDisk
    PyMac_PRECHECK(GetResourceSizeOnDisk);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = GetResourceSizeOnDisk(_self->ob_itself);
    {
        OSErr _err = ResError();
        if (_err != noErr) return PyMac_Error(_err);
    }
    _res = Py_BuildValue("l",
                         _rv);
    return _res;
}
  LOCAL_FUNC
  TT_Error  TT_Open_Stream( const String*  filepathname, 
                            TT_Stream*     stream )
  {
    TT_Error     error;
    Int          file;
    PStream_Rec  stream_rec;
    TFileMap*    map;

    int          size, err = 0;
    short        vRefNum, res = -1;
    Str255       FontName;
    char         *cp, *p, *fname, *sep;
    Str63        myName;
    long         dirID;


    if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) )
      return error;

    map = Allocate_Map();
    if ( !map )
    {
      error = TT_Err_Out_Of_Memory;
      goto Memory_Fail;
    }
    
    stream_rec = STREAM2REC( *stream );

    /* Find the dirID of the Fonts folder in the current System folder */
    if (FindFolder(kOnSystemDisk, kFontsFolderType, kDontCreateFolder, &vRefNum, &dirID)) 
        goto File_Fail;

    /* Break the name apart */
    fname = mystrdup(filepathname); /* Make a copy so we can muck with it */
    sep = ":/";     /* Things that can seperate file path componants */
    
    strtok(fname, sep);             /* Skip over "fonts:" */
    
    if ((p = strtok(NULL, sep)) == NULL)        /* Get filename */
        goto File_Fail;
    strcpy(myName + 1, p);                      /* Make this a Pascal string (Yuck!) */
    myName[0] = strlen(p);
     
    if ((p = strtok(NULL, sep)) == NULL)        /* Get res name */
        goto File_Fail;
    strcpy(FontName+1, p);                      /* Make this a Pascal string (Yuck!) */
    FontName[0] = strlen(p);
    
    FREE( fname );
    
    if ((cp = strchr(FontName, '.')) != NULL)   /* Strip off ".ttf" , if any */
        *cp = 0;
    
    /* Read the font into a buffer */
    if ((map->resid = HOpenResFile(vRefNum, dirID, myName, fsRdPerm)) == -1)
        goto File_Fail;
    
    if ((map->handle = Get1NamedResource('sfnt', FontName)) == NULL)
        goto Map_Fail;
    
    HLock(map->handle);
    map->base   = *map->handle;
    map->offset = 0;
    map->size   = GetResourceSizeOnDisk(map->handle);

    if ( map->base == NULL )
        goto Lock_Fail;

    stream_rec->map = map;
    stream_rec->pos = 0;

#ifndef TT_CONFIG_OPTION_THREAD_SAFE
    CUR_Stream = stream_rec;
#endif

    return TT_Err_Ok;

  Lock_Fail:
    ReleaseResource(map->handle);
    
  Map_Fail:
    CloseResFile(map->resid);

  File_Fail:
    error = TT_Err_Could_Not_Open_File;
    FREE( map );

  Memory_Fail:
    FREE( *stream );
    FREE( fname );
    return error;
  }