fontmetrics

String width via fontmetrics calculation is very slow if there are arabic or persian letters in text

本秂侑毒 提交于 2019-12-18 19:08:23
问题 I have a problem. My application interface works much slower if i use eastern languages there. Especially i felt it in components such as JList, JCombobox, JTable. How i found the performance of FontMetrics.stringWidth method is very slow (500+ times) if in the text at least one letter is arabic or persian. How i know it is commonly used method in various swing components. Is there a way to boost this method performance? Here is the example class which demonstrates the problem: import java

How to get ascender/descender and x height for a given font

女生的网名这么多〃 提交于 2019-12-18 13:17:09
问题 I need to get a ascender/descender and x-height.. By using following code I can find the descender and the total height: descender_height = paint.descent(); total_height = descender_height - paint.ascent(); //ascender = ?; is this always equal to descender height? //x_height = ?; total_height - 2*descender_height ? Thanks 回答1: I would think the ascender and descender height would typically be the same, but I wouldn't depend on it for every font. I don't really see a direct way to get to the x

Android: How to determine character index of a touch event's position in TextView?

萝らか妹 提交于 2019-12-17 16:24:59
问题 I have a TextView with an OnTouchListener . What I want is the character index the user is pointing to when I get the MotionEvent . Is there any way to get to the underlying font metrics of the TextView ? 回答1: I am not aware of a simple direct way to do this but you should be able to put something together using the Paint object of the TextView via a call to TextView.getPaint() Once you have the paint object you will have access to the underlying FontMetrices via a call to Paint

How do you get the font and graphic of a column header in a JTable

こ雲淡風輕ζ 提交于 2019-12-11 11:59:45
问题 I am trying to get the graphic and font of a column header in a JTable. To do this I am using the code Graphics g = myTable.getColumnModel().getColumn(i).getGraphics(); Font f = myTable.getColumnModel().getColumn(i).getFont(); However that produces a can't find symbol error The full code for this program is import javax.swing.*; import java.awt.*; import java.io.*; import java.lang.*; import java.awt.event.*; import javax.swing.event.*; import java.util.List; import java.util.ArrayList;

FontMetrics setFont?

好久不见. 提交于 2019-12-07 21:44:57
问题 I am making a program in which I need to set the Font inside a FontMetrics object. I have already created the fontmetrics before, but now I don't have access to the Graphics object anymore. Yet, I want to change the font inside the FontMetrics, that is, create a new FontMetrics, with a new Font, but using the same Graphic context. I could make the Graphics avaliable, but it would take a lot of time and it wouldn't make sense at all to do so. Would anyone know an easier way to it? It seens so

FontMetrics setFont?

你。 提交于 2019-12-06 13:53:00
I am making a program in which I need to set the Font inside a FontMetrics object. I have already created the fontmetrics before, but now I don't have access to the Graphics object anymore. Yet, I want to change the font inside the FontMetrics, that is, create a new FontMetrics, with a new Font, but using the same Graphic context. I could make the Graphics avaliable, but it would take a lot of time and it wouldn't make sense at all to do so. Would anyone know an easier way to it? It seens so obvius it should be a way, maybe I am just missing something really stupid (I looked at the

Get single glyph metrics (.net)

ぐ巨炮叔叔 提交于 2019-12-05 20:33:41
问题 How can I get full information about single glyph from choosen font (for example Arial -> symbol "A") This picture describe what variables I need to find: 回答1: You can start with the FontFamily class. and this CP article http://www.codeproject.com/KB/GDI-plus/ExtendedGraphicsII.aspx 回答2: I don't think FontFamily will give any information about a particular glyph, but the DirectWrite interface might work: (I haven't used it yet) Glyphs and Glyph Runs IDWriteFontFace::GetGlyphIndices

String width via fontmetrics calculation is very slow if there are arabic or persian letters in text

一个人想着一个人 提交于 2019-11-30 18:12:05
I have a problem. My application interface works much slower if i use eastern languages there. Especially i felt it in components such as JList, JCombobox, JTable. How i found the performance of FontMetrics.stringWidth method is very slow (500+ times) if in the text at least one letter is arabic or persian. How i know it is commonly used method in various swing components. Is there a way to boost this method performance? Here is the example class which demonstrates the problem: import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.image.BufferedImage;

Java - FontMetrics without Graphics

血红的双手。 提交于 2019-11-30 14:28:22
问题 How to get FontMetrics without use Graphics ? I want to get FontMetrics in constructor, now I do this way: BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB); FontMetrics fm = bi.getGraphics().getFontMetrics(font); int width = fm.stringWidth(pattern); int height = fm.getHeight(); 回答1: Hmm... It is quite logical that you need graphics to get FontMetrics. Font height, width etc. can differ on various displays. If you have some Component, you can use it for getting

Java: FontMetrics ascent incorrect?

偶尔善良 提交于 2019-11-30 11:37:18
When I look at the javadoc for FontMetric.getAscent() I see: The font ascent is the distance from the font's baseline to the top of most alphanumeric characters. Some characters in the Font might extend above the font ascent line. But I wrote a quick demo program and I see this: where the 4 horizontal lines for each row of text are: baseline position lowered by getDescent() baseline position baseline position raised by getAscent() baseline position raised by getHeight() Notice the space between the getAscent() line and the top of the characters. I've looked at most of the fonts and sizes, and