📄 other.html
字号:
<STRONG>Note</STRONG>:Currently, a <CODE>TextLayout</CODE> object uses the Roman baseline no matter what language the text is in. Many fontsassume the Roman baseline too, so these methods exist for typographic features that are not currently in widespread use. When <CODE>TextLayout</CODE>supports the Roman, centered, and hanging baselines, you will be able touse the information returned by these methods to align a line of text thatuses different baselines. <HR></BLOCKQUOTE><P><A NAME="ascent"></A><H3>Ascent, Descent, and Leading</H3>Ascent, descent, and leading are properties of fonts. The ascentof a font is the distance from the tops of the tallest glyphs to thebaseline.<P><IMG SRC="./Art/Ascent.gif"><P>The descent of a font is the distance from the baseline to the bottomof the lowest descenders on the glyphs.<P><IMG SRC="./Art/Descent.gif"><P>The leading is the recommended vertical distance from the bottom ofthe descenders to the top of the next line in a multiline setting.<P><IMG SRC="./Art/Leading.gif"><P>A <CODE>TextLayout</CODE> object has methods for returning informationabout the ascent, descent, and leading of the font. If thetext string uses more than one font, the ascent and descentare computed as the maximum values for the fonts used in the<CODE>TextLayout</CODE> object.<UL><LI><CODE>TextLayout.getAscent</CODE><LI><CODE>TextLayout.getDescent</CODE><LI><CODE>TextLayout.getLeading</CODE></UL><A NAME="advance"></A><H3>Advance</H3>The advance is the length of the string in the <CODE>TextLayout</CODE>, which is calculated as the distance from the left edge of the left-most glyph to the right edge of the right-mostglyph. <P><IMG SRC="./Art/Advance.gif"><P>The visual advance is the length of the string in the <CODE>TextLayout</CODE>object minus trailing whitespace.<P><IMG SRC="./Art/VAdvance.gif"><P>A <CODE>TextLayout</CODE> object has methods for returning its advance and visual advance.<UL><LI><CODE>TextLayout.getAdvance</CODE><LI><CODE>TextLayout.getVisualAdvance</CODE></UL><A NAME="bounds"></A><H3>Bounds</H3>The bounding box encloses the text in the <CODE>TextLayout</CODE>object. It includes all the visible glyphs and the caretboundaries, some of which might hang over the origin ororigin plus advance. <P><IMG SRC="./Art/Bounds.gif"><P>A <CODE>TextLayout</CODE> object has methods to return its bounds and theblack box bounds for a range of characters.The bounding box returned by <CODE>TextLayout.getBounds</CODE> is relative to the origin of the <CODE>TextLayout</CODE>, and not to any particular screen position.<P>The black box bounds is the union of the bounding boxes of all the glyphscorresponding to the characters between a starting point and an ending point.In bidirectional text, this path might be disjoint either on the display or inthesource text. See the <A HREF="int.html#highlighting">Selection Highlighting</A>section in Lesson 4 for information on how a range of characters inbidirectional text is not always contiguous.<UL><LI><CODE>TextLayout.getBounds</CODE><LI><CODE>TextLayout.getBlackBoxBounds</CODE></UL><A NAME="just"></A><H3>Justified Text</H3><CODE>TextLayout.getCharacterLevel</CODE> is not implemented yet soyou cannot justify a paragraph of text so all lines are equal in length.However, you can right, center, or left justifytext by drawing the <CODE>TextLayout</CODE> object in a differentlocation computed by calling <CODE>TextLayout.getVisibleAdvance</CODE>.<P>The <A HREF="./Code/LineBreakSample.java">LineBreakSample.java</A> codeshows how to left-align left-to-right text and right-align right-to-lefttext. Here is how to align the other possibilities.<P>To right-align a left-to-right layout: Draw at <CODE>(rightMargin - layout.getVisibleAdvance()).</CODE><P><IMG SRC="./Art/rightAlign.gif"><P>To center a left-to-right layout: Draw at <CODE>(leftMargin + rightMargin - layout.getVisibleAdvance()) / 2.</CODE><P><IMG SRC="./Art/centerAlign.gif"><P>To left-align a right-to-left layout: Draw at<CODE>(leftMargin + (layout.getVisibleAdvance() - layout.getAdvance)).</CODE><P>To center a right-toleft layout: Draw at <CODE>(leftMargin + rightMargin + layout.getAdvance ()) / 2 - layout.getAdvance().</CODE><A NAME="level"></A><H3>Character Level</H3><CODE>TextLayout.getCharacterLevel</CODE> returns the bidirectional level of the character as computed by the bidirectional algorithm. This is primarily used to determine if the character in question is a left-to-right or a right-to-left character (which depends on context and style information, and is not a simple characterproperty). The level (0-16 inclusive) is returned so clients with particular userinterface needs (for instance, clients building user interfacesthat show nested bidirectional levels in some way) have access to the fullinformation.<P></FONT></TD></TR></TABLE><!-- ================ --><!-- End Main Content --><!-- ================ --></FONT></TD></TR></TABLE><!-- Copyright Insert --><BR CLEAR="ALL"><FORM ACTION="/cgi-bin/search.cgi" METHOD="POST"><TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="5"> <TR> <TD VALIGN="TOP"> <P ALIGN=CENTER> <FONT SIZE="-1" COLOR="#999999" FACE="Verdana, Arial, Helvetica, sans-serif"> [ This page was updated: <!-- new date --> 12-Nov-99 ]</font></P> </TD> </TR> <TR> <TD BGCOLOR="#CCCCCC"> <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD> </TR> <TR> <TD> <CENTER> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> <A HREF="http://java.sun.com/products/">Products & APIs</A> | <A HREF="/developer/index.html">Developer Connection</A> | <A HREF="/developer/infodocs/index.shtml">Docs & Training</A> | <A HREF="/developer/support/index.html">Online Support</A><BR> <A HREF="/developer/community/index.html">Community Discussion</A> | <A HREF="http://java.sun.com/industry/">Industry News</A> | <A HREF="http://java.sun.com/solutions">Solutions Marketplace</A> | <A HREF="http://java.sun.com/casestudies">Case Studies</A> </FONT> </CENTER> </TD> </TR> <TR> <TD BGCOLOR="#CCCCCC"> <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD> </TR> <TR> <TD ALIGN="CENTER"> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> <A HREF="http://java.sun.com/docs/glossary.html">Glossary</A> - <A HREF="http://java.sun.com/applets/">Applets</A> - <A HREF="http://java.sun.com/docs/books/tutorial/">Tutorial</A> - <A HREF="http://java.sun.com/jobs/">Employment</A> - <A HREF="http://java.sun.com/nav/business/">Business & Licensing</A> - <A HREF="http://java.sun.com/javastore/">Java Store</A> - <A HREF="http://java.sun.com/casestudies/">Java in the Real World</A> </FONT> </TD> </TR> <TR> <TD> <CENTER> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> <a href="/siteinfo/faq.html">FAQ</a> | <a href="/feedback/index.html">Feedback</a> | <a href="http://www.dynamicdiagrams.net/mapa/cgi-bin/help.tcl?db=javasoft&dest=http://java.sun.com/">Map</a> | <A HREF="http://java.sun.com/a-z/index.html">A-Z Index</A> </FONT> </CENTER> </TD> </TR> <TR> <TD> <TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="0"> <TR> <TD WIDTH="50%"> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> For more information on Java technology<BR> and other software from Sun Microsystems, call:<BR> </FONT> <FONT SIZE="-1" FACE="Verdana, Arial, Helvetica, sans-serif"> (800) 786-7638<BR></FONT> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> Outside the U.S. and Canada, dial your country's <A HREF="http://www.att.com/business_traveler/attdirecttollfree/">AT&T Direct Access Number</A> first.<BR> </FONT> </TD> <TD ALIGN="RIGHT" WIDTH="50%"> <A HREF="http://www.sun.com"><IMG SRC="/images/lgsun.gif" width="64" height="30" border="0" ALT="Sun Microsystems, Inc."></A><BR> <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif"> Copyright © 1995-99 <A HREF="http://www.sun.com">Sun Microsystems, Inc.</A><BR> All Rights Reserved. <a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>. <A HREF="http://www.sun.com/privacy/">Privacy Policy</A>. </FONT> </TD> </TR> </TABLE> </TD> </TR> </TABLE></FORM><!-- End Copyright Insert --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -