| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkFontHost.h" | 8 #include "SkFontHost.h" |
| 9 #include "SkFontHost_FreeType_common.h" | 9 #include "SkFontHost_FreeType_common.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return false; | 316 return false; |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 void load_directory_fonts(const SkString& directory) { | 320 void load_directory_fonts(const SkString& directory) { |
| 321 SkOSFile::Iter iter(directory.c_str(), ".ttf"); | 321 SkOSFile::Iter iter(directory.c_str(), ".ttf"); |
| 322 SkString name; | 322 SkString name; |
| 323 | 323 |
| 324 while (iter.next(&name, false)) { | 324 while (iter.next(&name, false)) { |
| 325 SkString filename( | 325 SkString filename( |
| 326 SkOSPath::SkPathJoin(directory.c_str(), name.c_str())); | 326 SkOSPath::Join(directory.c_str(), name.c_str())); |
| 327 | 327 |
| 328 bool isFixedPitch; | 328 bool isFixedPitch; |
| 329 SkString realname; | 329 SkString realname; |
| 330 SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialize
d warning | 330 SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialize
d warning |
| 331 | 331 |
| 332 if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixe
dPitch)) { | 332 if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixe
dPitch)) { |
| 333 SkDebugf("------ can't load <%s> as a font\n", filename.c_str())
; | 333 SkDebugf("------ can't load <%s> as a font\n", filename.c_str())
; |
| 334 continue; | 334 continue; |
| 335 } | 335 } |
| 336 | 336 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 347 fFamilies.push_back().reset(addTo); | 347 fFamilies.push_back().reset(addTo); |
| 348 } | 348 } |
| 349 addTo->appendTypeface(tf); | 349 addTo->appendTypeface(tf); |
| 350 } | 350 } |
| 351 | 351 |
| 352 SkOSFile::Iter dirIter(directory.c_str()); | 352 SkOSFile::Iter dirIter(directory.c_str()); |
| 353 while (dirIter.next(&name, true)) { | 353 while (dirIter.next(&name, true)) { |
| 354 if (name.startsWith(".")) { | 354 if (name.startsWith(".")) { |
| 355 continue; | 355 continue; |
| 356 } | 356 } |
| 357 SkString dirname( | 357 SkString dirname(SkOSPath::Join(directory.c_str(), name.c_str())); |
| 358 SkOSPath::SkPathJoin(directory.c_str(), name.c_str())); | |
| 359 load_directory_fonts(dirname); | 358 load_directory_fonts(dirname); |
| 360 } | 359 } |
| 361 } | 360 } |
| 362 | 361 |
| 363 void load_system_fonts(const char* dir) { | 362 void load_system_fonts(const char* dir) { |
| 364 SkString baseDirectory(dir); | 363 SkString baseDirectory(dir); |
| 365 load_directory_fonts(baseDirectory); | 364 load_directory_fonts(baseDirectory); |
| 366 | 365 |
| 367 if (fFamilies.empty()) { | 366 if (fFamilies.empty()) { |
| 368 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString()
); | 367 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString()
); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 398 } | 397 } |
| 399 | 398 |
| 400 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies; | 399 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies; |
| 401 SkFontStyleSet_Custom* gDefaultFamily; | 400 SkFontStyleSet_Custom* gDefaultFamily; |
| 402 SkTypeface* gDefaultNormal; | 401 SkTypeface* gDefaultNormal; |
| 403 }; | 402 }; |
| 404 | 403 |
| 405 SkFontMgr* SkFontMgr::Factory() { | 404 SkFontMgr* SkFontMgr::Factory() { |
| 406 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX); | 405 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX); |
| 407 } | 406 } |
| OLD | NEW |