{"id":2489,"date":"2015-05-19T17:05:58","date_gmt":"2015-05-19T09:05:58","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=2489"},"modified":"2015-05-19T17:05:58","modified_gmt":"2015-05-19T09:05:58","slug":"fmx-%e4%bd%bf%e7%94%a8-canvas-%e8%ae%a1%e7%ae%97%e5%a4%a7%e5%b0%8f%e4%b8%8e%e7%89%a9%e7%90%86%e5%a4%a7%e5%b0%8f%e8%ae%a1%e7%ae%97%e6%97%b6%ef%bc%8c%e5%88%ab%e5%bf%98%e4%ba%86%e7%bc%a9%e6%94%be","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=2489","title":{"rendered":"[FMX] \u4f7f\u7528 Canvas \u8ba1\u7b97\u5927\u5c0f\u4e0e\u7269\u7406\u5927\u5c0f\u8ba1\u7b97\u65f6\uff0c\u522b\u5fd8\u4e86\u7f29\u653e\u6bd4"},"content":{"rendered":"<p>FMX \u7684 Canvas \u7684\u529f\u80fd\u5c31\u4e0d\u8bf4\u4e86\uff0c\u4f46\u4f60\u6ce8\u610f\u5230\u4e86\u5417\uff1fCanvas.TextWidth \u7b49\u51fd\u6570\u8fd4\u56de\u7684\u5927\u5c0f\uff0c\u5982\u679c\u4f60\u5f53\u771f\uff0c\u90a3\u4f60\u5c31\u4f1a\u53d1\u73b0\u73b0\u5b9e\u548c\u7406\u60f3\u5dee\u7684\u592a\u8fdc\u4e86\u3002\u4f60\u9700\u8981\u901a\u8fc7\u63a7\u4ef6\u7684\u00a0Scene.GetSceneScale \u6765\u83b7\u5f97\u4e00\u4e2a\u7f29\u653e\u6bd4\uff0c\u4e0e\u539f\u59cb\u7684\u8fdb\u884c\u7f29\u653e\u540e\uff0c\u624d\u662f\u653e\u5230\u5c4f\u5e55\u4e0a\u7684\u5b9e\u9645\u5927\u5c0f\u3002<\/p>\n<p>\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u8ba1\u7b97\u4e00\u4e2aLabel\u4e0a\u6587\u5b57\u7684\u663e\u793a\u533a\u57df\u5927\u5c0f\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">var\r\n  R: TRectF;\r\n  AScale: Single;\r\nbegin\r\n  R := TRectF.Create(0, 0, MaxInt, MaxInt);\r\n  Label1.Canvas.MeasureText(R,Label1.Text,Label1.WordWrap,[],Label1.TextAlign,TTextAlign.Leading);  \r\n  AScale := Label1.Scene.GetSceneScale;\r\n  R.Right := R.Right * AScale;\r\n  R.Bottom := R.Bottom * AScale;\r\n  ShowMessage('Label1.Text.Width='+FloatToStr(R.Right)+'x'+FloatToStr(R.Bottom));\r\nend;<\/pre>\n<p>\u4e0a\u9762\u7684 R.Right \u548c R.Bottom \u9700\u8981\u4e58\u4e0a AScale \u624d\u662f\u771f\u6b63\u7684\u7269\u7406\u50cf\u7d20\u5927\u5c0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FMX \u7684 Canvas \u7684\u529f\u80fd\u5c31\u4e0d\u8bf4\u4e86 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,9,21],"tags":[],"class_list":["post-2489","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-qdac","category-misc"],"views":4919,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2489"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2489\/revisions"}],"predecessor-version":[{"id":2490,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2489\/revisions\/2490"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}