access to fonts directory

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
logoliv
Prole
Posts: 27
Joined: Mon Jan 27, 2014 3:05 pm

access to fonts directory

Post by logoliv »

Hi,

I'm just trying to create a new font without copying the file in my main.lua directory (using the Windows Fonts instead) but it doesn't work :

Code: Select all

font = love.graphics.newFont("C:/Windows/Fonts/segoeui.ttf", 16)
love.graphics.setFont(font)
I obtain a "file not found" error...
Is there another way to specify the Windows directory, like a special variable ? Or perhaps the way to write the path is incorrect ?
Any help would be welcome, thanks.
Last edited by logoliv on Mon Jun 18, 2018 11:08 am, edited 1 time in total.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: file system / path

Post by pgimeno »

You can copy the file to a subfolder in your application and reference it with a relative path.

LÖVE is made to be cross platform. It is not Windows-specific. I use Linux and I would not be able to use a program that depends on Windows- or MacOS-specific directories, just as you wouldn't be able to use a program that depends on Linux- or MacOS-specific directories. LÖVE is designed to encourage cross-platform compatibility, that's why you can't do it.
logoliv
Prole
Posts: 27
Joined: Mon Jan 27, 2014 3:05 pm

Re: file system / path

Post by logoliv »

Thanks for your answer.

So the only possible paths are in subfolders relative to my application ?
I don't plan to port it to Linux or MacOS, nor distribute it... just want to use it on my pc !
And i find stupid to include a 1Mb font file just to have a new font, where i only use 10kb for my application lua code...

Could somebody tell me all the environment variables accessible in Löve please ?
Last edited by logoliv on Mon Jun 18, 2018 7:58 pm, edited 1 time in total.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: file system / path

Post by ivan »

logoliv wrote: Mon Jun 18, 2018 10:47 am So the only possible paths are in subfolders relative to my application ?
Even if you could access "C:\\Windows" note that your script file won't work if I have Windows installed to drive D:\\
You can also access the appData directory but this is usually for save files and temporary data.
logoliv wrote: Mon Jun 18, 2018 10:47 am And i find stupid to include a 1Mb font file just to have a new font, where i only use 10kb for my application lua code...
There are ways to trim down your font file, for example using BMFont or bitmap fonts.
You need to redistribute your assets otherwise the .love file wont work across platforms.
It's just how Love2D works, it's not stupid but a very mindful limitation.
Could somebody tell me all the environment variables accessible in Löve please ?
Environment variables are something different altogether and vary between operating systems.
See https://www.lua.org/pil/22.2.html
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: access to fonts directory

Post by pgimeno »

As I said, LÖVE is designed to encourage cross-platform compatibility, so these things are out of the scope of what it is designed to do. Still, you can do what you want, but it's not easy. You need to mount the folder using PhysFS via FFI. I believe zorg is working on a library to make that easier, but in the meantime, you can try this solution by grump: viewtopic.php?p=218501#p218501

Disclaimer: I have not tried it, therefore I don't know whether it will work.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: access to fonts directory

Post by zorg »

pgimeno wrote: Mon Jun 18, 2018 12:00 pm As I said, LÖVE is designed to encourage cross-platform compatibility, so these things are out of the scope of what it is designed to do. Still, you can do what you want, but it's not easy. You need to mount the folder using PhysFS via FFI. I believe zorg is working on a library to make that easier, but in the meantime, you can try this solution by grump: viewtopic.php?p=218501#p218501

Disclaimer: I have not tried it, therefore I don't know whether it will work.
I am :3
I just prioritize things with deadlines, like music compositions for albums... and a certain squid paintball game dlc came out not long ago, and that ate quite a bit of chunk of my time as well...
But i will soon get my bearings back together, and github and release the thing.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 26 guests