Questions tagged [fontmetrics]

115 questions
1
vote
0 answers

MyClass cannot access class com.sun.javafx.tk.Toolkit because module javafx.graphics does not export com.sun.javafx.tk to unnamed module

I run my JavaFX app with VM options: --module-path "C:\Software\javafx-sdk-18.0.1\lib" --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics yet when I try to run the app, I get: Caused by: java.lang.IllegalAccessError: class…
coderodde
  • 1,269
  • 4
  • 17
  • 34
1
vote
0 answers

How do we set a custom line height in a TextView?

I am working on a custom TextView where we are highlighting certain words in the String with a green background drawable. The drawable is dependent on the line height for the word it is highlighting and will draw itself according to the top and…
Calvin Rai
  • 816
  • 1
  • 8
  • 17
1
vote
0 answers

calling LineBreakMeasurer using a font not installed

I think the answer here is no (ie if the fontmetrics don't exist, then how could you). But I figure it's better to ask. I need to figure out soft line breaks in a Java program that oftentimes is run on a Linux box. The fonts specified for the text…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
1
vote
1 answer

How to get the height at which to draw a strikethrough from FreeType

FreeType has font metrics for the underline position, but I can't seem to find any metrics for the strikethrough position. How do text engines usually compute this value? Should I just put it at 1/3*ascent or whatever looks good? I suppose that for…
user519179
1
vote
1 answer

What is the supported method of calculating string width (pixels) in JDK 10

I don't want to use AWT. I was using FontMetrics.computeStringWidth() but is gone in JDK 10 breaking my app. Is there an alternative that doesn't require bringing a new framework (I'm using javafx)
bluephoton
  • 379
  • 3
  • 6
1
vote
1 answer

Get exact height of WinForms Font in pixels

This is possibly a duplicate question, but I am unable to find the answer. My only question is how to get height (ascent + descent, without any spacing) of the Font used in WinForms in pixels. I have Segoe UI 8.25 Regular font. Font.Height gives me…
rattler
  • 379
  • 2
  • 5
  • 15
1
vote
3 answers

Writing in NSView

I am trying to render text in a NSView canvas. I need to write three lines of text and ignore what's beyond. String.draw(in:withAttributes) with a provided rect seems perfect to do it. My code looks like this: func renderText(_ string:String,…
Béatrice Cassistat
  • 1,048
  • 12
  • 37
1
vote
1 answer

Android Layout: meaning of getLineBaseline, getLineDescent, getLineAscent, getLineBottom, getLineTop

The documentation for the following methods of Layout (including StaticLayout, DynamicLayout, and BoringLayout) are very sparce. getLineBaseline(int line) getLineDescent(int line) getLineAscent(int line) getLineBottom(int line) getLineTop(int…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1
vote
1 answer

Where can I find a good introduction to fonts

I have to write some code working with fonts. Is there a good introduction to the subject to get me started?
David Thielen
  • 28,723
  • 34
  • 119
  • 193
1
vote
2 answers

Fontmetrics stringwidth vs string length

I have an issue where I need to test the character at the stringwidth of 256. However, when I do a charAt(index) test, I get an indexoutofbounds exception because 256 (buffered image width) is actually longer than the string.length. My question is…
Mike
  • 11
  • 1
1
vote
1 answer

How to get text advance (stringWidth) without a Graphics in Java?

How to get text advance (stringWidth) without a Graphics instance in Java? In the doc examples, stringWidth() is taken from FontMetrics, while FontMetrics is taken from Graphics. Is it possible to obtain the same without a Graphics? In the notes…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
1
vote
0 answers

Advanced Font Metrics in WinForm

Is there a way in .NET WinForm to obtain advanced font metrics? I'd need to be able to determine the following programatically: Underline thickness Underline position Strikeout thickness Strikeout position I was able to obtain a lot of…
Emilie217
  • 83
  • 1
  • 11
1
vote
1 answer

Getting the font metrics before the paint method id called

Hi I am creating a news ticker/ text scroller. I am using the following method: import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class Scroll1 extends…
Cole Gordon
  • 155
  • 1
  • 17
1
vote
2 answers

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

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…
Dan
  • 7,286
  • 6
  • 49
  • 114
1
vote
0 answers

Is there a way to get font measurements from within a PCL (Portable Class Library)?

I'm trying to find a way to get font measurements from within my PCL (Portable Class Library), however every resource I have come across to get font measurements seems to be platform specific. Is this a limitation of the PCL to not support a…
michael
  • 14,844
  • 28
  • 89
  • 177