When checking for monospace and dual-width fonts, allow roughly a 3%
variance in the advances.
+2003-09-06 Noah Levitt <nlevitt@columbia.edu>
+
+ * doc/fontconfig-devel.sgml:
+ * doc/fontconfig-user.sgml:
+ * fontconfig/fontconfig.h:
+ * src/fcname.c:
+ * src/fcfreetype.c (FcFreeTypeCharSetAndSpacing): Add new spacing
+ value FC_DUAL (dual-width, as some CJK fonts). (bug #111)
+
+ * src/fcfreetype.c (FcFreeTypeCharSetAndSpacing): When checking for
+ monospace and dual-width fonts, allow roughly a 3% variance in the
+ advances.
+
2003-08-31 Manish Singh <yosh@gimp.org>
* src/fccfg.c (FcConfigAppFontClear): Support passing NULL to
2003-08-31 Manish Singh <yosh@gimp.org>
* src/fccfg.c (FcConfigAppFontClear): Support passing NULL to
aspect FC_ASPECT Double Stretches glyphs horizontally
before hinting
pixelsize FC_PIXEL_SIZE Double Pixel size
aspect FC_ASPECT Double Stretches glyphs horizontally
before hinting
pixelsize FC_PIXEL_SIZE Double Pixel size
- spacing FC_SPACING Int Proportional, monospace or
- charcell
+ spacing FC_SPACING Int Proportional, dual-width,
+ monospace or charcell
foundry FC_FOUNDRY String Font foundry name
antialias FC_ANTIALIAS Bool Whether glyphs can be
antialiased
foundry FC_FOUNDRY String Font foundry name
antialias FC_ANTIALIAS Bool Whether glyphs can be
antialiased
size Double Point size
aspect Double Stretches glyphs horizontally before hinting
pixelsize Double Pixel size
size Double Point size
aspect Double Stretches glyphs horizontally before hinting
pixelsize Double Pixel size
- spacing Int Proportional, monospace or charcell
+ spacing Int Proportional, dual-width, monospace or charcell
foundry String Font foundry name
antialias Bool Whether glyphs can be antialiased
hinting Bool Whether the rasterizer should use hinting
foundry String Font foundry name
antialias Bool Whether glyphs can be antialiased
hinting Bool Whether the rasterizer should use hinting
italic slant 100
oblique slant 110
proportional spacing 0
italic slant 100
oblique slant 110
proportional spacing 0
mono spacing 100
charcell spacing 110
unknown rgba 0
mono spacing 100
charcell spacing 110
unknown rgba 0
#define FC_WIDTH_ULTRAEXPANDED 200
#define FC_PROPORTIONAL 0
#define FC_WIDTH_ULTRAEXPANDED 200
#define FC_PROPORTIONAL 0
#define FC_MONO 100
#define FC_CHARCELL 110
#define FC_MONO 100
#define FC_CHARCELL 110
+#define APPROXIMATELY_EQUAL(x,y) (ABS ((x) - (y)) <= MAX (ABS (x), ABS (y)) / 33)
+
FcCharSet *
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
{
FcCharSet *
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
{
int o;
int i;
FT_UInt glyph;
int o;
int i;
FT_UInt glyph;
- FT_Pos advance, all_advance = 0;
- FcBool has_advance = FcFalse, fixed_advance = FcTrue;
+ FT_Pos advance, advance_one = 0, advance_two = 0;
+ FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
fcs = FcCharSetCreate ();
if (!fcs)
fcs = FcCharSetCreate ();
if (!fcs)
if (!has_advance)
{
has_advance = FcTrue;
if (!has_advance)
{
has_advance = FcTrue;
- else if (advance != all_advance)
- fixed_advance = FcFalse;
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
+
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf)
goto bail1;
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf)
goto bail1;
if (!has_advance)
{
has_advance = FcTrue;
if (!has_advance)
{
has_advance = FcTrue;
- else if (advance != all_advance)
- fixed_advance = FcFalse;
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
+
if (!leaf)
{
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf)
{
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!has_advance)
{
has_advance = FcTrue;
if (!has_advance)
{
has_advance = FcTrue;
- else if (advance != all_advance)
- fixed_advance = FcFalse;
+ else if (!APPROXIMATELY_EQUAL (advance, advance_one))
+ {
+ if (fixed_advance)
+ {
+ dual_advance = FcTrue;
+ fixed_advance = FcFalse;
+ advance_two = advance;
+ }
+ else if (!APPROXIMATELY_EQUAL (advance, advance_two))
+ dual_advance = FcFalse;
+ }
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf)
goto bail1;
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf)
goto bail1;
#endif
if (fixed_advance)
*spacing = FC_MONO;
#endif
if (fixed_advance)
*spacing = FC_MONO;
+ else if (dual_advance && APPROXIMATELY_EQUAL (2 * MIN (advance_one, advance_two), MAX (advance_one, advance_two)))
+ *spacing = FC_DUAL;
else
*spacing = FC_PROPORTIONAL;
return fcs;
else
*spacing = FC_PROPORTIONAL;
return fcs;
{ (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED },
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
{ (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED },
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
+ { (FcChar8 *) "dual", "spacing", FC_DUAL, },
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },