@@ -233,31 +233,30 @@ static ofPath makeContoursForCharacter(FT_Face face){
233233#include < ApplicationServices/ApplicationServices.h>
234234
235235// ------------------------------------------------------------------
236- static string osxFontPathByName (const of::filesystem::path & fileName){
236+ static of::filesystem::path osxFontPathByName (const of::filesystem::path & fileName) {
237237 CFStringRef targetName = CFStringCreateWithCString (nullptr , fileName.c_str (), kCFStringEncodingUTF8 );
238238 CTFontDescriptorRef targetDescriptor = CTFontDescriptorCreateWithNameAndSize (targetName, 0.0 );
239239 CFURLRef targetURL = (CFURLRef) CTFontDescriptorCopyAttribute (targetDescriptor, kCTFontURLAttribute );
240- string fontPath = " " ;
240+ string fontDir = " " ;
241241
242242 if (targetURL) {
243243 UInt8 buffer[PATH_MAX];
244244 CFURLGetFileSystemRepresentation (targetURL, true , buffer, PATH_MAX);
245- fontPath = string ((char *)buffer);
245+ fontDir = string ((char *)buffer);
246246 CFRelease (targetURL);
247247 }
248248
249249 CFRelease (targetName);
250250 CFRelease (targetDescriptor);
251-
251+ of::filesystem::path fontPath = { fontDir };
252252 return fontPath;
253253}
254254#endif
255255
256256#ifdef TARGET_WIN32
257257#include < unordered_map>
258258// font font face -> file name name mapping
259- // FIXME: second -> fs::path
260- static std::unordered_map<string, string> fonts_table;
259+ static std::unordered_map<string, of::filesystem::path> fonts_table;
261260// read font linking information from registry, and store in std::map
262261// ------------------------------------------------------------------
263262void initWindows (){
@@ -277,7 +276,6 @@ void initWindows(){
277276 wchar_t value_name[2048 ];
278277 BYTE *value_data;
279278
280-
281279 // get font_file_name -> font_face mapping from the "Fonts" registry key
282280
283281 l_ret = RegQueryInfoKeyW (key_ft, nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , &value_count, nullptr , &max_data_len, nullptr , nullptr );
@@ -298,47 +296,40 @@ void initWindows(){
298296
299297 char value_name_char[2048 ];
300298 char value_data_char[2048 ];
301- /* char ppidl[2048];
302- char fontsPath[2048];
303- SHGetKnownFolderIDList(FOLDERID_Fonts, 0, nullptr, &ppidl);
304- SHGetPathFromIDList(ppidl,&fontsPath);*/
305299 string fontsDir = ofGetEnv (" windir" );
306300 fontsDir += " \\ Fonts\\ " ;
301+
307302 for (DWORD i = 0 ; i < value_count; ++i)
308303 {
309304 DWORD name_len = 2048 ;
310305 DWORD data_len = max_data_len;
311-
312306 l_ret = RegEnumValueW (key_ft, i, value_name, &name_len, nullptr , nullptr , value_data, &data_len);
313307 if (l_ret != ERROR_SUCCESS){
314308 ofLogError (" ofTrueTypeFont" ) << " initWindows(): couldn't read registry key for font type" ;
315309 continue ;
316310 }
317-
318311 wcstombs (value_name_char,value_name,2048 );
319312 wcstombs (value_data_char,reinterpret_cast <wchar_t *>(value_data),2048 );
320313 string curr_face = value_name_char;
321314 string font_file = value_data_char;
322315 curr_face = curr_face.substr (0 , curr_face.find (' (' ) - 1 );
323316 curr_face = ofToLower (curr_face);
324- fonts_table[curr_face] = fontsDir + font_file;
317+ of::filesystem::path fontPath = { fontsDir + font_file };
318+ fonts_table[curr_face] = fontPath;
325319 }
326-
327-
328320 HeapFree (GetProcessHeap (), 0 , value_data);
329-
330321 l_ret = RegCloseKey (key_ft);
331322}
332323
333324
334- static string winFontPathByName (const string & fontname){
325+ static of::filesystem::path winFontPathByName (const string & fontname) {
335326 return fonts_table[fontname];
336327}
337328#endif
338329
339330#ifdef TARGET_LINUX
340331// ------------------------------------------------------------------
341- static string linuxFontPathByName (const string & fontname){
332+ static of::filesystem::path linuxFontPathByName (const string & fontname) {
342333 string filename;
343334 FcPattern * pattern = FcNameParse ((const FcChar8*)fontname.c_str ());
344335 FcBool ret = FcConfigSubstitute (0 ,pattern,FcMatchPattern);
@@ -368,21 +359,21 @@ static string linuxFontPathByName(const string & fontname){
368359 }
369360 FcPatternDestroy (fontMatch);
370361 FcPatternDestroy (pattern);
371- return filename;
362+ of::filesystem::path fontPath = { filename };
363+ return fontPath;
372364}
373365#endif
374366
375367// -----------------------------------------------------------
376- // FIXME: it seems first parameter is string because it represents the font name only
377- static bool loadFontFace (const string & _fontname, FT_Face & face,
368+ // FIXME: it seems first parameter is string because it represents the font name only / can be
369+ static bool loadFontFace (const string & _fontname, FT_Face & face,
378370 of::filesystem::path & _filename, int index){
379371 auto fontname = _fontname;
380- auto filename = ofToDataPath (_filename );
372+ auto filename = ofToDataPath (fontname );
381373 int fontID = index;
382374 if (!of::filesystem::exists (filename)){
383375#ifdef TARGET_LINUX
384- // FIXME: fs::path in input and output
385- filename = linuxFontPathByName (_fontname);
376+ filename = linuxFontPathByName (fontname);
386377#elif defined(TARGET_OSX)
387378 if (fontname==OF_TTF_SANS){
388379 fontname = " Helvetica Neue" ;
@@ -396,18 +387,16 @@ static bool loadFontFace(const string & _fontname, FT_Face & face,
396387 }else if (fontname==OF_TTF_MONO){
397388 fontname = " Menlo Regular" ;
398389 }
399- // FIXME: fs::path in input and output
400- filename = osxFontPathByName (_fontname);
390+ filename = osxFontPathByName (fontname);
401391#elif defined(TARGET_WIN32)
402392 if (fontname==OF_TTF_SANS){
403- fontname = " Arial " ;
393+ fontname = " arial " ;
404394 }else if (fontname==OF_TTF_SERIF){
405- fontname = " Times New Roman " ;
395+ fontname = " times new roman " ;
406396 }else if (fontname==OF_TTF_MONO){
407- fontname = " Courier New " ;
397+ fontname = " courier new " ;
408398 }
409- // FIXME: fs::path in input and output
410- filename = winFontPathByName (_fontname);
399+ filename = winFontPathByName (fontname);
411400#endif
412401 if (filename == " " ){
413402 ofLogError (" ofTrueTypeFont" ) << " loadFontFace(): couldn't find font " << fontname;
0 commit comments