Edit Resource Fork

I need to edit portions of some bitmap font files, and save the result to disk, but seem to go nowhere.

I started by dragging the file into the project, thinking I would simply access it a string. Unfortunately, as it starts by chr(0), it seems Xojo takes it as empty.

Then I proceeded to use Binarystream to load it from disk, same result.

After trying to load the data into a memoryBlock using Xojo.io.BinaryStream unsuccessfully, I am out of ideas.

I just tried this :

[code] dim f as folderitem = app.executablefile.parent.parent.child(“Resources”).child(“antic.bmap”)

msgbox str(f.exists)+" "+str(f.Length)[/code]

The file indeed exists, and in the finder is 2K long, but I get zero length.

For all intents and purposes, Xojo seems completely unable to deal with a file that starts with chr(0).

Will appreciate assistance.

Thank you in advance.

The binary stream is OK. Problem is, Xojo does not see the length of the file if it starts by chr(0) :confused:

Same result. For some reason, Xojo finds the file to be zero length.

I also don’t see that problem. With the code of Jean-Paul where i only added

MsgBox str(bi.Length)

gave the exact length of every fontfile starting with chr(o).

If you try this on Windows you have to copy the font file to a place where your program has access because the font directory in Windows is protected.

Here is the file :
antic.bmap

I had to zip it, because when I uploaded it, it arrived on the server as a zero bytes file. Yet, the archive recreates a 2K file on disk.

It is a suitcase file coming from Classic OS 9.x.

I just compared with other bmap files, they all have the same problem.

So it was not chr(0), it was suitcase. One more special mystery about such files under Mac OS X we do not know about.

EDIT : Ouch, ouch, ouch. It is even more vicious than I thought.

The compressed file is a zero length file. But opening the same archive on PC, I found in the _MACOSX folder a hiden file called ._antic.bmap which is the actual 2K file. I renamed it and am going to see how it fares back on PC.

It seems Apple is going to great length to prevent anybody to fuss with suitcase files…

I don’t know how big the file should be, but when i unzip it on a pc the file shows up as a zero byte file, just as you say. But unzipping the file also shows the same filename preceded with an underscore in the __MACOSX folder within in the zip file and that file shows a size of 2046 bytes while it starts with chr(0).

[quote=251476:@jean-paul devulder]f.length is zero i confirm

i try open file with hexa editor, i can’t[/quote]

It is a mess. The file I saved on PC once repatriated on Mac shows a header that was not apparent in the original file. That warrants much more investigations. It looks as if Mac OS X uses some wizardry with suitcases I will have to unravel before I can hope do anything with that.

[code]aMac OS X 2FxaÜFFILDM

00 05 16 07 00 02 00 00 4D 61 63 20 4F 53 20 58
20 20 20 20 20 20 20 20 00 02 00 00 00 09 00 00
00 32 00 00 00 46 00 00 00 02 00 00 00 78 00 00
07 86 46 46 49 4C 44 4D 4F 56 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00
00 00 00 00 41 54 54 52 00 00 00 00 00 00 00 78
00 00 00 78 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 01 00 00 00 07 20
[/code]

If I recall correctly, bmap is holding the screen version of the actual font file. So without the actual font file a bmap file will not be useful.

But this is 90s stuff and I’m therefore not totally sure.

[quote=251479:@Eli Ott]If I recall correctly, bmap is holding the screen version of the actual font file. So without the actual font file a bmap file will not be useful.

But this is 90s stuff and I’m therefore not totally sure.[/quote]

Indeed, the Classic era bitmap does not work on Mac OS X. BUT if you click on the bitmap, it shows the associated PostScript font.

What I am after is a way to activate Classic PostScript fonts with Fonts Manager. I have a customer who has kept some 18,000 PostScript fonts WITHOUT the associated bitmap (users are sometimes so strange, the Universe keeps making more), so I am trying to come up with a way to recreate a mocked up bitmap font which sole purpose is to activate the PostScript file under Mac OS X.

I was able to do so with a hex editor, now I need to do the same with Xojo…

Some “interesting” reverse engineering and historic documents digging in perspective…

[quote=251481:@jean-paul devulder]looking the folderitem information on debugger,

i see ResourceForkLength = 1926

i think osx considere the file like a ressource not a real data file[/quote]

That is what I suspect. Now if I only can figure out how to recreate such a file with its resource fork …

OK. Further along seeking access to the resource fork.

I can display the content of the resource fork with

cat antic.bmap/..namedfork/rsrc

Now if only I could figure how to edit it, that would be great. Of course, Xojo GetFolderItem chokes badly on such a path. It is getting late here. With some luck I will find the way tomorrow.

[quote=251485:@jean-paul devulder]for display data, you can also use in terminal
DeRez /Users/devulderjean-paul/Downloads/antic.bmap[/quote]

Indeed that works perfectly. Now I need to figure how to edit that…

DeRez is deprecated by Apple, so I’m not sure I’d write software that relies on it.

I seem to recall that MBS has a ResourceForkStream class or is it Einhugur? That allows you to open the resource fork of a file as a binary stream.

However I really don’t have much hope for the future of files with Resource Forks, I see sometimes code signing can choke if a file has a resource fork.

If you can use the terminal command CAT to extract data from the resource fork, I suspect there’s a way to turn it into a bonefide seperate file, then edit what you want from it.

Maybe there’s another way to get the Postscript data without needing a suitcase file?

Hi!

Try OS X friendly “xattr -l antic.bmap”. It will show the ressourcefork. Perhaps this is helpful…

MBS has a resource fork class. We wrote it when Xojo lost his class.
We also have a module for extended attributes.

For whatever reason, there is no way to activate a Classic PostScript font without. However, what I am doing at the moment does not require the resource fork to be stored in the bundle. I actually just succeeded using an uncompressed tar file which I can modify before putting it on disk and extract.

[quote=251519:@Christian Schmitz]MBS has a resource fork class. We wrote it when Xojo lost his class.
We also have a module for extended attributes.[/quote]

Superb. I found ResourceForkMBS. That may be particularly precious as I want to study the possibility to convert PFA PC files to a format I can activate on Mac.

Thank you all.

OK. I have been trying to understand how to actually edit an existing resource file, using the methods listed at http://www.monkeybreadsoftware.net/files-resourceforkmbs-method.shtml#7

I am getting nowhere. It is possible to open a resource with ResourceForkMBS.Open, or to create one with ResourceForkMBS.Create, but I see nowhere any way to apply the changes to the file it came from.

What am I missing ?

[quote=251507:@Sam Rowlands]I seem to recall that MBS has a ResourceForkStream class or is it Einhugur? That allows you to open the resource fork of a file as a binary stream.

However I really don’t have much hope for the future of files with Resource Forks, I see sometimes code signing can choke if a file has a resource fork.

If you can use the terminal command CAT to extract data from the resource fork, I suspect there’s a way to turn it into a bonefide seperate file, then edit what you want from it.

Maybe there’s another way to get the Postscript data without needing a suitcase file?[/quote]

Sam, you were right, Einhugur has a class to read and write resources :
http://www.einhugur.com/Html/ResourceStream/index.html

I am going to investigate further. That seems to be exactly what I need.

Thank you.

well, with both Einhugurs and MBS Plugins you can do it.
And you can open a file’s resource fork and make changes.
Not sure what you are missing.

see
http://www.monkeybreadsoftware.net/class-resourceforkmbs.shtml