| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/font_list.h" | 5 #include "content/common/font_list.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include <fontconfig/fontconfig.h> | 12 #include <fontconfig/fontconfig.h> |
| 13 | 13 |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 std::unique_ptr<FcPattern, decltype(&FcPatternDestroy)> CreateFormatPattern( | 18 std::unique_ptr<FcPattern, decltype(&FcPatternDestroy)> CreateFormatPattern( |
| 19 const char* format) { | 19 const char* format) { |
| 20 std::unique_ptr<FcPattern, decltype(&FcPatternDestroy)> pattern( | 20 std::unique_ptr<FcPattern, decltype(&FcPatternDestroy)> pattern( |
| 21 FcPatternCreate(), FcPatternDestroy); | 21 FcPatternCreate(), FcPatternDestroy); |
| 22 FcPatternAddBool(pattern.get(), FC_SCALABLE, FcTrue); | 22 FcPatternAddBool(pattern.get(), FC_SCALABLE, FcTrue); |
| 23 FcPatternAddString(pattern.get(), FC_FONTFORMAT, | 23 FcPatternAddString(pattern.get(), FC_FONTFORMAT, |
| 24 reinterpret_cast<const FcChar8*>(format)); | 24 reinterpret_cast<const FcChar8*>(format)); |
| 25 return pattern; | 25 return pattern; |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { | 28 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() { |
| 29 DCHECK(GetFontListTaskRunner()->RunsTasksInCurrentSequence()); |
| 30 |
| 29 std::unique_ptr<base::ListValue> font_list(new base::ListValue); | 31 std::unique_ptr<base::ListValue> font_list(new base::ListValue); |
| 30 | 32 |
| 31 std::unique_ptr<FcObjectSet, decltype(&FcObjectSetDestroy)> object_set( | 33 std::unique_ptr<FcObjectSet, decltype(&FcObjectSetDestroy)> object_set( |
| 32 FcObjectSetBuild(FC_FAMILY, NULL), FcObjectSetDestroy); | 34 FcObjectSetBuild(FC_FAMILY, NULL), FcObjectSetDestroy); |
| 33 | 35 |
| 34 std::set<std::string> sorted_families; | 36 std::set<std::string> sorted_families; |
| 35 | 37 |
| 36 // See https://www.freetype.org/freetype2/docs/reference/ft2-font_formats.html | 38 // See https://www.freetype.org/freetype2/docs/reference/ft2-font_formats.html |
| 37 // for the list of possible formats. | 39 // for the list of possible formats. |
| 38 const char* allowed_formats[] = { "TrueType", "CFF" }; | 40 const char* allowed_formats[] = { "TrueType", "CFF" }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 font_item->AppendString(family); | 65 font_item->AppendString(family); |
| 64 font_item->AppendString(family); // localized name. | 66 font_item->AppendString(family); // localized name. |
| 65 // TODO(yusukes): Support localized family names. | 67 // TODO(yusukes): Support localized family names. |
| 66 font_list->Append(std::move(font_item)); | 68 font_list->Append(std::move(font_item)); |
| 67 } | 69 } |
| 68 | 70 |
| 69 return font_list; | 71 return font_list; |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace content | 74 } // namespace content |
| OLD | NEW |