digitalmars.D.learn - [Font] Getting font folder on all platforms
- Flamaros (8/8) Sep 05 2013 I am searching the right way to find fonts folder for each
- Justin Whear (4/15) Sep 05 2013 For linux, see fontconfig:
- Flamaros (2/21) Sep 05 2013 Thx
- Jacob Carlborg (10/18) Sep 05 2013 The paths used for fonts on Mac OS X are the ones listed in this table:
- Tourist (3/11) Sep 06 2013 Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid.
- Flamaros (4/18) Sep 06 2013 Nice, thx.
- Flamaros (41/61) Oct 15 2013 I need to do some more tests, but scanning the registry seems
- Flamaros (3/67) Nov 08 2013 I did some progress with fontconfig under linux, I'll try to use
- Xavier Bigand (6/77) Nov 12 2013 I find a way to make it work under Windows.
I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.
Sep 05 2013
On Thu, 05 Sep 2013 21:48:03 +0200, Flamaros wrote:I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.For linux, see fontconfig: http://en.wikipedia.org/wiki/Fontconfig http://www.freedesktop.org/software/fontconfig/fontconfig-user.html
Sep 05 2013
On Thursday, 5 September 2013 at 19:59:20 UTC, Justin Whear wrote:On Thu, 05 Sep 2013 21:48:03 +0200, Flamaros wrote:ThxI am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.For linux, see fontconfig: http://en.wikipedia.org/wiki/Fontconfig http://www.freedesktop.org/software/fontconfig/fontconfig-user.html
Sep 05 2013
On 2013-09-05 21:48, Flamaros wrote:I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.The paths used for fonts on Mac OS X are the ones listed in this table: http://support.apple.com/kb/HT2435 To programmatically work with fonts, have a look at these API's: https://developer.apple.com/library/mac/documentation/Carbon/Reference/CTFontRef/Reference/reference.html https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGFont/Reference/reference.html https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/FontHandling/FontHandling.html#//apple_ref/doc/uid/TP40009459-CH5-SW1 That last link describes an Objective-C API. -- /Jacob Carlborg
Sep 05 2013
On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote:I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid. http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx
Sep 06 2013
On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote:On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote:Nice, thx. Do you know if there is a table of fonts and there family, or need open all font file my self?I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid. http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx
Sep 06 2013
On Friday, 6 September 2013 at 20:54:53 UTC, Flamaros wrote:On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote:I need to do some more tests, but scanning the registry seems working under Windows. Here is my test code : string fontPathFromName(in string name, in Font.Family family = Font.Family.Regular) { version(Windows) { import std.windows.registry; string fontPath = "C:/Windows/Fonts/"; string fontFileName; Key fontKey; fontKey = Registry.localMachine().getKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); if (family == Font.Family.Regular) fontFileName = fontKey.getValue(name ~ " (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Bold) fontFileName = fontKey.getValue(name ~ " Bold (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Italic) fontFileName = fontKey.getValue(name ~ " Italic (TrueType)").value_EXPAND_SZ(); else if (family == (Font.Family.Bold | Font.Family.Italic)) fontFileName = fontKey.getValue(name ~ " Bold Italic (TrueType)").value_EXPAND_SZ(); return fontPath ~ fontFileName; } } unittest { assert(fontPathFromName("Arial") == "C:/Windows/Fonts/arial.ttf"); assert(fontPathFromName("arial") == "C:/Windows/Fonts/arial.ttf"); // Test with wrong case assert(fontPathFromName("Arial", Font.Family.Bold | Font.Family.Italic) == "C:/Windows/Fonts/arialbi.ttf"); }On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote:Nice, thx. Do you know if there is a table of fonts and there family, or need open all font file my self?I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid. http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx
Oct 15 2013
On Tuesday, 15 October 2013 at 23:10:32 UTC, Flamaros wrote:On Friday, 6 September 2013 at 20:54:53 UTC, Flamaros wrote:I did some progress with fontconfig under linux, I'll try to use it for Windows too.On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote:I need to do some more tests, but scanning the registry seems working under Windows. Here is my test code : string fontPathFromName(in string name, in Font.Family family = Font.Family.Regular) { version(Windows) { import std.windows.registry; string fontPath = "C:/Windows/Fonts/"; string fontFileName; Key fontKey; fontKey = Registry.localMachine().getKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); if (family == Font.Family.Regular) fontFileName = fontKey.getValue(name ~ " (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Bold) fontFileName = fontKey.getValue(name ~ " Bold (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Italic) fontFileName = fontKey.getValue(name ~ " Italic (TrueType)").value_EXPAND_SZ(); else if (family == (Font.Family.Bold | Font.Family.Italic)) fontFileName = fontKey.getValue(name ~ " Bold Italic (TrueType)").value_EXPAND_SZ(); return fontPath ~ fontFileName; } } unittest { assert(fontPathFromName("Arial") == "C:/Windows/Fonts/arial.ttf"); assert(fontPathFromName("arial") == "C:/Windows/Fonts/arial.ttf"); // Test with wrong case assert(fontPathFromName("Arial", Font.Family.Bold | Font.Family.Italic) == "C:/Windows/Fonts/arialbi.ttf"); }On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote:Nice, thx. Do you know if there is a table of fonts and there family, or need open all font file my self?I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid. http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx
Nov 08 2013
Le 08/11/2013 21:05, Flamaros a écrit :On Tuesday, 15 October 2013 at 23:10:32 UTC, Flamaros wrote:I find a way to make it work under Windows. I also bind almost all fontconfig API in a similar way of Derelict. If someone is interested look font.d at : https://github.com/D-Quick/DQuick PS : I took fontconfig dll from GTK packagesOn Friday, 6 September 2013 at 20:54:53 UTC, Flamaros wrote:I did some progress with fontconfig under linux, I'll try to use it for Windows too.On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote:I need to do some more tests, but scanning the registry seems working under Windows. Here is my test code : string fontPathFromName(in string name, in Font.Family family = Font.Family.Regular) { version(Windows) { import std.windows.registry; string fontPath = "C:/Windows/Fonts/"; string fontFileName; Key fontKey; fontKey = Registry.localMachine().getKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); if (family == Font.Family.Regular) fontFileName = fontKey.getValue(name ~ " (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Bold) fontFileName = fontKey.getValue(name ~ " Bold (TrueType)").value_EXPAND_SZ(); else if (family == Font.Family.Italic) fontFileName = fontKey.getValue(name ~ " Italic (TrueType)").value_EXPAND_SZ(); else if (family == (Font.Family.Bold | Font.Family.Italic)) fontFileName = fontKey.getValue(name ~ " Bold Italic (TrueType)").value_EXPAND_SZ(); return fontPath ~ fontFileName; } } unittest { assert(fontPathFromName("Arial") == "C:/Windows/Fonts/arial.ttf"); assert(fontPathFromName("arial") == "C:/Windows/Fonts/arial.ttf"); // Test with wrong case assert(fontPathFromName("Arial", Font.Family.Bold | Font.Family.Italic) == "C:/Windows/Fonts/arialbi.ttf"); }On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote:Nice, thx. Do you know if there is a table of fonts and there family, or need open all font file my self?I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows it's generally "C:\Windows\Fonts" but a direct access seems brutal, it's certainly expected to retrieve this path by using some register keys? Is someone know how it works for linux and/or macOS X? I need to be able to retrieve fastest as possible the right file from the font and family name.Windows: call SHGetKnownFolderPath with FOLDERID_Fonts as rfid. http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx
Nov 12 2013