7f0ae838d7
This changes the font plugin from using a font file to using a specific installed system font, which is searched for on each specific system and associated with the font file. It now uses a font property instead of a path property, and font size has been removed because the font property now handles that. When the module is first loaded, it will build up a list of system fonts in order to be usable by Freetype. It was quite painful to program this because font files can contain multiple localized versions of their face names, and then there was the issue where windows likes to mangle custom style types to the font name. Regardless, it all seems to have worked out pretty well. Minor issues: - Truetype/Opentype fonts sometimes do not automatically have italic and/or bold styles available, it seems that the system applies transformations manually in those cases. We don't do this yet, however, so right now a user might select a font with italic/bold only to discover that italic/bold doesn't always work. Not entirely sure what to do about this yet. There's probably a freetype function to do something like that somehow, This also requires that iconv be used for non-windows systems to be able to look up localized font names within font files. Windows will use the win32 API and code page IDs to translate font names.
41 lines
851 B
C
41 lines
851 B
C
#pragma once
|
|
|
|
#include <ft2build.h>
|
|
#include FT_FREETYPE_H
|
|
#include FT_SFNT_NAMES_H
|
|
#include FT_TRUETYPE_IDS_H
|
|
|
|
#include <util/dstr.h>
|
|
#include <util/darray.h>
|
|
|
|
struct font_path_info {
|
|
char *face_and_style;
|
|
size_t full_len;
|
|
size_t face_len;
|
|
|
|
bool is_bitmap;
|
|
size_t num_sizes;
|
|
int *sizes;
|
|
|
|
bool bold;
|
|
bool italic;
|
|
|
|
char *path;
|
|
FT_Long index;
|
|
};
|
|
|
|
static inline void font_path_info_free(struct font_path_info *info)
|
|
{
|
|
bfree(info->sizes);
|
|
bfree(info->face_and_style);
|
|
bfree(info->path);
|
|
}
|
|
|
|
extern void build_font_path_info(FT_Face face, FT_Long idx, const char *path);
|
|
extern char *sfnt_name_to_utf8(FT_SfntName *sfnt_name);
|
|
|
|
extern void load_os_font_list(void);
|
|
extern void free_os_font_list(void);
|
|
extern const char *get_font_path(const char *family, uint16_t size,
|
|
const char *style, uint32_t flags, FT_Long *idx);
|