Questions tagged [fontmetrics]

115 questions
2
votes
4 answers

Font Metrics in C

I wanted to know if there is any library in C available for calculating the Font Metrics (Basically i wanted to know the width of a string of Particular Font). QT has QFontMetrics. Is there any way I can get similar data in C.
hari
  • 1,419
  • 4
  • 19
  • 30
2
votes
0 answers

GraphicsMagick and FontMetrics

My aim is to create a text image and put it on top of other images. This is the command I use to create the text image: String[] cp_img_arguments = {"convert", "-size", width_size + "x", "-background", background_colour, …
Giannis
  • 5,286
  • 15
  • 58
  • 113
2
votes
1 answer

Leading of FontMetrics seems that returns always zero?

I tried this code: Paint.FontMetrics pf = new Paint.FontMetrics(); parentPaint.getFontMetrics(pf); float lead = pf.leading; But it seems that leading is always 0.I read docs in about leading: The recommended additional space to add between lines…
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
2
votes
0 answers

How to speed up text measurement on Android?

I'm writing an application that has a custom text layout engine, and for this to work I must measure lots (thousands) of Strings using the .getTextBounds() method on the Paint class. It does work. But on some devices, this measurement is extremely…
Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
2
votes
0 answers

FontMetrics: TextBound invalid

What is the meaning of this warning??, im getting it when i set a text in a TextView: 10-30 23:56:42.122: W/TextPaint(1366): FontMetrics: TextBound invalid!!! top:-32 text:00:05:50
Ollie Strevel
  • 861
  • 1
  • 14
  • 27
2
votes
1 answer

How, in iOS, can I get the width of a string as rendered in a particular font and point size?

I would like to draw cards on a screen that have a small amount of text when they're laid out, more text when they're zoomed in, and ideally animate from one setting to the other like jQuery(...).show('slow');. The beginning state is slightly…
Christos Hayward
  • 5,777
  • 17
  • 58
  • 113
2
votes
4 answers

Draw Text in Middle of the Screen

I'm trying to draw text in the middle of my JFrame window, and it's off by a little bit. Here's what I've tried : FontMetrics fontMetrics = g.getFontMetrics(font); // draw title g.setColor(Color.WHITE); g.setFont(font); int titleLen =…
sparklyllama
  • 1,276
  • 4
  • 20
  • 28
2
votes
1 answer

Right align text on image

Graphics g = image.getGraphics(); FontMetrics fm = g.getFontMetrics(); int actual_width= fm.stringWidth("My Value"); drawString("My Value",total_width-actual_width,ypos); g.dispose(); ImageIO.write(image, "bmp", new…
Code Hungry
  • 3,930
  • 22
  • 67
  • 95
2
votes
1 answer

How to get the font metrics of a QPainter outside paintEvent?

How to get the font metrics of a QPainter outside paintEvent drawing method? I would need this before painting on the screen.
andreihondrari
  • 5,743
  • 5
  • 30
  • 59
2
votes
2 answers

Java Graphics: Constructing FontMetrics from Font, without a Graphics2D

Known Given FontMetrics There is a protected constructor for FontMetrics from Font. Question: Given a Font object, is there a way to construct a FontMetrics object without going through Graphics2D.setFont, Graphics2D.getFontMetric()? Context I'm…
user1311390
2
votes
1 answer

FontMetrics setFont?

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…
Luan Nico
  • 5,376
  • 2
  • 30
  • 60
1
vote
1 answer

Best way to find real bounds of font

I was looking for a way to find the bounds on rendered text and encountered the FontMetrics getStringBounds method. This seems to ignore some font's descent and has an exaggerated ascent so that it returns a bounds that doesn't let me align…
bittramp
  • 121
  • 2
  • 15
1
vote
1 answer

Is it possible to get accurate character/font metrics in AS3?

I have created a class which will use an embedded font to dynamically generate a bitmap font at run-time. So far it works well except that I have a minor issue with character spacing. In the image below the first line is an actual TextField and the…
cmann
  • 1,920
  • 4
  • 21
  • 33
1
vote
2 answers

JLabel width always returning 0 in the constructor. Then if the width is over X value, insert a line break?

I've created a class which extends the JLabel class. This class essentially makes it "nicer" for me to attach the relevant IconImage to my JLabel, and size it correctly too. When I create a new JLabel, by code, I now do it by something = new…
user873578
1
vote
0 answers

How to get the ascent and descent of a specific string with font applied

Saved Custom Font data to UIFont. UIFont* font = [UIFont fontWithName:@"SourceHanSans-Medium" size:nEmSize]; Now I want to get the height of a string. However, the value of nEmSize, which is the size of the font, is returned for the height of the…
Jungwon
  • 1,038
  • 7
  • 20