Questions tagged [fontmetrics]
115 questions
0
votes
0 answers
How to get FontMetrics from only Font and FontRenderContext
The program I'm making uses string related calculations done with FontMetrics. As FontRenderContext may vary, it is required to make the calculations correctly and I have a static instance of it saved so I can access it anywhere.
I found a way to…

supernovaw
- 9
- 1
0
votes
1 answer
Get font glyph metrics with Swift
In order to positioning / scaling font glyphs in a custom UIView I need to know some glyph metrics, such as:
- ascent (height of the glyph from the base line, such as the part of "g" that stands over the base line)
- descent (depth of the glyph from…

Luca
- 303
- 2
- 13
0
votes
2 answers
What is the correct syntax for changing fonts and drawing strings in Java?
Can someone check my syntax here? I am passing "Times New Roman","Arial","Verdana" to fontName and using 8,12,15 etc. for fontSize. It never changes the font here. I am doing this to write some text over an image.
Graphics2D g2d = (Graphics2D)…

Pit Digger
- 9,618
- 23
- 78
- 122
0
votes
2 answers
Horizontally Centering Text in a Window with Java
I'm trying to figure out how to center text horizontally in a window using Graphics2D and FontMetrics. I made a method that I hoped would measure the length of the string once it was changed to a Font type, but it's not centering the text very…

LuminousNutria
- 1,883
- 2
- 18
- 44
0
votes
1 answer
How to get the exact space that text takes inside a cell of a JTable?
I have a row header inside a JScrollPane of which I should set the width according to the maximum width that the text takes. I managed to do so but I have to add 1 in my call to setPreferredScrollableViewportSize in order to display the full text.…

Marco
- 33
- 5
0
votes
1 answer
My while loop for determining an appropriate font size is going too far... sometimes?
I'm doing a project for school that requires me to read a file and make a bar graph with the data read. I have made a class that makes a JFrame and paints rectangles to divide the frame into a section for the name of each data (football player name)…

Matthew Mayfield
- 43
- 5
0
votes
1 answer
Java - Centering Text (on a Canvas)
thanks for checking out my question.
I am working a menu for the game that I'm making, and I want to center the game's title on the main menu. I've looked at several questions here on Stack Overflow, but couldn't find an answer.
Problem
The problem…

Xaaf Code
- 43
- 1
- 13
0
votes
1 answer
FontMetrics returning wrong character size
since I work on a LWJGL project, it encountered a problem to display text.
In theory I'd like to iterate through the (extended) ascii table and save each texture of all the chars inside of a ArrayList.
But my problem is that it won't get the right…
user8893205
0
votes
0 answers
How to check if a character is a modifier in java
I am trying to make an image to text program that converts a 0-255 value to a character that matches it (visually). The important thing here is having all characters the same width so in a text editor the text is square...
basically I want all…

Jugbot
- 142
- 1
- 14
0
votes
0 answers
android font has incorect measureText for numerals
measureText() returns the same value for '0' as for '1' using default font in a canvas. is there a font with correct measures?
output from program:
12-15 22:36:53.572 28453-28453/acme.measure I/System.out: character: '0' has text bounds: Rect(5, -68…

Ray Tayek
- 9,841
- 8
- 50
- 90
0
votes
1 answer
Java: g.drawString() width and height in pixels?
I used fontmetrics to determine the length and height of the String drawn to a jpanel but it gave me incorrect measurements.
The String I used was: "Hello World this is fantastic"
For example: a drew a string with the default font; according to the…

nathannn
- 1
- 1
- 1
0
votes
1 answer
Repaint() FontMetrics
I have something I need to draw on the screen, but that requires font metrics to draw correctly. I also need to use repaint() or something else to draw to the screen right then and there.
If I have a paintComponent(Graphics) method, I can retrieve…

Christopher Smith
- 440
- 3
- 15
0
votes
1 answer
Java: .ttf font empty, width <=0, system fonts working
I am trying to generate a bufferedImage of the size of the given text.
When using a system font, there is no problem.
I tripple checked the location, so that should not be my mistake.
I can upload the font somewhere if needed.
font =…

luckydonald
- 5,976
- 4
- 38
- 58
0
votes
1 answer
Java: Graphics aligning Strings
I'm currently trying to create a rolling text method, in which will take an argument of a String. Soon, it will start to draw, from left to right, and go onto new lines over time so it doesn't draw off of the screen. I am using the FontMetrics to…

CoderMusgrove
- 604
- 8
- 18
0
votes
1 answer
Windows store app -- get font metrics?
In a Windows store app, how can I programmatically get font metrics of the Segoe UI font? (baseline, ascent, and so forth)?

William Jockusch
- 26,513
- 49
- 182
- 323