Java – FontMetrics without Graphics

No you do not necessarily need to get/use the graphics object: Font font = new Font(“Helvetica”,Font.PLAIN,12); Canvas c = new Canvas(); FontMetrics fm = c.getFontMetrics(font); If you would now call c.getGraphics() it would return null. The canvas solution on the other hand will also work in headless mode.

Font size in pixels

Point sizes are defined as 1/72 of an inch. That is, a 72-point font is approximately 1 inch from the lowest descent to the highest ascent. So the maximum height of a glyph in a 72pt font is about 1 inch. Apple’s iphone tech specs page claims that the iPhone currently has a resolution of … Read more

How to get the font-size or a bold-version of UIFont instance

This is an old answer and it’s no longer the best solution, please see the accepted answer instead. -(UIFont *)boldFont{ //First get the name of the font (unnecessary, but used for clarity) NSString *fontName = self.fontName; //Some fonts having -Regular on their names. so we have to remove that before append -Bold / -BoldMT fontName … Read more

How to use css to change font size

While the font-size cannot be changed for text directly inside pre tags, you can always wrap that text in another element (a span, for example) and change the font size of that element. For example (this is inline-styles, but could be put in CSS if you wanted): <pre><span class=”inner-pre” style=”font-size: 11px”> Blah blah Multiple lines … Read more

Different font sizes in the same annotation of matplotlib

Make your plot first, then use ax.annotate, iterating over your x coordinates, y coordinates, labels and fontsizes. import matplotlib.pyplot as plt X = [1,2,3,4,5] Y = [1,1,1,1,1] labels=”ABCDE” sizes = [10, 15, 20, 25, 30] fig, ax = plt.subplots() ax.scatter(X, Y) for x, y, label, size in zip(X, Y, labels, sizes): ax.annotate(label, (x, y), fontsize=size) … Read more

Changing font size into an AlertDialog

You can actually get access to the message’s TextView pretty easily, and then change it’s size. I tested with a bigger size, but you could use whatever size you want. The text will scroll nicely as it already does. The view’s id is android.R.id.message AlertDialog dialog = new AlertDialog.Builder(this).setMessage(“Hello world”).show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)