Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find what font was actually used for my CreateFont call?

Tags:

windows

fonts

gdi

In Windows, the CreateFontIndirect() call can silently substitute compatible fonts if the requested font is not requested. The GetObject() call does not reflect this substitution; it returns the same LOGFONT passed in. How can I find what font was actually created? Alternately, how can I force Windows to only return the exact font requested?

like image 608
bdonlan Avatar asked Aug 22 '11 23:08

bdonlan


People also ask

How do I find out what font was used?

If the font you want to identify is in printed material like a magazine, you can find the name with a scanned image. Once you have a digital image, you can upload the image to a website like WhatTheFont. WhatTheFont 'reads' the font in your image and compares it to thousands it holds in its database.

What is page font?

A font is a graphical representation of text that may include a different typeface, point size, weight, color, or design.

What font is this from website?

Add (download) Google chrome extension or Safari extension on your choice of web browser. Go to webpage where you want to find out the font and click on WhatFont extension. Hover over the webpage. You will find a floating box containing font ,you want to find out.

How to identify font used in an app using WhatTheFont?

On WhatTheFont, you can upload the image of the logo or any other image of text and let the tool identify font for you. This is useful when you want to identify font used in an app as you can take a screenshot of the screen and clip the text in the image to upload in font identifying tools such as WhatTheFont.

How to find the font name of a logo?

If you have image of the logo and are unable to find the font name using the tool above then you can make use of font identifying tools available such as WhatFontIs or WhatTheFont. On WhatTheFont, you can upload the image of the logo or any other image of text and let the tool identify font for you.

How to identify a font in an image?

First you upload an image or specify an image URL, then submit and it will try to identify and match each letter in the image, finally it will show you the matching font or a list of similar fonts. Tips for better results when identifying a font: 1. Get the text as horizontal as possible.

Whatthefont is used for?

WhatTheFont is a font identification tool developed by Myfonts for instant automated identification of the font used in a photograph or scan. The tool is very easy to use yet very efficient.


2 Answers

In Windows, the CreateFontIndirect() call can silently substitute compatible fonts if the requested font is not requested. The GetObject() call does not reflect this substitution; it returns the same LOGFONT passed in.

It's not CreateFontIndirect that's doing the substitution. The substitution happens when the font is selected into the DC. CreateFontIndirect just gives you a handle to an internal copy of the LOGFONT. That's why GetObject gives you the same LOGFONT back.

How can I find what font was actually created?

If you select the HFONT into the target DC, you can then ask the DC for the information about the font that was actually chosen as the best match to the LOGFONT.

  • The face name is available with GetTextFace.
  • You can get metrics with GetTextMetrics.
  • If the selected font is TrueType or OpenType, you can get additional metrics with GetOutlineTextMetrics.

That essentially tells you what font was actually created.

Aside:

When doing something like print preview, you can start with a LOGFONT, select it into the printer DC (or IC), grab the details of the actual font (printers often substitute fonts), and then create a new LOGFONT that's more representative of the actual font. Select that into the screen DC, and--with appropriate size conversions--do a pretty good match of what the user will actually get.

like image 127
Adrian McCarthy Avatar answered Sep 27 '22 20:09

Adrian McCarthy


To get the appropriate font on different language versions of the OS, call EnumFontFamiliesEx with the desired font characteristics in the LOGFONT structure, then retrieve the appropriate typeface name and create the font using CreateFont or CreateFontIndirect.

While it's not a universal way to get the actual font name from an HFONT, you can check beforehand what CreateFontIndirect would (most likely) return.

Judging from how MSDN suggest this as a good solution for getting a font family from the attributes it seems like the way Windows internally performs the substitution.

like image 22
pezcode Avatar answered Sep 27 '22 22:09

pezcode