{"id":3118,"date":"2015-11-27T13:27:49","date_gmt":"2015-11-27T05:27:49","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=3118"},"modified":"2015-11-27T13:33:42","modified_gmt":"2015-11-27T05:33:42","slug":"fmx-%e4%bd%bf%e7%94%a8-ttextlayoutmanager-%e6%9d%a5%e5%8a%a0%e5%bf%ab%e6%89%b9%e9%87%8f%e6%96%87%e6%9c%ac%e7%bb%98%e5%88%b6","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=3118","title":{"rendered":"[FMX] \u4f7f\u7528 TTextLayout \u6765\u52a0\u5feb\u6279\u91cf\u6587\u672c\u7ed8\u5236"},"content":{"rendered":"<p>\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5728\u7ed8\u5236\u5927\u91cf\u6587\u672c\u65f6\uff0c\u5982\u679c\u8c03\u7528 TCanvas.FillText\uff0c\u4f1a\u91cd\u590d\u7684\u521b\u5efa\u548c\u7ffb\u8bd1 TTextLayoutManager \u5bf9\u8c61\uff0c\u5f71\u54cd\u7ed8\u5236\u6548\u7387\u3002\u6240\u4ee5\uff0c\u5982\u679c\u4f60\u8981\u5728 FMX \u5e94\u7528\u4e2d\u5927\u91cf\u7ed8\u5236\u6587\u672c\u65f6\uff0c\u5e94\u8be5\u5c3d\u91cf\u5c06 TTextLayoutManager \u72ec\u7acb\u51fa\u6765\uff0c\u7528\u5b83\u6765\u7ed8\u5236\uff0c\u800c\u4e0d\u662f\u7528 FillText\uff0c\u6211\u5b9e\u9645\u505a\u4e86\u4e0b\u6d4b\u8bd5\uff0c\u540c\u4e00\u4e2a\u5b57\u7b26\u4e32\u7ed8\u5236 10000 \u6b21\uff0c\u7528 TCanvas.FillText \u7528\u65f6\u7ea6 1.8 \u79d2\uff0c\u800c\u7528 TTextLayout\u00a0\u53ea\u7528\u4e86 0.24 \u79d2\uff0c\u6548\u7387\u63d0\u5347\u4e86 7 \u500d\u591a\uff0c\u8fd8\u662f\u76f8\u5f53\u53ef\u89c2\u7684\u3002<\/p>\n<p>\u7528 TTextLayoutManager \u6765\u7ed8\u5236\u6587\u672c\uff0c\u9700\u8981\u4ee5\u4e0b\u51e0\u6b65\uff1a<\/p>\n<p>1\u3001\u5f53\u7136\u662f\u58f0\u660e\u53d8\u91cf\uff0c\u5e76\u521b\u5efa\u5b83\u7684\u5b9e\u4f8b\u4e86\uff08\u5047\u8bbe\u753b\u5e03\u5bf9\u8c61\u4e3a Canvas\uff09<\/p>\n<pre class=\"lang:delphi decode:true \">var\r\n   Layout: TTextLayout;\r\nbegin\r\nLayout := TTextLayoutManager.TextLayoutByCanvas(Canvas.ClassType).Create(Canvas);\r\n<\/pre>\n<p>2\u3001\u8bbe\u7f6e Layout \u7684\u5404\u4e2a\u7ed8\u5236\u53c2\u6570\uff0c\u4ee5\u4fbf\u51c6\u5907\u7ed8\u5236\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">Layout.BeginUpdate;\r\nLayout.TopLeft := PointF(0,0);\r\nLayout.MaxSize := PointF(100,25);\r\nLayout.WordWrap := False;\r\nLayout.Opacity := 0.5;\r\nLayout.HorizontalAlign := TTextAlign.Center;\r\nLayout.VerticalAlign := TTextAlign.Center;\r\nLayout.Font := Canvas.Font;\r\nLayout.RightToLeft := False;\r\nLayout.Text:='Hello,\u8fd9\u662f\u4e2d\u6587\uff01';\r\nLayout.EndUpdate;<\/pre>\n<p>3\u3001\u8c03\u7528 TTextLayout.RenderLayout \u6765\u5b8c\u6210\u6e32\u67d3\uff0c\u5982\u679c\u8981\u6539\u53d8\u6587\u5b57\u5185\u5bb9\uff0c\u53ea\u9700\u8981\u6539\u53d8 TTextLayout.Text\uff0c\u6539\u53d8\u4f4d\u7f6e\u5f53\u524d\u5c31\u662f TopLeft \u548c MaxSize \u4e86\uff1b<\/p>\n<pre class=\"lang:delphi decode:true \">Layout.RenderLayout(Canvas);<\/pre>\n<p>4\u3001\u6700\u540e\uff0c\u5f53\u7136\u662f\u5728\u4f7f\u7528\u5b8c\u6bd5\u7ffb\u8bd1 Layout \u5bf9\u8c61\uff0c\u5c31\u4e0d\u7f00\u8ff0\u4e86\u3002<\/p>\n<p>\u6ce8\u610f\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u540c\u65f6\u6539\u53d8\u591a\u4e2a\u5c5e\u6027\u65f6\uff0c\u6700\u597d\u8c03\u7528BeginUpdate\/EndUpdate\u6765\u907f\u514d\u91cd\u590d\u89e6\u53d1\u4e00\u4e9b\u4e0d\u9700\u8981\u7684\u52a8\u4f5c\uff0c\u5f71\u54cd\u6548\u7387\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u9645\u4e0a\uff0c\u6211\u4eec\u5728\u7ed8\u5236\u5927\u91cf\u6587\u672c\u65f6\uff0c\u5982\u679c\u8c03\u7528  [&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":[21],"tags":[149,495,496,139],"class_list":["post-3118","post","type-post","status-publish","format-standard","hentry","category-misc","tag-fmx","tag-ttextlayout","tag-496","tag-139"],"views":4567,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3118","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=3118"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3118\/revisions"}],"predecessor-version":[{"id":3121,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3118\/revisions\/3121"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}