{"id":1110,"date":"2009-10-15T23:57:00","date_gmt":"2009-10-16T05:57:00","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/?p=1110"},"modified":"2009-10-15T23:57:00","modified_gmt":"2009-10-16T05:57:00","slug":"openoffice-org-fontdescriptor","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2009\/10\/15\/openoffice-org-fontdescriptor\/","title":{"rendered":"OpenOffice.org FontDescriptor"},"content":{"rendered":"<p>OOo controls have a Struct <a href=\"http:\/\/api.openoffice.org\/docs\/common\/ref\/com\/sun\/star\/awt\/FontDescriptor.html\">FontDescriptor<\/a> that contains all the information about the text (font name, point size, etc.) so one would hope that to make an editbox have the same font as the containing text range, all you would have to do is<\/p>\r\n<pre><code class=\"language-vb\">textField.fontDescriptor = textRange.fontDescriptor<\/code><\/pre>\r\n<p>but no such luck. FontDescriptors apply to <a href=\"http:\/\/api.openoffice.org\/docs\/common\/ref\/com\/sun\/star\/awt\/FontDescriptor-xref.html\">everything but actual text<\/a>; text has all those properties as part of the <a href=\"http:\/\/api.openoffice.org\/docs\/common\/ref\/com\/sun\/star\/style\/CharacterProperties.html\">CharacterProperties<\/a> service, so each property has to be accessed separately:<\/p>\r\n<pre><code class=\"language-vb\">fontDescriptor = textField.fontDescriptor\r\nfontDescriptor.name = textRange.CharFontName\r\nfontDescriptor.height = textRange.CharHeight\r\n' etc.\r\ntextField.fontDescriptor = fontDescriptor<\/code><\/pre>\r\n<p>Note that you can't do <code class=\"language-vb\">textField.fontDescriptor.name = textRange.CharFontName<\/code>, because <a href=\"http:\/\/wiki.services.openoffice.org\/wiki\/Documentation\/DevGuide\/ProUNO\/Basic\/Mapping_of_Structs\">Structs are always copied<\/a>. Even if it makes no sense.<code class=\"language-vb\">textField.fontDescriptor.name<\/code> creates a temporary copy of <code class=\"language-vb\">textField.fontDescriptor<\/code> and modifies <em>its<\/em> <code class=\"language-vb\">name<\/code>, leaving the original <code class=\"language-vb\">textField.fontDescriptor<\/code> untouched","protected":false},"excerpt":{"rendered":"OOo controls have a Struct FontDescriptor that contains all the information about the text (font name, point size, etc.) so one would hope that to make an editbox have the same font as the containing text range, all you would have to do is textField.fontDescriptor = textRange.fontDescriptor but no such luck. FontDescriptors apply to everything [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1110"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=1110"}],"version-history":[{"count":3,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1110\/revisions"}],"predecessor-version":[{"id":1113,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1110\/revisions\/1113"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=1110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=1110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=1110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}