{"id":286,"date":"2013-05-16T15:49:26","date_gmt":"2013-05-16T07:49:26","guid":{"rendered":"http:\/\/blog.sorayuki.net\/?p=286"},"modified":"2016-10-09T10:38:01","modified_gmt":"2016-10-09T02:38:01","slug":"%e3%80%90%e5%9d%91%e3%80%91gdi%e4%b8%ad%e7%9a%84measurestring","status":"publish","type":"post","link":"https:\/\/blog.sorayuki.net\/?p=286","title":{"rendered":"\u3010\u5751\u3011GDI+\u4e2d\u7684MeasureString"},"content":{"rendered":"<p>\u4e00\u6574\u4e2a\u5b57\u7b26\u62ff\u53bbmeasure\u786e\u5b9e\u662f\u4e0d\u600e\u4e48\u5bb9\u6613\u9047\u4e0a\u95ee\u9898\u3002\u4f46\u662f\u4f60\u8981\u4e00\u4e2a\u4e00\u4e2a\u6765\u7684\u8bdd\uff0c\u5c31\u4f1a\u6709\u95ee\u9898\u3002\u539f\u56e0\u662fmsdn\u91cc\u6709\u8fd9\u4e48\u4e00\u53e5\u8bdd\uff1a<\/p>\n<p>The <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=overload%3asystem.drawing.graphics.measurestring&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">MeasureString<\/a> method is designed for use with individual strings and includes a small amount of extra space before and after the string to allow for overhanging glyphs.<\/p>\n<p>INCLUDES A SMALL AMOUNT OF EXTRA SPACE BEFORE AND AFTER THE STRING<\/p>\n<p>\u6240\u4ee5\u83b7\u53d6\u5230\u7684\u4f1a\u504f\u5927\u3002<\/p>\n<p>\u65b9\u6cd5\u5b83\u4e5f\u8bf4\u5f97\u633a\u6e05\u695a<\/p>\n<p>To obtain metrics suitable for adjacent strings in layout (for example, when implementing formatted text), use the <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=m%3asystem.drawing.graphics.measurecharacterranges(system.string%2csystem.drawing.font%2csystem.drawing.rectanglef%2csystem.drawing.stringformat)&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">MeasureCharacterRanges<\/a> method or one of the <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=overload%3asystem.drawing.graphics.measurestring&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">MeasureString<\/a> methods that takes a <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=t%3asystem.drawing.stringformat&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">StringFormat<\/a>, and pass <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=p%3asystem.drawing.stringformat.generictypographic&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">GenericTypographic<\/a>. Also, ensure the <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=p%3asystem.drawing.graphics.textrenderinghint&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">TextRenderingHint<\/a> for the <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=t%3asystem.drawing.graphics&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">Graphics<\/a> is <a href=\"ms-xhelp:\/\/\/?method=page&amp;id=t%3asystem.drawing.text.textrenderinghint&amp;vendor=Microsoft&amp;topicVersion=110&amp;topicLocale=EN-US\">AntiAlias<\/a>.<\/p>\n<p>\u6ca1\u6ce8\u610f\u7684\u8bdd\u5f88\u5bb9\u6613\u6389\u5751<\/p>\n<p>\u540e\u7eed\u8865\u5145\uff1aMeasureString\u7684\u65f6\u5019\u8981\u52a0StringFormat.GenericTypographic\uff0c\u90a3\u4e48\u5728DrawString\u7684\u65f6\u5019\u4e5f\u8981\u4e00\u8d77\u52a0\u8fd9\u4e2a\u53c2\u6570\u3002\u4e0d\u7136\u5b83\u8ba1\u7b97\u7684\u65f6\u5019\u548c\u7ed8\u5236\u7684\u65f6\u5019\u5bbd\u5ea6\u53c8\u4e0d\u4e00\u6837\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6574\u4e2a\u5b57\u7b26\u62ff\u53bbmeasure\u786e\u5b9e\u662f\u4e0d\u600e\u4e48\u5bb9\u6613\u9047\u4e0a\u95ee\u9898\u3002\u4f46\u662f\u4f60\u8981\u4e00\u4e2a\u4e00\u4e2a\u6765\u7684\u8bdd\uff0c\u5c31\u4f1a\u6709\u95ee\u9898\u3002\u539f\u56e0\u662fmsdn\u91cc\u6709\u8fd9 &hellip; <a href=\"https:\/\/blog.sorayuki.net\/?p=286\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u3010\u5751\u3011GDI+\u4e2d\u7684MeasureString<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":0,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sorayuki.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}