Questions tagged [fontmetrics]

115 questions
1
vote
0 answers

Unity Font Metrics counting ascent for dymaic fonts

I want to custom render font, but how to calc ascent for dynamic font for other size? Using Font.ascent I receive only ascent for current setted size. On image: 1 step - Without shifting; 2 step - Shift on char height; 3 step - shift on ascent - to…
Oksana
  • 13,442
  • 10
  • 53
  • 89
1
vote
1 answer

Obtaining FontMetrics before getting a Graphics instance

Typically, I'd obtain a graphics instance something like this: BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = img.createGraphics(); However, in the current project I'm working on, the width and…
Tom Castle
  • 2,198
  • 1
  • 16
  • 20
1
vote
1 answer

How to get the real height of a character (fontmetrics/graphics2d)

I am currently in need to get the real height of a character. I am aware of the functions like getDecsent(), getAscent(), ... but they only allow to get values regarding the hole font (in its context). I also tried the way using getStringBounds(),…
Markus
  • 11
  • 1
1
vote
0 answers

Calculating line length in Java

I've been using LineBreakMeasurer & AttributedString to measure line lengths. However, I now need to take into account: Small Caps Scaling (making each character thinner/wider). Spacing (adding/subtracting space after each character). Hyphenation,…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
1
vote
1 answer

Java 2D PNG: Calculate Dimension

I want to create a PNG Image with Java. In this image I want to show some random Text. Normaly I would create a picture like this: BufferedImage bi = new BufferedImage(300,300,BufferedImage.TYPE_INT_ARGB); bi.getGraphics().drawString("Hello world",…
1
vote
2 answers

Getting Font Metrics in PHP

I was wondering if there is anything in PHP that will get me different properties of a font like ascent, descent, leading, height, etc. Something similar to FontMetrics class in java fount…
Romit
  • 96
  • 2
  • 13
1
vote
1 answer

Alternative of FontMetrics in Java

My code uses getFontMetrics() which is deprecated. What could be the alternative ? public void setFont ( Font font ) { if(font == null){ Font defaultFont=(Font)javax.swing.UIManager.getDefaults().get ( "Label.font" ) ; …
Ashish
  • 14,295
  • 21
  • 82
  • 127
1
vote
0 answers

FontMetrics return garbage font descent

I am facing a weird problem in Eclipse, and even after lot of search, haven't found any Bugs also in this regard. My Problem is with the handle field in FontMetrics Class. Since the API says its Platform Dependent, there is not much I can do about…
Saurabh
  • 63
  • 8
1
vote
1 answer

getFontMetrics() taking 8000ms on first call in Java Applet

Making a call to getFontMetrics()in my java applet is taking between 5000ms and 22000ms to return! Subsequent calls seem to take a negligible amount of time (0-16ms) I have to admit I'm running on a machine with bare bones graphics drivers (Graphics…
jason
  • 427
  • 5
  • 20
0
votes
1 answer

How the GetTextMetrics method gets the font metrics from a font ?

I am designing a font and need to set its font metrics, as mentioned in this article, different software and systems may use different parameters as font metrics. I would like to know how the win32 API GetTextMetrics converts the parameters in the…
Bourbon_7
  • 161
  • 7
0
votes
0 answers

How can I convert the result FontMetrics.stringWidth() returns to millimeter?

I have benn working on compose office document (docx) by using Java, and the related design requires to know the millimeter of a string.But when I use code below to get pixel of this very sentence, the pixel is not correct(I'm using a 2.8k display,…
welt chen
  • 1
  • 1
0
votes
1 answer

Resize JTable to fit contents does not work precisely, resulting in elipses

I want to perfectly resize a JTable to fit its model contents based on either the column header label, OR the row containing the longest String for the same column (whichever is greatest). I don't want to use the renderer to determine these sizes as…
0
votes
1 answer

Getting the glyph width of a monospaced font

Recently I asked on a different forum about the glyph width of the Source Code Pro font (it’s 600). This helps me in setting tab stops in a word processor for code samples. How do I find the glyph width of other Monospaced fonts?
Manngo
  • 14,066
  • 10
  • 88
  • 110
0
votes
0 answers

Draw string inside rectangle visually

I'm trying to display text inside a rectangle which I have the dimensions of (x, y, width, and height). However, if the text's length is long enough to the point where the text would leak outside the rectangle, I want to instead display as many…
0
votes
1 answer

I can't center text in java swing

I'm making custom components for my game and I tried everything I found in Stack Overflow and no matter what I still can't place text in the center of a rectangle. I even read all the documentation of working with java text API. Can anyone explain…
RDev
  • 41
  • 6