#include <dk.h>
#include <dktypes.h>
#include <dkfont.h>
Go to the source code of this file.
Defines | |
#define | DK_FONT_FEATURE_RM 1 |
Font feature: roman font. | |
#define | DK_FONT_FEATURE_SF 2 |
Font feature: sans-serif font. | |
#define | DK_FONT_FEATURE_TT 3 |
Font feature: typewriter font. | |
#define | DK_FONT_FEATURE_FAMILY 3 |
Font feature mask: Font family. | |
#define | DK_FONT_FEATURE_BD 4 |
Font feature: bold. | |
#define | DK_FONT_FEATURE_IT 8 |
Font feature: italic. | |
#define | DK_FONT_RP_TYPE_SYTEM 0 |
Font replacement type: System. | |
#define | DK_FONT_RP_TYPE_DOWNLOAD 1 |
Font replacement type: Download. | |
Functions | |
char * | dkfont_get_tex_name (size_t number) |
Find TeX name of a font. | |
char * | dkfont_get_ps_name (size_t number) |
Find PS name of a font. | |
char * | dkfont_get_svg_font_id (size_t number) |
Get SVG ID for font. | |
char * | dkfont_get_svg_family_name (size_t number) |
Get SVG font family name. | |
char * | dkfont_get_gs_alias_name (size_t number) |
Get GhostScript alias name for font. | |
char * | dkfont_get_gs_file_name (size_t number) |
Get GhostScript font file name. | |
char * | dkfont_get_new_gs_file_name (size_t number) |
Get new GhostScript font file name. | |
int | dkfont_get_features (size_t number) |
Get font features. | |
dk_font_t * | dkfont_get_ps_fonts (void) |
Get all PS font descriptions. | |
dk_font_mapping_t * | dkfont_mapping_open (void) |
Create a new font mapping structure. | |
void | dkfont_mapping_close (dk_font_mapping_t *f) |
Destroy font mapping structure and release memory. | |
int | dkfont_mapping_add_stream (dk_font_mapping_t *f, dk_stream_t *s) |
Add information from an input stream to the font mapping structure. | |
int | dkfont_get_error_code (dk_font_mapping_t *f) |
Retrieve last error code. | |
unsigned long | dkfont_get_error_lineno (dk_font_mapping_t *f) |
Retrieve line number of input in which the last error occured. | |
dk_one_font_mapping_t * | dkfont_get_one_font (dk_font_mapping_t *f, size_t s) |
Retrieve font substitution data for one font. | |
void | dkfont_set_used (dk_font_mapping_t *fm, size_t sz, int fl) |
Mark one font in the font mapping structure as used. | |
int | dkfont_get_used (dk_font_mapping_t *f, size_t s) |
Chech whether or not a font is marked as used. | |
void | dkfont_one_font_reset (dk_one_font_mapping_t *s) |
Reset a font substution structure (the internal pointer is set to point to the first substitution candidate structure). | |
dk_font_replacement_t * | dkfont_one_font_get (dk_one_font_mapping_t *s) |
Get next font substitution candidate structure in font substitution structure. | |
char * | dkfont_rep_get_name (dk_font_replacement_t *r) |
Get font name of font substitution candidate structure. | |
char * | dkfont_rep_get_family (dk_font_replacement_t *r) |
Get font family name of font substitution candidate structure. | |
char * | dkfont_rep_get_location (dk_font_replacement_t *r) |
Get location (directory part of download URL or directory name) of font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_source_name (dk_font_replacement_t *r) |
Get file name of font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_pfb_location (dk_font_replacement_t *r) |
Get location (directory part of download URL or directory name) of PFB font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_pfb_source_name (dk_font_replacement_t *r) |
Get file name of PFB font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_ttf_location (dk_font_replacement_t *r) |
Get location (directory part of download URL or directory name) of TTF font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_ttf_source_name (dk_font_replacement_t *r) |
Get file name of TTF font file for a font substitution candidate structure. | |
char * | dkfont_rep_get_font_type (dk_font_replacement_t *r) |
Get font type. | |
char * | dkfont_rep_get_tex_name (dk_font_replacement_t *r) |
Get TeX name for substitution candidate. | |
int | dkfont_rep_get_features (dk_font_replacement_t *r) |
Get features of substitution candidate. | |
int | dkfont_rep_get_source_type (dk_font_replacement_t *r) |
Get source type for font substitution candidate. | |
int | dkfont_rep_check_driver (dk_font_replacement_t *r, char *d) |
Check whether a font substitution candidate can be used with a driver. |
This module provides information about the 35 well-known PS fonts. For each font we can retrieve LaTeX and PS font name and a list of features. use the functions dkfont_get_tex_name(), dkfont_get_ps_name(), dkfont_get_svg_font_id(), dkfont_get_svg_family_name(), dkfont_get_gs_alias_name(), dkfont_get_gs_file_name() and dkfont_get_features() for this purpose.
Since version 1.11.0 the module can read a font configuration file for more comfortable and flexible font substitutions.
See "dklibs - Font configuration" for details about font configuration files.
Example 1: Retrieve built-in information.
size_t i; int ff; for(i = 0; i < 35; i++) { printf("Font: %lu\n", (unsigned long)i); printf("TeX/LaTeX name: %s\n", dkfong_get_tex_name(i)); printf("PS name: %s\n", dkfont_get_ps_name(i)); printf("GS alias name: %s\n", dkfont_get_gs_alias_name(i)); printf("GS old file name: %s\n", dkfont_get_gs_file_name(i)); printf("GS new file name: %s\n", dkfont_get_new_gs_file_name(i)); printf("SVG font ID: %s\n", dkfont_get_svg_font_id(i)); printf("SVG font family: %s\n", dkfont_get_svg_family_name(i)); printf("Font features: "); ff = dkfont_get_features(i); switch(ff & DK_FONT_FEATURE_FAMILY) { case 3: { printf("tty"); } break; case 2: { printf("sans-serif"); } break; default: { printf("roman"); } break; } if(ff & DK_FONT_FEATURE_BD) { printf(" bold"); } if(ff & DK_FONT_FEATURE_IT) { printf(" italic"); } printf("\n\n"); }
Example 2: Retrieve information from a configuration file.
#include <dk.h> #include <dkfont.h> #include <dkapp.h> #include <dkstream.h> dk_app_t *a; dk_stream_t *s; dk_font_mapping_t *fm; dk_one_font_mapping_t *o; dk_font_replacement_t *r; size_t i; char *t; int ff; a = dkapp_open_ext1(argc, argv, "tests", "/etc", 0, DK_APP_LOG_NO_STDOUT); if(a) { s = dkapp_read_cfg(a, "combfont.cfg"); if(s) { fm = dkfont_mapping_open(); if(fm) { if(dkfont_mapping_add_stream(fm, s)) { for(i = 0; i < 35; i++) { o = dkfont_get_one_font(fm, i); if(o) { printf("\nFont: %lu\n\n", (unsigned long)i); dkfont_one_font_reset(o); while((r = dkfont_one_get_font(o)) != NULL) { ff = dkfont_rep_get_features(r); printf("Font features: "); switch(ff & DK_FONT_FEATURE_FAMILY) { case 3: { printf("tty"); } break; case 2: { printf("sans-serif"); } break; default: { printf("roman"); } break; } if(ff & DK_FONT_FEATURE_BD) { printf(" bold"); } if(ff & DK_FONT_FEATURE_IT) { printf(" italic"); } printf("Source type: "); switch(dkfont_rep_get_source_type(r)) { case DK_FONT_RP_TYPE_DOWNLOAD: { printf("download"); } break; default: { printf("system"); } break; } printf("\n"); t = dkfont_rep_get_name(r)); if(t) printf("Replacement font: %s\n", t); t = dkfont_rep_get_family(r); if(t) printf("Replacement family: %s\n", t); t = dkfont_rep_get_font_type(r); if(t) printf("Font type name: %s\n", t); t = dkfont_rep_get_tex_name(r); if(t) printf("TeX/LaTeX name: %s\n", t); t = dkfont_rep_get_location(r); if(t) printf("Font file directory: %s\n", t); t = dkfont_rep_get_source_name(r); if(t) printf("Font file name: %s\n", t); t = dkfont_rep_get_pfb_location(r); if(t) printf("PFB file directory: %s\n", t); t = dkfont_rep_get_pfb_source_name(r); if(t) printf("PFB file name: %s\n", t); t = dkfont_rep_get_ttf_location(r); if(t) printf("TTF file directory: %s\n", t); t = dkfont_rep_get_ttf_source_name(r); if(t) printf("TTF file name: %s\n", t); printf("Drivers: "); if(dkfont_rep_check_driver(r, "svg") printf(" svg"); if(dkfont_rep_check_driver(r, "ps") printf(" ps"); printf("\n\n"); } } } } dkfont_mapping_close(fm); } dkstream_close(s); } dkapp_close(a); }
#define DK_FONT_FEATURE_BD 4 |
Font feature: bold.
#define DK_FONT_FEATURE_FAMILY 3 |
Font feature mask: Font family.
#define DK_FONT_FEATURE_IT 8 |
Font feature: italic.
#define DK_FONT_FEATURE_RM 1 |
Font feature: roman font.
#define DK_FONT_FEATURE_SF 2 |
Font feature: sans-serif font.
#define DK_FONT_FEATURE_TT 3 |
Font feature: typewriter font.
#define DK_FONT_RP_TYPE_DOWNLOAD 1 |
Font replacement type: Download.
#define DK_FONT_RP_TYPE_SYTEM 0 |
Font replacement type: System.
int dkfont_get_error_code | ( | dk_font_mapping_t * | f | ) |
Retrieve last error code.
f | Pointer to font mapping structure |
unsigned long dkfont_get_error_lineno | ( | dk_font_mapping_t * | f | ) |
Retrieve line number of input in which the last error occured.
f | Pointer to font mapping structure. |
int dkfont_get_features | ( | size_t | number | ) |
Get font features.
number | Index of the font (0-34). |
char* dkfont_get_gs_alias_name | ( | size_t | number | ) |
Get GhostScript alias name for font.
number | Index of the font (0-34). |
char* dkfont_get_gs_file_name | ( | size_t | number | ) |
Get GhostScript font file name.
number | Index of the font (0-34). |
char* dkfont_get_new_gs_file_name | ( | size_t | number | ) |
Get new GhostScript font file name.
number | Index of the font (0-34). |
dk_one_font_mapping_t* dkfont_get_one_font | ( | dk_font_mapping_t * | f, | |
size_t | s | |||
) |
Retrieve font substitution data for one font.
f | Pointer to font mapping structure. | |
s | Index of the font (0-34). |
dk_font_t* dkfont_get_ps_fonts | ( | void | ) |
Get all PS font descriptions.
char* dkfont_get_ps_name | ( | size_t | number | ) |
Find PS name of a font.
number | Index of the font (0-35). |
char* dkfont_get_svg_family_name | ( | size_t | number | ) |
Get SVG font family name.
number | Index of the font (0-35). |
char* dkfont_get_svg_font_id | ( | size_t | number | ) |
Get SVG ID for font.
number | Index of the font (0-35). |
char* dkfont_get_tex_name | ( | size_t | number | ) |
Find TeX name of a font.
number | Index of the font (0-34). |
int dkfont_get_used | ( | dk_font_mapping_t * | f, | |
size_t | s | |||
) |
Chech whether or not a font is marked as used.
f | Pointer to font mapping structure. | |
s | Index of the font (0-34). |
int dkfont_mapping_add_stream | ( | dk_font_mapping_t * | f, | |
dk_stream_t * | s | |||
) |
Add information from an input stream to the font mapping structure.
f | Pointer to font mapping structure. | |
s | Pointer to stream. |
void dkfont_mapping_close | ( | dk_font_mapping_t * | f | ) |
Destroy font mapping structure and release memory.
f | Pointer to font mapping structure to destroy. |
dk_font_mapping_t* dkfont_mapping_open | ( | void | ) |
Create a new font mapping structure.
The font mapping structure is created in dynamically allocated memory, use dkfont_mapping_close() to destroy the structure and release the memory if the structure is no longer needed.
dk_font_replacement_t* dkfont_one_font_get | ( | dk_one_font_mapping_t * | s | ) |
Get next font substitution candidate structure in font substitution structure.
s | Pointer to font substitution structure. |
void dkfont_one_font_reset | ( | dk_one_font_mapping_t * | s | ) |
Reset a font substution structure (the internal pointer is set to point to the first substitution candidate structure).
s | Pointer to font substution structure. |
int dkfont_rep_check_driver | ( | dk_font_replacement_t * | r, | |
char * | d | |||
) |
Check whether a font substitution candidate can be used with a driver.
r | Font substitution candidate structure. | |
d | Driver name. |
char* dkfont_rep_get_family | ( | dk_font_replacement_t * | r | ) |
Get font family name of font substitution candidate structure.
r | Font substitution candidate structure. |
int dkfont_rep_get_features | ( | dk_font_replacement_t * | r | ) |
Get features of substitution candidate.
r | Font substitution candidate structure. |
char* dkfont_rep_get_font_type | ( | dk_font_replacement_t * | r | ) |
Get font type.
r | Font substitution candidate structure. |
char* dkfont_rep_get_location | ( | dk_font_replacement_t * | r | ) |
Get location (directory part of download URL or directory name) of font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
char* dkfont_rep_get_name | ( | dk_font_replacement_t * | r | ) |
Get font name of font substitution candidate structure.
r | Font substitution candidate structure. |
char* dkfont_rep_get_pfb_location | ( | dk_font_replacement_t * | r | ) |
Get location (directory part of download URL or directory name) of PFB font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
char* dkfont_rep_get_pfb_source_name | ( | dk_font_replacement_t * | r | ) |
Get file name of PFB font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
char* dkfont_rep_get_source_name | ( | dk_font_replacement_t * | r | ) |
Get file name of font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
int dkfont_rep_get_source_type | ( | dk_font_replacement_t * | r | ) |
Get source type for font substitution candidate.
r | Font substitution candidate structure. |
char* dkfont_rep_get_tex_name | ( | dk_font_replacement_t * | r | ) |
Get TeX name for substitution candidate.
r | Font substitution candidate structure. |
char* dkfont_rep_get_ttf_location | ( | dk_font_replacement_t * | r | ) |
Get location (directory part of download URL or directory name) of TTF font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
char* dkfont_rep_get_ttf_source_name | ( | dk_font_replacement_t * | r | ) |
Get file name of TTF font file for a font substitution candidate structure.
r | Font substitution candidate structure. |
void dkfont_set_used | ( | dk_font_mapping_t * | fm, | |
size_t | sz, | |||
int | fl | |||
) |
Mark one font in the font mapping structure as used.
fm | Pointer to font mapping structure. | |
sz | Index of the font (0-34). | |
fl | Flag (1=font used, 0=font not used). |