egra: do not record cells outside of the vertical canvas (framebuffer) in agg mini...
[iv.d.git] / fontconfig_samples / fctest.d
blobf9a191b2f8e192d4edfa02c7ac761473048f4e07
1 import iv.cmdcon;
2 import iv.fontconfig;
5 void main () {
6 if (!FcInit()) assert(0, "cannot init fontconfig");
7 //scope(exit) FcFini(); // that segfaults, lol. packard, please, kill yourself.
8 //FcPattern* pat = FcNameParse("Arial:pixelsize=16");
9 //FcPattern* pat = FcNameParse("Arial"); // works too
10 //FcPattern* pat = FcNameParse("/usr/share/fonts/TTF/arial.ttf"); // returns substitute
11 //FcPattern* pat = FcNameParse("Arial:bold");
12 //FcPattern* pat = FcNameParse("Arial:italic");
13 //FcPattern* pat = FcNameParse("Arial:italic:bold");
14 //FcPattern* pat = FcNameParse("Arial:bold:italic");
15 FcPattern* pat = FcNameParse("Courier New:bold:italic");
16 if (pat is null) assert(0, "cannot parse font name");
17 if (!FcConfigSubstitute(null, pat, FcMatchPattern)) assert(0, "cannot find fontconfig substitute");
18 FcDefaultSubstitute(pat);
19 // find the font
20 FcResult result;
21 FcPattern* font = FcFontMatch(null, pat, &result);
22 if (font !is null) {
23 char* file = null;
24 if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
25 //import std.string : fromStringz;
26 conwriteln("font file: [", file, "]");
28 double pixelsize;
29 if (FcPatternGetDouble(font, FC_PIXEL_SIZE, 0, &pixelsize) == FcResultMatch) {
30 conwriteln("pixel size: ", pixelsize);
32 double pointsize;
33 if (FcPatternGetDouble(font, FC_SIZE, 0, &pointsize) == FcResultMatch) {
34 conwriteln("point size: ", pointsize);
37 FcPatternDestroy(pat);