Add new spacing value FC_DUAL (dual-width, as some CJK fonts). (bug #111)
When checking for monospace and dual-width fonts, allow roughly a 3% variance in the advances.
This commit is contained in:
parent
3ef32bcdc4
commit
a05d257fb3
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
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>
|
2003-08-31 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
* src/fccfg.c (FcConfigAppFontClear): Support passing NULL to
|
* src/fccfg.c (FcConfigAppFontClear): Support passing NULL to
|
||||||
|
|
|
@ -139,8 +139,8 @@ convenience for the applications rendering mechanism.
|
||||||
aspect FC_ASPECT Double Stretches glyphs horizontally
|
aspect FC_ASPECT Double Stretches glyphs horizontally
|
||||||
before hinting
|
before hinting
|
||||||
pixelsize FC_PIXEL_SIZE Double Pixel size
|
pixelsize FC_PIXEL_SIZE Double Pixel size
|
||||||
spacing FC_SPACING Int Proportional, monospace or
|
spacing FC_SPACING Int Proportional, dual-width,
|
||||||
charcell
|
monospace or charcell
|
||||||
foundry FC_FOUNDRY String Font foundry name
|
foundry FC_FOUNDRY String Font foundry name
|
||||||
antialias FC_ANTIALIAS Bool Whether glyphs can be
|
antialias FC_ANTIALIAS Bool Whether glyphs can be
|
||||||
antialiased
|
antialiased
|
||||||
|
|
|
@ -98,7 +98,7 @@ convenience for the applications rendering mechanism.
|
||||||
size Double Point size
|
size Double Point size
|
||||||
aspect Double Stretches glyphs horizontally before hinting
|
aspect Double Stretches glyphs horizontally before hinting
|
||||||
pixelsize Double Pixel size
|
pixelsize Double Pixel size
|
||||||
spacing Int Proportional, monospace or charcell
|
spacing Int Proportional, dual-width, monospace or charcell
|
||||||
foundry String Font foundry name
|
foundry String Font foundry name
|
||||||
antialias Bool Whether glyphs can be antialiased
|
antialias Bool Whether glyphs can be antialiased
|
||||||
hinting Bool Whether the rasterizer should use hinting
|
hinting Bool Whether the rasterizer should use hinting
|
||||||
|
@ -349,6 +349,7 @@ symbolic names for common font values:
|
||||||
italic slant 100
|
italic slant 100
|
||||||
oblique slant 110
|
oblique slant 110
|
||||||
proportional spacing 0
|
proportional spacing 0
|
||||||
|
dual spacing 90
|
||||||
mono spacing 100
|
mono spacing 100
|
||||||
charcell spacing 110
|
charcell spacing 110
|
||||||
unknown rgba 0
|
unknown rgba 0
|
||||||
|
|
|
@ -128,6 +128,7 @@ typedef int FcBool;
|
||||||
#define FC_WIDTH_ULTRAEXPANDED 200
|
#define FC_WIDTH_ULTRAEXPANDED 200
|
||||||
|
|
||||||
#define FC_PROPORTIONAL 0
|
#define FC_PROPORTIONAL 0
|
||||||
|
#define FC_DUAL 90
|
||||||
#define FC_MONO 100
|
#define FC_MONO 100
|
||||||
#define FC_CHARCELL 110
|
#define FC_CHARCELL 110
|
||||||
|
|
||||||
|
|
|
@ -1807,6 +1807,8 @@ FcFreeTypeCheckGlyph (FT_Face face, FcChar32 ucs4,
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define APPROXIMATELY_EQUAL(x,y) (ABS ((x) - (y)) <= MAX (ABS (x), ABS (y)) / 33)
|
||||||
|
|
||||||
FcCharSet *
|
FcCharSet *
|
||||||
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
{
|
{
|
||||||
|
@ -1820,8 +1822,8 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
int o;
|
int o;
|
||||||
int i;
|
int i;
|
||||||
FT_UInt glyph;
|
FT_UInt glyph;
|
||||||
FT_Pos advance, all_advance = 0;
|
FT_Pos advance, advance_one = 0, advance_two = 0;
|
||||||
FcBool has_advance = FcFalse, fixed_advance = FcTrue;
|
FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
|
||||||
|
|
||||||
fcs = FcCharSetCreate ();
|
fcs = FcCharSetCreate ();
|
||||||
if (!fcs)
|
if (!fcs)
|
||||||
|
@ -1851,10 +1853,20 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
if (!has_advance)
|
if (!has_advance)
|
||||||
{
|
{
|
||||||
has_advance = FcTrue;
|
has_advance = FcTrue;
|
||||||
all_advance = advance;
|
advance_one = advance;
|
||||||
}
|
}
|
||||||
else if (advance != all_advance)
|
else if (!APPROXIMATELY_EQUAL (advance, advance_one))
|
||||||
fixed_advance = FcFalse;
|
{
|
||||||
|
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);
|
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
|
||||||
if (!leaf)
|
if (!leaf)
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
@ -1899,10 +1911,20 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
if (!has_advance)
|
if (!has_advance)
|
||||||
{
|
{
|
||||||
has_advance = FcTrue;
|
has_advance = FcTrue;
|
||||||
all_advance = advance;
|
advance_one = advance;
|
||||||
}
|
}
|
||||||
else if (advance != all_advance)
|
else if (!APPROXIMATELY_EQUAL (advance, advance_one))
|
||||||
fixed_advance = FcFalse;
|
{
|
||||||
|
if (fixed_advance)
|
||||||
|
{
|
||||||
|
dual_advance = FcTrue;
|
||||||
|
fixed_advance = FcFalse;
|
||||||
|
advance_two = advance;
|
||||||
|
}
|
||||||
|
else if (!APPROXIMATELY_EQUAL (advance, advance_two))
|
||||||
|
dual_advance = FcFalse;
|
||||||
|
}
|
||||||
|
|
||||||
if (!leaf)
|
if (!leaf)
|
||||||
{
|
{
|
||||||
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
|
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
|
||||||
|
@ -1956,10 +1978,19 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
if (!has_advance)
|
if (!has_advance)
|
||||||
{
|
{
|
||||||
has_advance = FcTrue;
|
has_advance = FcTrue;
|
||||||
all_advance = advance;
|
advance_one = advance;
|
||||||
}
|
}
|
||||||
else if (advance != all_advance)
|
else if (!APPROXIMATELY_EQUAL (advance, advance_one))
|
||||||
fixed_advance = FcFalse;
|
{
|
||||||
|
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);
|
leaf = FcCharSetFindLeafCreate (fcs, ucs4);
|
||||||
if (!leaf)
|
if (!leaf)
|
||||||
goto bail1;
|
goto bail1;
|
||||||
|
@ -1993,6 +2024,8 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
|
||||||
#endif
|
#endif
|
||||||
if (fixed_advance)
|
if (fixed_advance)
|
||||||
*spacing = FC_MONO;
|
*spacing = FC_MONO;
|
||||||
|
else if (dual_advance && APPROXIMATELY_EQUAL (2 * MIN (advance_one, advance_two), MAX (advance_one, advance_two)))
|
||||||
|
*spacing = FC_DUAL;
|
||||||
else
|
else
|
||||||
*spacing = FC_PROPORTIONAL;
|
*spacing = FC_PROPORTIONAL;
|
||||||
return fcs;
|
return fcs;
|
||||||
|
|
|
@ -167,6 +167,7 @@ static const FcConstant _FcBaseConstants[] = {
|
||||||
{ (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED },
|
{ (FcChar8 *) "ultraexpanded", "width", FC_WIDTH_ULTRAEXPANDED },
|
||||||
|
|
||||||
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
|
{ (FcChar8 *) "proportional", "spacing", FC_PROPORTIONAL, },
|
||||||
|
{ (FcChar8 *) "dual", "spacing", FC_DUAL, },
|
||||||
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
|
{ (FcChar8 *) "mono", "spacing", FC_MONO, },
|
||||||
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
|
{ (FcChar8 *) "charcell", "spacing", FC_CHARCELL, },
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue