107 lines
2.8 KiB
C
107 lines
2.8 KiB
C
#include <FontStr.h>
|
|||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
static char TheFaceName[80];
|
||
|
|
|
||
|
|
char* GetType(char* s, TEXTMETRIC TextMetrics) {
|
||
|
|
if (!s) return NULL;
|
||
|
|
strcpy(s, "Font Type:");
|
||
|
|
if ((TextMetrics.tmAveCharWidth & TMPF_FIXED_PITCH)==TMPF_FIXED_PITCH) {
|
||
|
|
strcat(s, "Fixed<>");
|
||
|
|
}
|
||
|
|
if ((TextMetrics.tmAveCharWidth & TMPF_VECTOR)==TMPF_VECTOR) {
|
||
|
|
strcat(s, "Vector<>");
|
||
|
|
}
|
||
|
|
if ((TextMetrics.tmAveCharWidth & TMPF_TRUETYPE)==TMPF_TRUETYPE) {
|
||
|
|
strcat(s, "TrueType<>");
|
||
|
|
}
|
||
|
|
if ((TextMetrics.tmAveCharWidth & TMPF_DEVICE)==TMPF_DEVICE) {
|
||
|
|
strcat(s, "Device<>");
|
||
|
|
}
|
||
|
|
if (strlen(s) > 11) {
|
||
|
|
int len = strlen(s);
|
||
|
|
s[len - 3]='\0';
|
||
|
|
}
|
||
|
|
return s;
|
||
|
|
}
|
||
|
|
|
||
|
|
char* GetFamily(char* s, TEXTMETRIC TextMetrics) {
|
||
|
|
int R = TextMetrics.tmPitchAndFamily & 0xF0;
|
||
|
|
strcpy(s, "Family:");
|
||
|
|
if (R==FF_DONTCARE) {
|
||
|
|
strcat(s, "Don't Care or don't know");
|
||
|
|
}
|
||
|
|
if (R==FF_ROMAN) {
|
||
|
|
strcat(s, "Roman");
|
||
|
|
}
|
||
|
|
if (R==FF_SWISS) {
|
||
|
|
strcat(s, "Swiss");
|
||
|
|
}
|
||
|
|
if (R==FF_MODERN) {
|
||
|
|
strcat(s, "Modern");
|
||
|
|
}
|
||
|
|
if (R==FF_SCRIPT) {
|
||
|
|
strcat(s, "Script");
|
||
|
|
}
|
||
|
|
if (R==FF_DECORATIVE) {
|
||
|
|
strcat(s, "Decorative");
|
||
|
|
}
|
||
|
|
return s;
|
||
|
|
}
|
||
|
|
|
||
|
|
char* GetCharSet(char* s, TEXTMETRIC TextMetrics) {
|
||
|
|
strcpy(s, "Char Set:");
|
||
|
|
if (TextMetrics.tmCharSet==ANSI_CHARSET) {
|
||
|
|
strcat(s, "Ansi");
|
||
|
|
}
|
||
|
|
if (TextMetrics.tmCharSet==DEFAULT_CHARSET) {
|
||
|
|
strcat(s, "Default");
|
||
|
|
}
|
||
|
|
if (TextMetrics.tmCharSet==SYMBOL_CHARSET) {
|
||
|
|
strcat(s, "Symbol");
|
||
|
|
}
|
||
|
|
if (TextMetrics.tmCharSet==OEM_CHARSET) {
|
||
|
|
strcat(s, "OEM");
|
||
|
|
}
|
||
|
|
return s;
|
||
|
|
}
|
||
|
|
|
||
|
|
char* GetFontString(char* s, int s_len, TEXTMETRIC TextMetric, char* FaceName) {
|
||
|
|
if (!s || !FaceName) {
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
char szType[99];
|
||
|
|
char szFamily[99];
|
||
|
|
char szCharSet[99];
|
||
|
|
|
||
|
|
GetType(szType, TextMetric);
|
||
|
|
GetFamily(szFamily, TextMetric);
|
||
|
|
GetCharSet(szCharSet, TextMetric);
|
||
|
|
|
||
|
|
snprintf(s, s_len, "Font: %s\n"
|
||
|
|
"Height: %d\n"
|
||
|
|
"Ascent: %d\n"
|
||
|
|
"Descent: %d\n"
|
||
|
|
"AveCharW: %d\n"
|
||
|
|
"MaxCharW: %d\n"
|
||
|
|
"Weight: %d\n"
|
||
|
|
"Italic: %hd\n"
|
||
|
|
"Underlined: %d\n"
|
||
|
|
"%s\n"
|
||
|
|
"%s\n"
|
||
|
|
"%s",
|
||
|
|
FaceName,
|
||
|
|
TextMetric.tmHeight,
|
||
|
|
TextMetric.tmAscent,
|
||
|
|
TextMetric.tmDescent,
|
||
|
|
TextMetric.tmAveCharWidth,
|
||
|
|
TextMetric.tmMaxCharWidth,
|
||
|
|
TextMetric.tmWeight,
|
||
|
|
TextMetric.tmItalic,
|
||
|
|
TextMetric.tmUnderlined,
|
||
|
|
szType, szFamily, szCharSet
|
||
|
|
);
|
||
|
|
return s;
|
||
|
|
}
|