summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 01:13:41 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 01:13:41 +0000
commitc601cd327760f385f03d228967d8aa7445712dd6 (patch)
tree3849dc1f70c468d26dc2543db85979eb8a5b8c1d /chrome
parent24e5219bf22811b32ca821c35c85f31e2697160a (diff)
downloadchromium_src-c601cd327760f385f03d228967d8aa7445712dd6.zip
chromium_src-c601cd327760f385f03d228967d8aa7445712dd6.tar.gz
chromium_src-c601cd327760f385f03d228967d8aa7445712dd6.tar.bz2
move chrome_font to app/gfx
http://crbug.com/11387 Review URL: http://codereview.chromium.org/115010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_win.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_win.h2
-rw-r--r--chrome/browser/drag_utils.cc2
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc2
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h2
-rw-r--r--chrome/browser/printing/printed_document.cc2
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h2
-rw-r--r--chrome/browser/views/bookmark_table_view.cc2
-rw-r--r--chrome/browser/views/constrained_window_impl.cc2
-rw-r--r--chrome/browser/views/download_item_view.h2
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc2
-rw-r--r--chrome/browser/views/location_bar_view.h2
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc2
-rw-r--r--chrome/browser/views/options/languages_page_view.cc2
-rw-r--r--chrome/browser/views/options/options_group_view.cc2
-rw-r--r--chrome/browser/views/sad_tab_view.h2
-rw-r--r--chrome/browser/views/shell_dialogs_win.cc2
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc2
-rw-r--r--chrome/chrome.gyp15
-rw-r--r--chrome/common/common.vcproj8
-rw-r--r--chrome/common/gfx/chrome_font.h237
-rw-r--r--chrome/common/gfx/chrome_font_gtk.cc85
-rw-r--r--chrome/common/gfx/chrome_font_mac.mm87
-rw-r--r--chrome/common/gfx/chrome_font_skia.cc163
-rw-r--r--chrome/common/gfx/chrome_font_unittest.cc57
-rw-r--r--chrome/common/gfx/chrome_font_win.cc211
-rw-r--r--chrome/common/gfx/text_elider.cc2
-rw-r--r--chrome/common/gfx/text_elider.h2
-rw-r--r--chrome/common/gfx/text_elider_unittest.cc2
-rw-r--r--chrome/common/win_util.h2
-rw-r--r--chrome/test/unit/unittests.vcproj4
-rw-r--r--chrome/views/controls/button/menu_button.h2
-rw-r--r--chrome/views/controls/button/native_button.h2
-rw-r--r--chrome/views/controls/button/text_button.h2
-rw-r--r--chrome/views/controls/combo_box.cc2
-rw-r--r--chrome/views/controls/label.cc2
-rw-r--r--chrome/views/controls/label.h2
-rw-r--r--chrome/views/controls/link.cc2
-rw-r--r--chrome/views/controls/menu/chrome_menu.h2
-rw-r--r--chrome/views/controls/menu/menu.cc2
-rw-r--r--chrome/views/controls/tabbed_pane.cc2
-rw-r--r--chrome/views/controls/text_field.h2
-rw-r--r--chrome/views/window/custom_frame_view.cc2
-rw-r--r--chrome/views/window/dialog_client_view.cc2
-rw-r--r--chrome/views/window/dialog_client_view.h2
-rw-r--r--chrome/views/window/window_win.cc2
48 files changed, 51 insertions, 894 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index ba7b57f..da73d98 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -12,12 +12,12 @@
#include <atlmisc.h>
#include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl.
+#include "app/gfx/chrome_font.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/views/controls/menu/menu.h"
#include "webkit/glue/window_open_disposition.h"
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index 70e13052..a671e40 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -8,6 +8,7 @@
#include <algorithm>
+#include "app/gfx/chrome_font.h"
#include "app/resource_bundle.h"
#include "base/basictypes.h"
#include "base/gfx/gtk_util.h"
@@ -21,7 +22,6 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/notification_service.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
index 65b4f34..10f32b1 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
@@ -12,6 +12,7 @@
#include <cmath>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/command_line.h"
@@ -28,7 +29,6 @@
#include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
#include "chrome/browser/views/location_bar_view.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/notification_service.h"
#include "chrome/views/view.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.h b/chrome/browser/autocomplete/autocomplete_popup_view_win.h
index afcc353..f98346d 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.h
@@ -12,11 +12,11 @@
#include <string>
+#include "app/gfx/chrome_font.h"
#include "base/scoped_ptr.h"
#include "base/win_util.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "webkit/glue/window_open_disposition.h"
class AutocompletePopupModel;
diff --git a/chrome/browser/drag_utils.cc b/chrome/browser/drag_utils.cc
index 2cef2ec..a715492 100644
--- a/chrome/browser/drag_utils.cc
+++ b/chrome/browser/drag_utils.cc
@@ -9,6 +9,7 @@
#include <shobjidl.h>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/file_util.h"
@@ -16,7 +17,6 @@
#include "base/gfx/point.h"
#include "base/string_util.h"
#include "chrome/browser/views/bookmark_bar_view.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/os_exchange_data.h"
#include "chrome/common/win_util.h"
#include "chrome/views/controls/button/text_button.h"
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 5697e50c..4a89aa8 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/gtk/download_item_gtk.h"
+#include "app/gfx/chrome_font.h"
#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/string_util.h"
@@ -13,7 +14,6 @@
#include "chrome/browser/gtk/download_shelf_gtk.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/gtk/nine_box.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/text_elider.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 4d576a2..74f730d 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -9,10 +9,10 @@
#include "app/animation.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/gfx/rect.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/owned_widget_gtk.h"
#include "skia/include/SkBitmap.h"
diff --git a/chrome/browser/printing/printed_document.cc b/chrome/browser/printing/printed_document.cc
index b42b375..902554b 100644
--- a/chrome/browser/printing/printed_document.cc
+++ b/chrome/browser/printing/printed_document.cc
@@ -6,13 +6,13 @@
#include <set>
+#include "app/gfx/chrome_font.h"
#include "base/message_loop.h"
#include "base/time.h"
#include "chrome/browser/printing/page_number.h"
#include "chrome/browser/printing/page_overlays.h"
#include "chrome/browser/printing/printed_pages_source.h"
#include "chrome/browser/printing/printed_page.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/emf.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/common/time_format.h"
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
index 0aa5dc0..aa40435 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
@@ -5,10 +5,10 @@
#ifndef CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_
#define CHROME_BROWSER_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_
+#include "app/gfx/chrome_font.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/view.h"
class AutocompleteEditModel;
diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc
index 61be2b0..d3da5e8 100644
--- a/chrome/browser/views/bookmark_table_view.cc
+++ b/chrome/browser/views/bookmark_table_view.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/views/bookmark_table_view.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/resource_bundle.h"
#include "base/base_drag_source.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
@@ -12,7 +13,6 @@
#include "chrome/browser/bookmarks/bookmark_table_model.h"
#include "chrome/browser/profile.h"
#include "chrome/common/drag_drop_types.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/os_exchange_data.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index ab42c6b..a99eb60 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/views/constrained_window_impl.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/rect.h"
@@ -18,7 +19,6 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/window_sizer.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/path.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/common/notification_service.h"
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index 06c344a..c5df73d 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -18,12 +18,12 @@
#include <string>
+#include "app/gfx/chrome_font.h"
#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
#include "base/timer.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/icon_manager.h"
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 24bcc2b..56c1d17 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -5,12 +5,12 @@
#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/path.h"
#include "chrome/common/win_util.h"
#include "chrome/views/controls/button/image_button.h"
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index 883d3c3..5dac2ef 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "app/gfx/chrome_font.h"
#include "base/gfx/rect.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
@@ -16,7 +17,6 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/browser/views/info_bubble.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/controls/hwnd_view.h"
#include "chrome/views/controls/image_view.h"
#include "chrome/views/controls/label.h"
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index a026b4d..fb1c57a 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -12,6 +12,7 @@
#include <vector>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/file_util.h"
@@ -21,7 +22,6 @@
#include "chrome/browser/character_encoding.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/views/standard_layout.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/views/controls/button/native_button.h"
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 8337676..4752c80 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/views/options/languages_page_view.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/file_util.h"
@@ -21,7 +22,6 @@
#include "chrome/browser/views/options/language_combobox_model.h"
#include "chrome/browser/views/restart_message_box.h"
#include "chrome/browser/views/standard_layout.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/views/controls/button/radio_button.h"
diff --git a/chrome/browser/views/options/options_group_view.cc b/chrome/browser/views/options/options_group_view.cc
index fa4fd97..7985a41 100644
--- a/chrome/browser/views/options/options_group_view.cc
+++ b/chrome/browser/views/options/options_group_view.cc
@@ -8,11 +8,11 @@
#include "chrome/browser/views/options/options_group_view.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/native_theme.h"
#include "chrome/browser/views/standard_layout.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/grid_layout.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/controls/separator.h"
diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h
index 3013ecf..5e9415d 100644
--- a/chrome/browser/views/sad_tab_view.h
+++ b/chrome/browser/views/sad_tab_view.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_SAD_TAB_H_
#define CHROME_BROWSER_VIEWS_SAD_TAB_H_
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/view.h"
class SkBitmap;
diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc
index 35879b9..99664a1 100644
--- a/chrome/browser/views/shell_dialogs_win.cc
+++ b/chrome/browser/views/shell_dialogs_win.cc
@@ -12,13 +12,13 @@
#include <algorithm>
#include <set>
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "base/file_util.h"
#include "base/registry.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/win_util.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 039954f..285ebcc 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -7,13 +7,13 @@
#include "chrome/browser/views/tabs/tab_renderer.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tabs/tab_strip_model.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/win_util.h"
#include "chrome/views/widget/widget.h"
#include "chrome/views/window/non_client_view.h"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 99099a6..0da07eb 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -108,6 +108,7 @@
},
},
{
+ # TODO(beng): rename to 'app' when moves to top level.
'target_name': 'app_base',
'type': '<(library)',
'msvs_guid': '4631946D-7D5F-44BD-A5A8-504C0A7033BE',
@@ -129,7 +130,12 @@
'../app/gfx/chrome_canvas.cc',
'../app/gfx/chrome_canvas.h',
'../app/gfx/chrome_canvas_linux.cc',
- '../app/gfx/chrome_canvas_win.cc',
+ '../app/gfx/chrome_canvas_win.cc',
+ '../app/gfx/chrome_font.h',
+ '../app/gfx/chrome_font_gtk.cc',
+ '../app/gfx/chrome_font_mac.mm',
+ '../app/gfx/chrome_font_skia.cc',
+ '../app/gfx/chrome_font_win.cc',
'../app/l10n_util.cc',
'../app/l10n_util.h',
'../app/l10n_util_posix.cc',
@@ -220,11 +226,6 @@
'common/extensions/url_pattern.h',
'common/extensions/user_script.cc',
'common/extensions/user_script.h',
- 'common/gfx/chrome_font.h',
- 'common/gfx/chrome_font_gtk.cc',
- 'common/gfx/chrome_font_mac.mm',
- 'common/gfx/chrome_font_skia.cc',
- 'common/gfx/chrome_font_win.cc',
'common/gfx/color_utils.cc',
'common/gfx/color_utils.h',
'common/gfx/emf.cc',
@@ -2495,7 +2496,7 @@
'common/extensions/url_pattern_unittest.cc',
'common/extensions/user_script_unittest.cc',
'common/file_descriptor_set_unittest.cc',
- 'common/gfx/chrome_font_unittest.cc',
+ '../app/gfx/chrome_font_unittest.cc',
'common/gfx/emf_unittest.cc',
'common/gfx/icon_util_unittest.cc',
'common/gfx/text_elider_unittest.cc',
diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj
index f8b4613..d359d59 100644
--- a/chrome/common/common.vcproj
+++ b/chrome/common/common.vcproj
@@ -149,14 +149,6 @@
Name="gfx"
>
<File
- RelativePath=".\gfx\chrome_font.h"
- >
- </File>
- <File
- RelativePath=".\gfx\chrome_font_win.cc"
- >
- </File>
- <File
RelativePath=".\gfx\color_utils.cc"
>
</File>
diff --git a/chrome/common/gfx/chrome_font.h b/chrome/common/gfx/chrome_font.h
deleted file mode 100644
index 0358afc..0000000
--- a/chrome/common/gfx/chrome_font.h
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_GFX_CHROME_FONT_H_
-#define CHROME_COMMON_GFX_CHROME_FONT_H_
-
-#include "build/build_config.h"
-
-#include <string>
-
-#if defined(OS_WIN)
-typedef struct HFONT__* HFONT;
-#elif defined(OS_LINUX)
-#include "skia/include/SkRefCnt.h"
-class SkPaint;
-class SkTypeface;
-#endif
-
-#if defined(OS_WIN)
-typedef struct HFONT__* NativeFont;
-#elif defined(OS_MACOSX)
-#ifdef __OBJC__
-@class NSFont;
-#else
-class NSFont;
-#endif
-typedef NSFont* NativeFont;
-#elif defined(OS_LINUX)
-class SkTypeface;
-typedef SkTypeface* NativeFont;
-#else // null port.
-#error No known OS defined
-#endif
-
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
-#include "base/scoped_ptr.h"
-
-// ChromeFont provides a wrapper around an underlying font. Copy and assignment
-// operators are explicitly allowed, and cheap.
-class ChromeFont {
- public:
- // The following constants indicate the font style.
- enum {
- NORMAL = 0,
- BOLD = 1,
- ITALIC = 2,
- UNDERLINED = 4,
- };
-
- // Creates a ChromeFont given font name (e.g. arial), font size (e.g. 12).
- // Skia actually expects a family name and not a font name.
- static ChromeFont CreateFont(const std::wstring& font_name, int font_size);
-
- ~ChromeFont() { }
-
- // Returns a new Font derived from the existing font.
- // size_deta is the size to add to the current font. For example, a value
- // of 5 results in a font 5 units bigger than this font.
- ChromeFont DeriveFont(int size_delta) const {
- return DeriveFont(size_delta, style());
- }
-
- // Returns a new Font derived from the existing font.
- // size_deta is the size to add to the current font. See the single
- // argument version of this method for an example.
- // The style parameter specifies the new style for the font, and is a
- // bitmask of the values: BOLD, ITALIC and UNDERLINED.
- ChromeFont DeriveFont(int size_delta, int style) const;
-
- // Returns the number of vertical pixels needed to display characters from
- // the specified font.
- int height() const;
-
- // Returns the baseline, or ascent, of the font.
- int baseline() const;
-
- // Returns the average character width for the font.
- int ave_char_width() const;
-
- // Returns the number of horizontal pixels needed to display the specified
- // string.
- int GetStringWidth(const std::wstring& text) const;
-
- // Returns the expected number of horizontal pixels needed to display
- // the specified length of characters.
- // Call GetStringWidth() to retrieve the actual number.
- int GetExpectedTextWidth(int length) const;
-
- // Returns the style of the font.
- int style() const;
-
- // Font Name.
- // It is actually a font family name, because Skia expects a family name
- // and not a font name.
- std::wstring FontName();
-
- // Font Size.
- int FontSize();
-
- NativeFont nativeFont() const;
-
- // Creates a font with the default name and style.
- ChromeFont();
-
-#if defined(OS_WIN)
- // Creates a ChromeFont from the specified HFONT. The supplied HFONT is
- // effectively copied.
- static ChromeFont CreateFont(HFONT hfont);
-
- // Returns the handle to the underlying HFONT. This is used by ChromeCanvas to
- // draw text.
- HFONT hfont() const { return font_ref_->hfont(); }
-
- // Dialog units to pixels conversion.
- // See http://support.microsoft.com/kb/145994 for details.
- int horizontal_dlus_to_pixels(int dlus) {
- return dlus * font_ref_->dlu_base_x() / 4;
- }
- int vertical_dlus_to_pixels(int dlus) {
- return dlus * font_ref_->height() / 8;
- }
-#elif defined(OS_LINUX)
- // We need a copy constructor and assignment operator to deal with
- // the Skia reference counting.
- ChromeFont(const ChromeFont& other);
- ChromeFont& operator=(const ChromeFont& other);
- // Setup a Skia context to use the current typeface
- void PaintSetup(SkPaint* paint) const;
-#endif
-
- private:
-
-#if defined(OS_WIN)
- // Chrome text drawing bottoms out in the Windows GDI functions that take an
- // HFONT (an opaque handle into Windows). To avoid lots of GDI object
- // allocation and destruction, ChromeFont indirectly refers to the HFONT
- // by way of an HFontRef. That is, every ChromeFont has an HFontRef, which
- // has an HFONT.
- //
- // HFontRef is reference counted. Upon deletion, it deletes the HFONT.
- // By making HFontRef maintain the reference to the HFONT, multiple
- // HFontRefs can share the same HFONT, and ChromeFont can provide value
- // semantics.
- class HFontRef : public base::RefCounted<HFontRef> {
- public:
- // This constructor takes control of the HFONT, and will delete it when
- // the HFontRef is deleted.
- HFontRef(HFONT hfont,
- int height,
- int baseline,
- int ave_char_width,
- int style,
- int dlu_base_x);
- ~HFontRef();
-
- // Accessors
- HFONT hfont() const { return hfont_; }
- int height() const { return height_; }
- int baseline() const { return baseline_; }
- int ave_char_width() const { return ave_char_width_; }
- int style() const { return style_; }
- int dlu_base_x() const { return dlu_base_x_; }
-
- private:
- const HFONT hfont_;
- const int height_;
- const int baseline_;
- const int ave_char_width_;
- const int style_;
- // Constants used in converting dialog units to pixels.
- const int dlu_base_x_;
-
- DISALLOW_COPY_AND_ASSIGN(HFontRef);
- };
-
- // Returns the base font ref. This should ONLY be invoked on the
- // UI thread.
- static HFontRef* GetBaseFontRef();
-
- // Creates and returns a new HFONTRef from the specified HFONT.
- static HFontRef* CreateHFontRef(HFONT font);
-
- explicit ChromeFont(HFontRef* font_ref) : font_ref_(font_ref) { }
-
- // Reference to the base font all fonts are derived from.
- static HFontRef* base_font_ref_;
-
- // Indirect reference to the HFontRef, which references the underlying HFONT.
- scoped_refptr<HFontRef> font_ref_;
-#elif defined(OS_LINUX)
- explicit ChromeFont(SkTypeface* typeface, const std::wstring& name,
- int size, int style);
- // Calculate and cache the font metrics.
- void calculateMetrics();
- // Make |this| a copy of |other|.
- void CopyChromeFont(const ChromeFont& other);
-
- // The default font, used for the default constructor.
- static ChromeFont* default_font_;
-
- // These two both point to the same SkTypeface. We use the SkAutoUnref to
- // handle the reference counting, but without @typeface_ we would have to
- // cast the SkRefCnt from @typeface_helper_ every time.
- scoped_ptr<SkAutoUnref> typeface_helper_;
- SkTypeface *typeface_;
-
- // Additional information about the face
- // Skia actually expects a family name and not a font name.
- std::wstring font_family_;
- int font_size_;
- int style_;
-
- // Cached metrics, generated at construction
- int height_;
- int ascent_;
- int avg_width_;
-#elif defined(OS_MACOSX)
- explicit ChromeFont(const std::wstring& font_name, int font_size, int style);
-
- // Calculate and cache the font metrics.
- void calculateMetrics();
-
- std::wstring font_name_;
- int font_size_;
- int style_;
-
- // Cached metrics, generated at construction
- int height_;
- int ascent_;
- int avg_width_;
-#endif
-
-};
-
-#endif // CHROME_COMMON_GFX_CHROME_FONT_H_
diff --git a/chrome/common/gfx/chrome_font_gtk.cc b/chrome/common/gfx/chrome_font_gtk.cc
deleted file mode 100644
index f0d2120..0000000
--- a/chrome/common/gfx/chrome_font_gtk.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/gfx/chrome_font.h"
-
-#include <fontconfig/fontconfig.h>
-#include <gtk/gtk.h>
-
-#include "base/string_util.h"
-
-ChromeFont* ChromeFont::default_font_ = NULL;
-
-// Find the best match font for |family_name| in the same way as Skia
-// to make sure CreateFont() successfully creates default font.
-// In Skia, it only checks the best match font. If it failed to find,
-// SkTypeface will be NULL for that font family. It eventually causes segfault.
-// For example, family_name = "Sans" and system may have various fonts.
-// The first font family in FcPattern will be "DejaVu Sans" but a font family
-// returned by FcFontMatch will be "VL PGothic".
-// In this case, SkTypeface for "Sans" returns NULL even if system has font
-// for "Sans" font family.
-// See FontMatch() in skia/ports/SkFontHost_fontconfig.cpp for more detail.
-static std::wstring FindBestMatchFontFamilyName(const char* family_name) {
- FcPattern* pattern = FcPatternCreate();
- FcValue fcvalue;
- fcvalue.type = FcTypeString;
- char* family_name_copy = strdup(family_name);
- fcvalue.u.s = reinterpret_cast<FcChar8*>(family_name_copy);
- FcPatternAdd(pattern, FC_FAMILY, fcvalue, 0);
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
- FcResult result;
- FcPattern* match = FcFontMatch(0, pattern, &result);
- DCHECK(match) << "Could not find font: " << family_name;
- FcChar8* match_family;
- FcPatternGetString(match, FC_FAMILY, 0, &match_family);
-
- std::wstring font_family = UTF8ToWide(
- reinterpret_cast<char*>(match_family));
- FcPatternDestroy(match);
- FcPatternDestroy(pattern);
- free(family_name_copy);
- return font_family;
-}
-
-// Get the default gtk system font (name and size).
-ChromeFont::ChromeFont() {
- if (default_font_ == NULL) {
- gtk_init(NULL, NULL);
- GtkSettings* settings = gtk_settings_get_default();
-
- GValue value = {0};
- g_value_init(&value, G_TYPE_STRING);
- g_object_get_property(G_OBJECT(settings), "gtk-font-name", &value);
-
- // gtk-font-name may be wrapped in quotes.
- gchar* font_name = g_strdup_value_contents(&value);
- gchar* font_ptr = font_name;
- if (font_ptr[0] == '\"')
- font_ptr++;
- if (font_ptr[strlen(font_ptr) - 1] == '\"')
- font_ptr[strlen(font_ptr) - 1] = '\0';
-
- PangoFontDescription* desc =
- pango_font_description_from_string(font_ptr);
- gint size = pango_font_description_get_size(desc);
- const char* family_name = pango_font_description_get_family(desc);
-
- // Find best match font for |family_name| to make sure we can get
- // SkTypeface for default font.
- // TODO(agl): remove this.
- std::wstring font_family = FindBestMatchFontFamilyName(family_name);
-
- default_font_ = new ChromeFont(CreateFont(font_family, size / PANGO_SCALE));
-
- pango_font_description_free(desc);
- g_free(font_name);
- g_value_unset(&value);
-
- DCHECK(default_font_);
- }
-
- CopyChromeFont(*default_font_);
-}
diff --git a/chrome/common/gfx/chrome_font_mac.mm b/chrome/common/gfx/chrome_font_mac.mm
deleted file mode 100644
index 590c54e..0000000
--- a/chrome/common/gfx/chrome_font_mac.mm
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/gfx/chrome_font.h"
-
-#include <Cocoa/Cocoa.h>
-
-#include "base/logging.h"
-#include "base/sys_string_conversions.h"
-
-// static
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_name,
- int font_size) {
- return ChromeFont(font_name, font_size, NORMAL);
-}
-
-ChromeFont::ChromeFont(const std::wstring& font_name, int font_size, int style)
- : font_name_(font_name),
- font_size_(font_size),
- style_(style) {
- calculateMetrics();
-}
-
-ChromeFont::ChromeFont()
- : font_size_([NSFont systemFontSize]),
- style_(NORMAL) {
- NSFont* system_font = [NSFont systemFontOfSize:font_size_];
- font_name_ = base::SysNSStringToWide([system_font fontName]);
- calculateMetrics();
-}
-
-void ChromeFont::calculateMetrics() {
- NSFont* font = nativeFont();
- height_ = [font xHeight];
- ascent_ = [font ascender];
- avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width;
-}
-
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
- return ChromeFont(font_name_, font_size_ + size_delta, style);
-}
-
-int ChromeFont::height() const {
- return height_;
-}
-
-int ChromeFont::baseline() const {
- return ascent_;
-}
-
-int ChromeFont::ave_char_width() const {
- return avg_width_;
-}
-
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
- NSFont* font = nativeFont();
- NSString* ns_string = base::SysWideToNSString(text);
- NSDictionary* attributes =
- [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
- NSSize string_size = [ns_string sizeWithAttributes:attributes];
- return string_size.width;
-}
-
-int ChromeFont::GetExpectedTextWidth(int length) const {
- return length * avg_width_;
-}
-
-int ChromeFont::style() const {
- return style_;
-}
-
-std::wstring ChromeFont::FontName() {
- return font_name_;
-}
-
-int ChromeFont::FontSize() {
- return font_size_;
-}
-
-NativeFont ChromeFont::nativeFont() const {
- // TODO(pinkerton): apply |style_| to font.
- // We could cache this, but then we'd have to conditionally change the
- // dtor just for MacOS. Not sure if we want to/need to do that.
- return [NSFont fontWithName:base::SysWideToNSString(font_name_)
- size:font_size_];
-}
diff --git a/chrome/common/gfx/chrome_font_skia.cc b/chrome/common/gfx/chrome_font_skia.cc
deleted file mode 100644
index ae62a7a..0000000
--- a/chrome/common/gfx/chrome_font_skia.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/gfx/chrome_font.h"
-
-#include "base/logging.h"
-#include "base/sys_string_conversions.h"
-
-#include "skia/include/SkTypeface.h"
-#include "skia/include/SkPaint.h"
-
-ChromeFont::ChromeFont(const ChromeFont& other) {
- CopyChromeFont(other);
-}
-
-ChromeFont& ChromeFont::operator=(const ChromeFont& other) {
- CopyChromeFont(other);
- return *this;
-}
-
-ChromeFont::ChromeFont(SkTypeface* tf, const std::wstring& font_family,
- int font_size, int style)
- : typeface_helper_(new SkAutoUnref(tf)),
- typeface_(tf),
- font_family_(font_family),
- font_size_(font_size),
- style_(style) {
- tf->ref();
- calculateMetrics();
-}
-
-void ChromeFont::calculateMetrics() {
- SkPaint paint;
- SkPaint::FontMetrics metrics;
-
- PaintSetup(&paint);
- paint.getFontMetrics(&metrics);
-
- ascent_ = SkScalarRound(-metrics.fAscent);
- height_ = SkScalarRound(-metrics.fAscent + metrics.fDescent +
- metrics.fLeading);
-
- if (metrics.fAvgCharWidth) {
- avg_width_ = SkScalarRound(metrics.fAvgCharWidth);
- } else {
- static const char x_char = 'x';
- paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
- SkScalar width = paint.measureText(&x_char, 1);
-
- avg_width_ = static_cast<int>(ceilf(SkScalarToFloat(width)));
- }
-}
-
-void ChromeFont::CopyChromeFont(const ChromeFont& other) {
- typeface_helper_.reset(new SkAutoUnref(other.typeface_));
- typeface_ = other.typeface_;
- typeface_->ref();
- font_family_ = other.font_family_;
- font_size_ = other.font_size_;
- style_ = other.style_;
- height_ = other.height_;
- ascent_ = other.ascent_;
- avg_width_ = other.avg_width_;
-}
-
-int ChromeFont::height() const {
- return height_;
-}
-
-int ChromeFont::baseline() const {
- return ascent_;
-}
-
-int ChromeFont::ave_char_width() const {
- return avg_width_;
-}
-
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_family,
- int font_size) {
- DCHECK_GT(font_size, 0);
-
- SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family).c_str(),
- SkTypeface::kNormal);
- DCHECK(tf) << "Could not find font: " << base::SysWideToUTF8(font_family);
- SkAutoUnref tf_helper(tf);
-
- return ChromeFont(tf, font_family, font_size, NORMAL);
-}
-
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
- // If the delta is negative, if must not push the size below 1
- if (size_delta < 0) {
- DCHECK_LT(-size_delta, font_size_);
- }
-
- if (style == style_) {
- // Fast path, we just use the same typeface at a different size
- return ChromeFont(typeface_, font_family_, font_size_ + size_delta, style_);
- }
-
- // If the style has changed we may need to load a new face
- int skstyle = SkTypeface::kNormal;
- if (BOLD & style)
- skstyle |= SkTypeface::kBold;
- if (ITALIC & style)
- skstyle |= SkTypeface::kItalic;
-
- SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family_).c_str(),
- static_cast<SkTypeface::Style>(skstyle));
- SkAutoUnref tf_helper(tf);
-
- return ChromeFont(tf, font_family_, font_size_ + size_delta, skstyle);
-}
-
-void ChromeFont::PaintSetup(SkPaint* paint) const {
- paint->setAntiAlias(false);
- paint->setSubpixelText(false);
- paint->setTextSize(SkFloatToScalar(font_size_));
- paint->setTypeface(typeface_);
- paint->setFakeBoldText((BOLD & style_) && !typeface_->isBold());
- paint->setTextSkewX((ITALIC & style_) && !typeface_->isItalic() ?
- -SK_Scalar1/4 : 0);
-}
-
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
- const std::string utf8(base::SysWideToUTF8(text));
-
- SkPaint paint;
- PaintSetup(&paint);
- paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
- SkScalar width = paint.measureText(utf8.data(), utf8.size());
-
- int breadth = static_cast<int>(ceilf(SkScalarToFloat(width)));
- // Check for overflow. We should probably be returning an unsigned
- // int, but in practice we'll never have a screen massive enough
- // to show that much text anyway.
- if (breadth < 0)
- return INT_MAX;
-
- return breadth;
-}
-
-int ChromeFont::GetExpectedTextWidth(int length) const {
- return length * avg_width_;
-}
-
-
-int ChromeFont::style() const {
- return style_;
-}
-
-std::wstring ChromeFont::FontName() {
- return font_family_;
-}
-
-int ChromeFont::FontSize() {
- return font_size_;
-}
-
-NativeFont ChromeFont::nativeFont() const {
- return typeface_;
-}
diff --git a/chrome/common/gfx/chrome_font_unittest.cc b/chrome/common/gfx/chrome_font_unittest.cc
deleted file mode 100644
index d0b61d2..0000000
--- a/chrome/common/gfx/chrome_font_unittest.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/gfx/chrome_font.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class ChromeFontTest : public testing::Test {
-};
-
-TEST_F(ChromeFontTest, LoadArial) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ASSERT_TRUE(cf.nativeFont());
- ASSERT_EQ(cf.style(), ChromeFont::NORMAL);
- ASSERT_EQ(cf.FontSize(), 16);
- ASSERT_EQ(cf.FontName(), L"Arial");
-}
-
-TEST_F(ChromeFontTest, LoadArialBold) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ChromeFont bold(cf.DeriveFont(0, ChromeFont::BOLD));
- ASSERT_TRUE(bold.nativeFont());
- ASSERT_EQ(bold.style(), ChromeFont::BOLD);
-}
-
-TEST_F(ChromeFontTest, Ascent) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ASSERT_GT(cf.baseline(), 2);
- ASSERT_LT(cf.baseline(), 20);
-}
-
-TEST_F(ChromeFontTest, Height) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ASSERT_GT(cf.baseline(), 2);
- ASSERT_LT(cf.baseline(), 20);
-}
-
-TEST_F(ChromeFontTest, AvgWidths) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ASSERT_EQ(cf.GetExpectedTextWidth(0), 0);
- ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0));
- ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1));
- ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2));
-}
-
-TEST_F(ChromeFontTest, Widths) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ASSERT_EQ(cf.GetStringWidth(L""), 0);
- ASSERT_GT(cf.GetStringWidth(L"a"), cf.GetStringWidth(L""));
- ASSERT_GT(cf.GetStringWidth(L"ab"), cf.GetStringWidth(L"a"));
- ASSERT_GT(cf.GetStringWidth(L"abc"), cf.GetStringWidth(L"ab"));
-}
-
-} // anonymous namespace
diff --git a/chrome/common/gfx/chrome_font_win.cc b/chrome/common/gfx/chrome_font_win.cc
deleted file mode 100644
index 71b10d8..0000000
--- a/chrome/common/gfx/chrome_font_win.cc
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/gfx/chrome_font.h"
-
-#include <windows.h>
-#include <math.h>
-
-#include <algorithm>
-
-#include "app/l10n_util_win.h"
-#include "base/logging.h"
-#include "base/win_util.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-
-/*static*/
-ChromeFont::HFontRef* ChromeFont::base_font_ref_;
-
-// If the tmWeight field of a TEXTMETRIC structure has a value >= this, the
-// font is bold.
-static const int kTextMetricWeightBold = 700;
-
-//
-// ChromeFont
-//
-
-ChromeFont::ChromeFont()
- : font_ref_(GetBaseFontRef()) {
-}
-
-int ChromeFont::height() const {
- return font_ref_->height();
-}
-
-int ChromeFont::baseline() const {
- return font_ref_->baseline();
-}
-
-int ChromeFont::ave_char_width() const {
- return font_ref_->ave_char_width();
-}
-
-int ChromeFont::GetExpectedTextWidth(int length) const {
- return length * std::min(font_ref_->dlu_base_x(), ave_char_width());
-}
-
-int ChromeFont::style() const {
- return font_ref_->style();
-}
-
-NativeFont ChromeFont::nativeFont() const {
- return hfont();
-}
-
-// static
-ChromeFont ChromeFont::CreateFont(HFONT font) {
- DCHECK(font);
- LOGFONT font_info;
- GetObject(font, sizeof(LOGFONT), &font_info);
- return ChromeFont(CreateHFontRef(CreateFontIndirect(&font_info)));
-}
-
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_name,
- int font_size) {
- HDC hdc = GetDC(NULL);
- long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- ReleaseDC(NULL, hdc);
- HFONT hf = ::CreateFont(lf_height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- font_name.c_str());
- return ChromeFont::CreateFont(hf);
-}
-
-// static
-ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() {
- if (base_font_ref_ == NULL) {
- NONCLIENTMETRICS metrics;
- win_util::GetNonClientMetrics(&metrics);
-
- l10n_util::AdjustUIFont(&metrics.lfMessageFont);
-
- // See comment in ChromeFont::DeriveFont() about font size.
- // TODO(jungshik): Add a per-locale resource entry for the minimum
- // font size and actually enforce the lower-bound. 5 is way too small
- // for CJK, Thai, and Indian locales.
- DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5);
- HFONT font = CreateFontIndirect(&metrics.lfMessageFont);
- DLOG_ASSERT(font);
- base_font_ref_ = ChromeFont::CreateHFontRef(font);
- // base_font_ref_ is global, up the ref count so it's never deleted.
- base_font_ref_->AddRef();
- }
- return base_font_ref_;
-}
-
-std::wstring ChromeFont::FontName() {
- LOGFONT font_info;
- GetObject(hfont(), sizeof(LOGFONT), &font_info);
- return (std::wstring(font_info.lfFaceName));
-}
-
-int ChromeFont::FontSize() {
- LOGFONT font_info;
- GetObject(hfont(), sizeof(LOGFONT), &font_info);
- long lf_height = font_info.lfHeight;
- HDC hdc = GetDC(NULL);
- int device_caps = GetDeviceCaps(hdc, LOGPIXELSY);
- int font_size = 0;
- if (device_caps != 0) {
- float font_size_float = -static_cast<float>(lf_height)*72/device_caps;
- font_size = static_cast<int>(::ceil(font_size_float - 0.5));
- }
- ReleaseDC(NULL, hdc);
- return font_size;
-}
-
-ChromeFont::HFontRef::HFontRef(HFONT hfont,
- int height,
- int baseline,
- int ave_char_width,
- int style,
- int dlu_base_x)
- : hfont_(hfont),
- height_(height),
- baseline_(baseline),
- ave_char_width_(ave_char_width),
- style_(style),
- dlu_base_x_(dlu_base_x) {
- DLOG_ASSERT(hfont);
-}
-
-ChromeFont::HFontRef::~HFontRef() {
- DeleteObject(hfont_);
-}
-
-
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
- LOGFONT font_info;
- GetObject(hfont(), sizeof(LOGFONT), &font_info);
- // LOGFONT returns two types of font heights, negative is measured slightly
- // differently (character height, vs cell height).
- if (font_info.lfHeight < 0) {
- font_info.lfHeight -= size_delta;
- } else {
- font_info.lfHeight += size_delta;
- }
- // Even with "Small Fonts", the smallest readable font size is 5. It is easy
- // to create a non-drawing font and forget about the fact that text should be
- // drawn in the UI. This test ensures that the font will be readable.
- DCHECK_GE(abs(font_info.lfHeight), 5);
- font_info.lfUnderline = ((style & UNDERLINED) == UNDERLINED);
- font_info.lfItalic = ((style & ITALIC) == ITALIC);
- font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL;
-
- HFONT hfont = CreateFontIndirect(&font_info);
- return ChromeFont(CreateHFontRef(hfont));
-}
-
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
- int width = 0;
- HDC dc = GetDC(NULL);
- HFONT previous_font = static_cast<HFONT>(SelectObject(dc, hfont()));
- SIZE size;
- if (GetTextExtentPoint32(dc, text.c_str(), static_cast<int>(text.size()),
- &size)) {
- width = size.cx;
- } else {
- width = 0;
- }
- SelectObject(dc, previous_font);
- ReleaseDC(NULL, dc);
- return width;
-}
-
-ChromeFont::HFontRef* ChromeFont::CreateHFontRef(HFONT font) {
- TEXTMETRIC font_metrics;
- HDC screen_dc = GetDC(NULL);
- HFONT previous_font = static_cast<HFONT>(SelectObject(screen_dc, font));
- int last_map_mode = SetMapMode(screen_dc, MM_TEXT);
- GetTextMetrics(screen_dc, &font_metrics);
- // Yes, this is how Microsoft recommends calculating the dialog unit
- // conversions.
- SIZE ave_text_size;
- GetTextExtentPoint32(screen_dc,
- L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
- 52, &ave_text_size);
- const int dlu_base_x = (ave_text_size.cx / 26 + 1) / 2;
- // To avoid the DC referencing font_handle_, select the previous font.
- SelectObject(screen_dc, previous_font);
- SetMapMode(screen_dc, last_map_mode);
- ReleaseDC(NULL, screen_dc);
-
- const int height = std::max(1, static_cast<int>(font_metrics.tmHeight));
- const int baseline = std::max(1, static_cast<int>(font_metrics.tmAscent));
- const int ave_char_width =
- std::max(1, static_cast<int>(font_metrics.tmAveCharWidth));
- int style = 0;
- if (font_metrics.tmItalic) {
- style |= ChromeFont::ITALIC;
- }
- if (font_metrics.tmUnderlined) {
- style |= ChromeFont::UNDERLINED;
- }
- if (font_metrics.tmWeight >= kTextMetricWeightBold) {
- style |= ChromeFont::BOLD;
- }
-
- return new HFontRef(font, height, baseline, ave_char_width, style,
- dlu_base_x);
-}
diff --git a/chrome/common/gfx/text_elider.cc b/chrome/common/gfx/text_elider.cc
index e25f19c..1b0303f 100644
--- a/chrome/common/gfx/text_elider.cc
+++ b/chrome/common/gfx/text_elider.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/gfx/chrome_font.h"
#include "base/file_path.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
diff --git a/chrome/common/gfx/text_elider.h b/chrome/common/gfx/text_elider.h
index 2f88845..61bfada 100644
--- a/chrome/common/gfx/text_elider.h
+++ b/chrome/common/gfx/text_elider.h
@@ -8,9 +8,9 @@
#include <unicode/coll.h>
#include <unicode/uchar.h>
+#include "app/gfx/chrome_font.h"
#include "base/basictypes.h"
#include "base/string16.h"
-#include "chrome/common/gfx/chrome_font.h"
class FilePath;
class GURL;
diff --git a/chrome/common/gfx/text_elider_unittest.cc b/chrome/common/gfx/text_elider_unittest.cc
index c47e0bd..3a2eb6d 100644
--- a/chrome/common/gfx/text_elider_unittest.cc
+++ b/chrome/common/gfx/text_elider_unittest.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/gfx/chrome_font.h"
#include "base/file_path.h"
#include "base/string_util.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/text_elider.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chrome/common/win_util.h b/chrome/common/win_util.h
index e838e4d..282fe2a3 100644
--- a/chrome/common/win_util.h
+++ b/chrome/common/win_util.h
@@ -10,10 +10,10 @@
#include <string>
#include <vector>
+#include "app/gfx/chrome_font.h"
#include "base/fix_wp64.h"
#include "base/gfx/rect.h"
#include "base/scoped_handle.h"
-#include "chrome/common/gfx/chrome_font.h"
class FilePath;
diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj
index 9f84d5e..f274c23 100644
--- a/chrome/test/unit/unittests.vcproj
+++ b/chrome/test/unit/unittests.vcproj
@@ -1096,6 +1096,10 @@
>
</File>
<File
+ RelativePath="..\..\..\app\gfx\chrome_font_unittest.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\..\app\l10n_util_unittest.cc"
>
</File>
diff --git a/chrome/views/controls/button/menu_button.h b/chrome/views/controls/button/menu_button.h
index 119abb2..83485d0 100644
--- a/chrome/views/controls/button/menu_button.h
+++ b/chrome/views/controls/button/menu_button.h
@@ -7,7 +7,7 @@
#include <windows.h>
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/background.h"
#include "chrome/views/controls/button/text_button.h"
#include "base/time.h"
diff --git a/chrome/views/controls/button/native_button.h b/chrome/views/controls/button/native_button.h
index e7293c2..bfe6639 100644
--- a/chrome/views/controls/button/native_button.h
+++ b/chrome/views/controls/button/native_button.h
@@ -5,7 +5,7 @@
#ifndef CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
#define CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/button/native_button_wrapper.h"
diff --git a/chrome/views/controls/button/text_button.h b/chrome/views/controls/button/text_button.h
index 6f59088..bdca6cb 100644
--- a/chrome/views/controls/button/text_button.h
+++ b/chrome/views/controls/button/text_button.h
@@ -5,7 +5,7 @@
#ifndef CHROME_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
#define CHROME_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/border.h"
#include "chrome/views/controls/button/custom_button.h"
#include "skia/include/SkBitmap.h"
diff --git a/chrome/views/controls/combo_box.cc b/chrome/views/controls/combo_box.cc
index db6c86b..ca73727 100644
--- a/chrome/views/controls/combo_box.cc
+++ b/chrome/views/controls/combo_box.cc
@@ -5,11 +5,11 @@
#include "chrome/views/controls/combo_box.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/native_theme.h"
#include "base/gfx/rect.h"
-#include "chrome/common/gfx/chrome_font.h"
// Limit how small a combobox can be.
static const int kMinComboboxWidth = 148;
diff --git a/chrome/views/controls/label.cc b/chrome/views/controls/label.cc
index e0acde8..7cd8920 100644
--- a/chrome/views/controls/label.cc
+++ b/chrome/views/controls/label.cc
@@ -7,11 +7,11 @@
#include <math.h>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/logging.h"
#include "base/string_util.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/insets.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/views/background.h"
diff --git a/chrome/views/controls/label.h b/chrome/views/controls/label.h
index b2f1679..cf4dede 100644
--- a/chrome/views/controls/label.h
+++ b/chrome/views/controls/label.h
@@ -5,7 +5,7 @@
#ifndef CHROME_VIEWS_CONTROLS_LABEL_H_
#define CHROME_VIEWS_CONTROLS_LABEL_H_
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/view.h"
#include "googleurl/src/gurl.h"
#include "skia/include/SkColor.h"
diff --git a/chrome/views/controls/link.cc b/chrome/views/controls/link.cc
index 7969987..53d2495 100644
--- a/chrome/views/controls/link.cc
+++ b/chrome/views/controls/link.cc
@@ -4,7 +4,7 @@
#include "chrome/views/controls/link.h"
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/event.h"
namespace views {
diff --git a/chrome/views/controls/menu/chrome_menu.h b/chrome/views/controls/menu/chrome_menu.h
index f8b5e17..5258742 100644
--- a/chrome/views/controls/menu/chrome_menu.h
+++ b/chrome/views/controls/menu/chrome_menu.h
@@ -8,12 +8,12 @@
#include <list>
#include <vector>
+#include "app/gfx/chrome_font.h"
#include "base/gfx/point.h"
#include "base/gfx/rect.h"
#include "base/message_loop.h"
#include "base/task.h"
#include "chrome/common/drag_drop_types.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/controls/menu/controller.h"
#include "chrome/views/view.h"
#include "skia/include/SkBitmap.h"
diff --git a/chrome/views/controls/menu/menu.cc b/chrome/views/controls/menu/menu.cc
index 3e4e6ae..09ebe8d 100644
--- a/chrome/views/controls/menu/menu.cc
+++ b/chrome/views/controls/menu/menu.cc
@@ -13,13 +13,13 @@
#include <string>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
#include "base/gfx/rect.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/accelerator.h"
const SkBitmap* Menu::Delegate::kEmptyIcon = 0;
diff --git a/chrome/views/controls/tabbed_pane.cc b/chrome/views/controls/tabbed_pane.cc
index e0205a9..487c0b5 100644
--- a/chrome/views/controls/tabbed_pane.cc
+++ b/chrome/views/controls/tabbed_pane.cc
@@ -7,12 +7,12 @@
#include <vssym32.h>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util_win.h"
#include "app/resource_bundle.h"
#include "base/gfx/native_theme.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/background.h"
#include "chrome/views/fill_layout.h"
#include "chrome/views/widget/root_view.h"
diff --git a/chrome/views/controls/text_field.h b/chrome/views/controls/text_field.h
index ffa5469..6de2218 100644
--- a/chrome/views/controls/text_field.h
+++ b/chrome/views/controls/text_field.h
@@ -10,8 +10,8 @@
#include <string>
+#include "app/gfx/chrome_font.h"
#include "base/basictypes.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/view.h"
#include "skia/include/SkColor.h"
diff --git a/chrome/views/window/custom_frame_view.cc b/chrome/views/window/custom_frame_view.cc
index e3cdad6..d5d587e 100644
--- a/chrome/views/window/custom_frame_view.cc
+++ b/chrome/views/window/custom_frame_view.cc
@@ -5,10 +5,10 @@
#include "chrome/views/window/custom_frame_view.h"
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/resource_bundle.h"
#include "base/win_util.h"
#include "chrome/common/gfx/path.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/win_util.h"
#include "chrome/views/window/client_view.h"
#include "chrome/views/window/window_delegate.h"
diff --git a/chrome/views/window/dialog_client_view.cc b/chrome/views/window/dialog_client_view.cc
index 099ff60..8f82443 100644
--- a/chrome/views/window/dialog_client_view.cc
+++ b/chrome/views/window/dialog_client_view.cc
@@ -9,11 +9,11 @@
#include <vsstyle.h>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/native_theme.h"
#include "chrome/browser/views/standard_layout.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/win_util.h"
#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/window/dialog_delegate.h"
diff --git a/chrome/views/window/dialog_client_view.h b/chrome/views/window/dialog_client_view.h
index 0e311bb..0a88e19 100644
--- a/chrome/views/window/dialog_client_view.h
+++ b/chrome/views/window/dialog_client_view.h
@@ -5,7 +5,7 @@
#ifndef CHROME_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_
#define CHROME_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_
-#include "chrome/common/gfx/chrome_font.h"
+#include "app/gfx/chrome_font.h"
#include "chrome/views/focus/focus_manager.h"
#include "chrome/views/controls/button/button.h"
#include "chrome/views/window/client_view.h"
diff --git a/chrome/views/window/window_win.cc b/chrome/views/window/window_win.cc
index 9a603f9..58301f5 100644
--- a/chrome/views/window/window_win.cc
+++ b/chrome/views/window/window_win.cc
@@ -7,11 +7,11 @@
#include <shellapi.h>
#include "app/gfx/chrome_canvas.h"
+#include "app/gfx/chrome_font.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/win_util.h"
#include "chrome/app/chrome_dll_resource.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/icon_util.h"
#include "chrome/common/gfx/path.h"
#include "chrome/common/notification_service.h"