Internal Fonts
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Internal Fonts
Hey All,
Is there a way to internalize fonts in livecode? This was a feature that Adobe Director had and we still would like to use it in livecode if it is possible.
Thanks for any help you can provide on this subject.
Is there a way to internalize fonts in livecode? This was a feature that Adobe Director had and we still would like to use it in livecode if it is possible.
Thanks for any help you can provide on this subject.
Re: Internal Fonts
Unlike Director, you cannot use fonts that have been embedded in your Rev application, but you can fake it..
1. read in the font file and store in a custom property
2. when you run your app, save out the font custom property to a temporary file
3. now load/unload the font(s) as required with revFontLoad and revFontUnload
1. read in the font file and store in a custom property
Code: Select all
put URL "binfile:/path/to/font" into tFont
set the myFont of this stack to tFont
Code: Select all
put the myFont of this stack into tFont
put tFont into URL ("binfile:/" & specialFolderPath("Temporary") & "/fontName.extension")
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Re: Internal Fonts
Thanks for the information shaosean. That would of taking me forever to figure out without your help. Love livecode, just wish the documentation was a little better.
Re: Internal Fonts
yeah, the documentation totally needs to be improved, wish they would just switch to using HTML or some other form of text files so we can easily search them.. The online documentation needs to be updated pretty badly as it is a few years out of date
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Re: Internal Fonts
Seem to be having trouble with loading in the binary data and then writing it back out. I have not really worked with the binfile yet so not sure if I am doing something wrong here. My function keeps returning "No font data to save out". I did this check because there was no file being created on my desktop.
Code: Select all
function copyFonts
local tFontFile, tFont
put specialFolderPath("Fonts") & "/helr45w_0.ttf" into tFontFile
if there is a file tFontFile then
put URL("binfile:/" & specialFolderPath("Fonts") & "/helr45w_0.ttf") into tFont
else
return "Font file does not exist"
end if
if tFont is empty then
return "No font data to save out"
else
put tFont into URL ("binfile:/" & specialFolderPath("Desktop") & "/helr45w_0.ttf")
end if
end copyFonts
Re: Internal Fonts
Try removing the slash after "binfile:/" in both places.. The reason for this is there is a slash already from the specialFolder function.. The only other changes I would make is to reuse the "tFontFile" variable and to make it a command instead of a function..
Code: Select all
command copyFonts
local tFontFile, tFont
put specialFolderPath("Fonts") & "/helr45w_0.ttf" into tFontFile
if there is a file tFontFile then
put URL ("binfile:" & tFontFile) into tFont
else
return "Font file does not exist"
end if
if tFont is empty then
return "No font data to save out"
else
put tFont into URL ("binfile:/" & specialFolderPath("Desktop") & "/helr45w_0.ttf")
end if
end copyFonts
-
- Posts: 86
- Joined: Tue May 15, 2012 5:56 pm
- Location: Minneapolis, MN
Re: Internal Fonts
Taking out the slash fixed it but when I go to the message box and have it output specialFolder("Fonts") there is no slash at the beginning. Instead I get C:/Windows/Fonts . So is the slash not needed because it is an absolute path?shaosean wrote:Try removing the slash after "binfile:/" in both places.. The reason for this is there is a slash already from the specialFolder function..
Re: Internal Fonts
Sure it does!CenturyMan1979 wrote:Taking out the slash fixed it...
The correct syntax is:
url("binfile:" & absolute_or_relative_path)
or
url("file:" & absolute_or_relative_path)
This is correct, as we just found out.CenturyMan1979 wrote:...but when I go to the message box and have it output specialFolder("Fonts") there is no slash at the beginning.
Bingo (in case you have a harddisk named "C")CenturyMan1979 wrote:Instead I get C:/Windows/Fonts . So is the slash not needed because it is an absolute path?
A slash isn't even necessary with relative pathnames!
url("file:" & "mytextfile.txt")...
will work as long as "mytextfile.txt" is in the current defaultfolder!
I wonder how you come to think of a slash at the beginning?
This is ONLY neccessary in an internet browser when accessing local files -> file:/...
Re: Internal Fonts
Mac OS X and Linux need the slash at the beginning for absolute paths
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Internal Fonts
Sean- specialFolderPath() gives you the complete specification, so a leading slash isn't necessary. Or useful.
Re: Internal Fonts
Yep. that is true, but we are dealing with plain wrong syntax hereshaosean wrote:Mac OS X and Linux need the slash at the beginning for absolute paths
Good:
url("binfile:" & absolute_or_relative_path)
Bad:
url("binfile:/" & absolute_or_relative_path)
Whatever, I think this is just a misunderstanding from your first example:
put URL "binfile:/path/to/font" into tFont
So maybe CenturyMan1979 thought the / would be necessary here!?
OK, all cleared out, move on, nothing to see here
Best
Klaus