Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: src/ports/SkFontHost_linux.cpp

Issue 195733007: Changes to SkFontHost_linux (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 SkDebugf("---- failed to open <%s> as a font\n", path); 319 SkDebugf("---- failed to open <%s> as a font\n", path);
320 return false; 320 return false;
321 } 321 }
322 } 322 }
323 323
324 void load_directory_fonts(const SkString& directory) { 324 void load_directory_fonts(const SkString& directory) {
325 SkOSFile::Iter iter(directory.c_str(), ".ttf"); 325 SkOSFile::Iter iter(directory.c_str(), ".ttf");
326 SkString name; 326 SkString name;
327 327
328 while (iter.next(&name, false)) { 328 while (iter.next(&name, false)) {
329 SkString filename(directory); 329 SkString filename(
330 filename.append(name); 330 SkOSPath::SkPathJoin(directory.c_str(), name.c_str()));
331 331
332 bool isFixedPitch; 332 bool isFixedPitch;
333 SkString realname; 333 SkString realname;
334 SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialize d warning 334 SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialize d warning
335 335
336 if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixe dPitch)) { 336 if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixe dPitch)) {
337 SkDebugf("------ can't load <%s> as a font\n", filename.c_str()) ; 337 SkDebugf("------ can't load <%s> as a font\n", filename.c_str()) ;
338 continue; 338 continue;
339 } 339 }
340 340
(...skipping 13 matching lines...) Expand all
354 } 354 }
355 355
356 SkOSFile::Iter dirIter(directory.c_str()); 356 SkOSFile::Iter dirIter(directory.c_str());
357 while (dirIter.next(&name, true)) { 357 while (dirIter.next(&name, true)) {
358 if (name.startsWith(".")) { 358 if (name.startsWith(".")) {
359 continue; 359 continue;
360 } 360 }
361 SkString dirname(directory); 361 SkString dirname(directory);
362 dirname.append(name); 362 dirname.append(name);
363 dirname.append(SK_FONT_FILE_DIR_SEPERATOR); 363 dirname.append(SK_FONT_FILE_DIR_SEPERATOR);
364 load_directory_fonts(dirname); 364 load_directory_fonts(dirname);
bungeman-skia 2014/03/13 15:11:05 Can we use SkOSPath::SkPathJoin here as well, and
hal.canary 2014/03/13 15:21:43 Done.
365 } 365 }
366 } 366 }
367 367
368 void load_system_fonts(const char* dir) { 368 void load_system_fonts(const char* dir) {
369 SkString baseDirectory(dir); 369 SkString baseDirectory(dir);
370 load_directory_fonts(baseDirectory); 370 load_directory_fonts(baseDirectory);
371 371
372 if (fFamilies.empty()) { 372 if (fFamilies.empty()) {
373 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString() ); 373 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString() );
374 fFamilies.push_back().reset(family); 374 fFamilies.push_back().reset(family);
375 family->appendTypeface(SkNEW(SkTypeface_Empty)); 375 family->appendTypeface(SkNEW(SkTypeface_Empty));
376 } 376 }
377 377
378 // Try to pick a default font. 378 // Try to pick a default font.
379 static const char* gDefaultNames[] = { 379 static const char* gDefaultNames[] = {
380 "Arial", "Verdana", "Times New Roman", NULL 380 "Arial", "Verdana", "Times New Roman", "Droid Sans", NULL
381 }; 381 };
382 for (size_t i = 0; i < SK_ARRAY_COUNT(gDefaultNames); ++i) { 382 for (size_t i = 0; i < SK_ARRAY_COUNT(gDefaultNames); ++i) {
383 SkFontStyleSet_Custom* set = this->onMatchFamily(gDefaultNames[i]); 383 SkFontStyleSet_Custom* set = this->onMatchFamily(gDefaultNames[i]);
384 if (NULL == set) { 384 if (NULL == set) {
385 continue; 385 continue;
386 } 386 }
387 387
388 SkTypeface* tf = set->matchStyle(SkFontStyle(SkFontStyle::kNormal_We ight, 388 SkTypeface* tf = set->matchStyle(SkFontStyle(SkFontStyle::kNormal_We ight,
389 SkFontStyle::kNormal_Wi dth, 389 SkFontStyle::kNormal_Wi dth,
390 SkFontStyle::kUpright_S lant)); 390 SkFontStyle::kUpright_S lant));
(...skipping 12 matching lines...) Expand all
403 } 403 }
404 404
405 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies; 405 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies;
406 SkFontStyleSet_Custom* gDefaultFamily; 406 SkFontStyleSet_Custom* gDefaultFamily;
407 SkTypeface* gDefaultNormal; 407 SkTypeface* gDefaultNormal;
408 }; 408 };
409 409
410 SkFontMgr* SkFontMgr::Factory() { 410 SkFontMgr* SkFontMgr::Factory() {
411 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX); 411 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX);
412 } 412 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698