Must I use path to fonts? - c++

The FT_New_Face function seems to be the one I'm looking for, but it requires a path to the font file. I would like to open a font like "Times New Roman," without supplying a path. How can I do that?

Most unix-based systems use Fontconfig for this to get best matching font file from set of search parameters ( family name, variations, weight etc )
Fontconfig is a library for configuring and customizing font access.
Fontconfig can:
discover new fonts when installed automatically, removing a common
source of configuration problems.
perform font name substitution, so that appropriate alternative fonts can be selected if fonts are missing.
identify the set of fonts required to completely cover a set
of languages.
have GUI configuration tools built as it uses an XML-based configuration file (though with autodiscovery, we believe
this need is minimized).
efficiently and quickly find the fonts you
need among the set of fonts you have installed, even if you have
installed thousands of fonts, while minimzing memory usage.
be used in concert with the X Render Extension and FreeType to implement high quality, anti-aliased and subpixel rendered text on a display.
Fontconfig does not:
render the fonts themselves (this is left to FreeType or other
rendering mechanisms)
depend on the X Window System in any fashion, so
that printer only applications do not have such dependencies
Fontconfig is relatively portable and used on a variety of systems, however OSX has CoreText which has similar functionality and Windows has DirectWrite
Refer to this question for help on how to use Fontconfig.

Related

How to package several icons for different sizes in a VS C++ app?

I'm developing a C++ app in Visual Studio 2022 with a UI (UI library is wxWidgets). I'm trying to figure out how icons work. I gathered from researching that Windows expects a variety of different icons to be packaged with apps for the best UX (see Which icon sizes should my Windows application's icon include?). However I can't seem to find a way to get multiple icons taken into account.
My understanding so far is that all resource related things, including icons, are controlled by Resource.h and <projectName>.rc, both of which are initially provided by the VS template for a C++ App.
I've removed the provided icons (i.e the "normal" and "small" ones) and have instead imported many icons, one for each size, in the Resource View.
But regardless of that, always one icon seem to be used at a time.
Checking the contents of <projectName>.rc, I see the following:
I also expect the following, in Resource.h, to be relevant:
It seems that independently of the icon sizes, IDI_ICON1 is used. If it's 16x16, it's upscaled in context that requires it, if it's 256x256, it's downscaled (poorly, somehow ?) when required i.e in almost all contexts.
How should this be done ? Are there resources available on the matter I may have missed ?
You should embed all your ico files with different resolution into one ico file. The ico file is actually a container and can contain multiple images inside.

Localization Font

I am very new to localization, I am trying to localize a small software which has 19 folders 'en', 'jp, 'tw' as names for example. Inside each one is a text file saved as utf-8 with language data.
The problem is when I try and copy and paste from a chinese site I get strange glyphs like this [][][][] I presume its because my system font is not chinese and it does not support that.
As a developer should I somehow change my entire system font to have all of these languages supported? Is there such a font? I am unsure how software companies handle these things.
As a developer should I somehow change my entire system font to have
all of these languages supported?
No, you should not. Consider localization string as data.
The problem is when I try and copy and paste from a chinese site I get
strange glyphs like this [][][][] I presume its because my system font
is not chinese and it does not support that.
But you should be provided with such data and you should know it's encoding.
Also, I've suggest you to check internationalization libraries (like gettext) to prevent reinventing the wheel.

Produce an OpenType font programmatically: request for HOWTO

Background: Adobe released their first open source fonts to the GitHub. Repos consist of many files with different syntax, some of them are binary. See e.g. https://github.com/adobe/source-sans-pro
In the corresponding README file, build process is outlined like this:
> Key to building OTF or TTF fonts is makeotf, which is part of the AFDKO toolset.
> In this repository, all necessary files are in place for building the OTF and TTF fonts.
It works, but doesn't contribute to my understanding of the font creation process. I've found specs of some of the formats, but very little about what they do. A good HOWTO would help a lot.
And the main question is, I have glyphs in SVG (or any other vector) format and necessary metrics for each glyph. Let's also say that kerning is a non-issue for now, to keep things simple.
How do I build an OTF (or TTF) font file automatically with those?
I'm comfortable with both programming and reading the f. manuals, just don't know where to begin.

Use PDF Core Fonts in wkhtmltopdf/QPrinter

Questions in a nutshell:
Is it possible to force wkhtmltopdf to use Type1 fonts (PDF core fonts) when generating the pdf?
or: Is it possible to force the Qt QPdfEngine to use Type1 fonts (PDF core fonts) when generating the pdf?
Detailed description of the problem.
I have developed a webapp to do a pdf-export of a very large database using wkhtmltopdf & tcpdf. The (900+) pages are "printed" using wkhtmltopdf and then "glued together" using tcpdf & fpdi.
Unfortunately wkhtmltopdf seems to always embed the fonts it uses to render the pdf. This is very unwanted behavior as this is redundant and bloats the document. Additionally the document needs to be editable in Acrobat Pro. Apparently Acrobat Pro seems to be overwhelmed by embedded fonts. It tries to replace them upon saving the document, and hangs itself after ~45 minutes on windows machines (on Mac machines it just takes incredibly long to save the document).
So: is there a possibility to tell wkhtmltopdf not to embed fonts and use Type1 Fonts (Helvetica) instead?
I couldn't find any switch to do this so i assumed patching wkhtmltopdf would do the trick by using: printer->setUseEmbeddedFonts(false)
Unfortunately this didn't change anything.
My next idea was patching the Qt-PDF-Printer. Looking into the QPrinter-Class and the QPrintEngine I didn't find any place where the pdf engine uses Type1 fonts instead of embedding the TTF-Fonts (or whatever font is used).
Any ideas and/or pointers?

Embedding Third Party Fonts as resource for Win32 Application

I was wondering how i can embed a third party font into my app( and use it ) so i can distribute my app with the font of my choice for users who do not have the font installed on their systems. Is this possible, or do i have to distribute the font if i want the users to be able to use the font in question. Thanks.
Stick the actual font file into a User-Defined Resource.
Very few fonts will have a license that allows this. Even a free font should be checked.
You can use CreateScalableFontResource and AddFontResource to make a font file available to your application. The font must be available as a separate file for this to work.